Class: Slipcover::DevTools::Replicator
- Inherits:
-
Object
- Object
- Slipcover::DevTools::Replicator
- Defined in:
- lib/slipcover/dev_tools.rb
Instance Attribute Summary collapse
-
#database_name ⇒ Object
readonly
Returns the value of attribute database_name.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#source_environment ⇒ Object
readonly
Returns the value of attribute source_environment.
-
#source_server ⇒ Object
readonly
Returns the value of attribute source_server.
-
#target_environment ⇒ Object
readonly
Returns the value of attribute target_environment.
-
#target_server ⇒ Object
readonly
Returns the value of attribute target_server.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Replicator
constructor
A new instance of Replicator.
- #perform ⇒ Object
Constructor Details
#initialize(opts) ⇒ Replicator
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/slipcover/dev_tools.rb', line 14 def initialize(opts) @source_environment = opts[:source_environment] || "staging" @target_environment = opts[:target_environment] || "development" @database_name = opts[:database_name] @logger = opts[:logger] || Logger.new("/dev/null") @source_server = Slipcover::Server.new(Slipcover::Config.yaml_path, source_environment) @target_server = Slipcover::Server.new(Slipcover::Config.yaml_path, target_environment) @http = HttpAdapter.new end |
Instance Attribute Details
#database_name ⇒ Object (readonly)
Returns the value of attribute database_name.
12 13 14 |
# File 'lib/slipcover/dev_tools.rb', line 12 def database_name @database_name end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
12 13 14 |
# File 'lib/slipcover/dev_tools.rb', line 12 def http @http end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/slipcover/dev_tools.rb', line 12 def logger @logger end |
#source_environment ⇒ Object (readonly)
Returns the value of attribute source_environment.
10 11 12 |
# File 'lib/slipcover/dev_tools.rb', line 10 def source_environment @source_environment end |
#source_server ⇒ Object (readonly)
Returns the value of attribute source_server.
10 11 12 |
# File 'lib/slipcover/dev_tools.rb', line 10 def source_server @source_server end |
#target_environment ⇒ Object (readonly)
Returns the value of attribute target_environment.
11 12 13 |
# File 'lib/slipcover/dev_tools.rb', line 11 def target_environment @target_environment end |
#target_server ⇒ Object (readonly)
Returns the value of attribute target_server.
11 12 13 |
# File 'lib/slipcover/dev_tools.rb', line 11 def target_server @target_server end |
Instance Method Details
#perform ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/slipcover/dev_tools.rb', line 26 def perform logger.info "Fetching list of #{source_environment} databases#{" containing string \"" + database_name + "\"" if database_name}..." logger.info "Replicating these dbs: #{dbs_to_replicate.join(",")}" dbs_to_replicate.each_with_index.map do |db, i| Thread.new(db, i, &method(:replicate)) end.map(&:join) end |