Class: BranchDb::Cloner
- Inherits:
-
Object
- Object
- BranchDb::Cloner
- Defined in:
- lib/branch_db/cloner.rb
Constant Summary
Constants included from Logging
Constants included from PgUtils
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(config, output: $stdout) ⇒ Cloner
constructor
A new instance of Cloner.
- #source_db ⇒ Object
- #source_exists? ⇒ Boolean
- #target_db ⇒ Object
Constructor Details
#initialize(config, output: $stdout) ⇒ Cloner
Returns a new instance of Cloner.
8 9 10 11 |
# File 'lib/branch_db/cloner.rb', line 8 def initialize(config, output: $stdout) @config = config.is_a?(Hash) ? config : config.configuration_hash @output = output end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/branch_db/cloner.rb', line 6 def config @config end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/branch_db/cloner.rb', line 6 def output @output end |
Instance Method Details
#clone ⇒ Object
13 14 15 16 17 |
# File 'lib/branch_db/cloner.rb', line 13 def clone log "📦 Cloning #{source_db} → #{target_db}..." create_or_recreate_database transfer_data end |
#source_db ⇒ Object
24 |
# File 'lib/branch_db/cloner.rb', line 24 def source_db = @source_db ||= determine_source_db |
#source_exists? ⇒ Boolean
19 20 21 22 |
# File 'lib/branch_db/cloner.rb', line 19 def source_exists? check_pg_tools!(:psql, :pg_dump) database_exists?(source_db) end |
#target_db ⇒ Object
26 |
# File 'lib/branch_db/cloner.rb', line 26 def target_db = config[:database] |