Class: Cloudsync::SyncManager
- Inherits:
-
Object
- Object
- Cloudsync::SyncManager
- Defined in:
- lib/cloudsync/sync_manager.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#from_backend ⇒ Object
Returns the value of attribute from_backend.
-
#to_backend ⇒ Object
Returns the value of attribute to_backend.
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
-
#initialize(opts = {}) ⇒ SyncManager
constructor
A new instance of SyncManager.
- #mirror! ⇒ Object
- #prune! ⇒ Object
- #sync! ⇒ Object
- #sync_all! ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ SyncManager
Returns a new instance of SyncManager.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cloudsync/sync_manager.rb', line 7 def initialize(opts={}) @from_backend = get_backend opts[:from] @to_backend = get_backend opts[:to] if @from_backend == @to_backend raise ArgumentError, "The from_backend can't be the same as the to_backend." end @dry_run = opts[:dry_run] log_file = opts[:log_file] || "cloudsync.log" log_file = ::File.(log_file) $LOGGER = Logger.new(log_file) end |
Instance Attribute Details
#dry_run ⇒ Object
Returns the value of attribute dry_run.
5 6 7 |
# File 'lib/cloudsync/sync_manager.rb', line 5 def dry_run @dry_run end |
#from_backend ⇒ Object
Returns the value of attribute from_backend.
5 6 7 |
# File 'lib/cloudsync/sync_manager.rb', line 5 def from_backend @from_backend end |
#to_backend ⇒ Object
Returns the value of attribute to_backend.
5 6 7 |
# File 'lib/cloudsync/sync_manager.rb', line 5 def to_backend @to_backend end |
Instance Method Details
#dry_run? ⇒ Boolean
37 38 39 |
# File 'lib/cloudsync/sync_manager.rb', line 37 def dry_run? @dry_run end |
#mirror! ⇒ Object
30 31 32 33 34 35 |
# File 'lib/cloudsync/sync_manager.rb', line 30 def mirror! $LOGGER.info("[SM]: Mirror from #{from_backend} to #{to_backend} started at #{mirror_start = Time.now}. Dry-run? #{!!dry_run?}") sync! prune! $LOGGER.info("[SM]: Mirror from #{from_backend} to #{to_backend} finished at #{Time.now}. Took #{Time.now - mirror_start}s") end |
#prune! ⇒ Object
41 42 43 |
# File 'lib/cloudsync/sync_manager.rb', line 41 def prune! prune end |
#sync! ⇒ Object
22 23 24 |
# File 'lib/cloudsync/sync_manager.rb', line 22 def sync! sync(:sync) end |
#sync_all! ⇒ Object
26 27 28 |
# File 'lib/cloudsync/sync_manager.rb', line 26 def sync_all! sync(:sync_all) end |