Class: BranchDb::Preparer
- Inherits:
-
Object
- Object
- BranchDb::Preparer
- Includes:
- Logging
- Defined in:
- lib/branch_db/preparer.rb
Overview
Checks if database needs initialization and triggers cloning if needed. Used by the db:prepare rake task enhancement.
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#db_config ⇒ Object
readonly
Returns the value of attribute db_config.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(db_config, output: $stdout) ⇒ Preparer
constructor
A new instance of Preparer.
- #prepare_if_needed ⇒ Object
Constructor Details
#initialize(db_config, output: $stdout) ⇒ Preparer
Returns a new instance of Preparer.
9 10 11 12 |
# File 'lib/branch_db/preparer.rb', line 9 def initialize(db_config, output: $stdout) @db_config = db_config @output = output end |
Instance Attribute Details
#db_config ⇒ Object (readonly)
Returns the value of attribute db_config.
7 8 9 |
# File 'lib/branch_db/preparer.rb', line 7 def db_config @db_config end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/branch_db/preparer.rb', line 7 def output @output end |
Instance Method Details
#prepare_if_needed ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/branch_db/preparer.rb', line 14 def prepare_if_needed log "📦 Checking database#{db_label}..." unless needs_cloning? log "✅ Database '#{config[:database]}' ready." return end attempt_clone end |