Class: Backup::Syncer::Cloud::Base::SyncContext
- Inherits:
-
Object
- Object
- Backup::Syncer::Cloud::Base::SyncContext
- Defined in:
- lib/backup/syncer/cloud/base.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#remote_base ⇒ Object
readonly
Returns the value of attribute remote_base.
Instance Method Summary collapse
-
#initialize(directory, bucket, path) ⇒ SyncContext
constructor
Creates a new SyncContext object which handles a single directory from the Syncer::Base @directories array.
-
#sync!(mirror = false, concurrency_type = false, concurrency_level = 2) ⇒ Object
Performs the sync operation using the provided techniques (mirroring/concurrency).
Constructor Details
#initialize(directory, bucket, path) ⇒ SyncContext
Creates a new SyncContext object which handles a single directory from the Syncer::Base @directories array.
74 75 76 77 |
# File 'lib/backup/syncer/cloud/base.rb', line 74 def initialize(directory, bucket, path) @directory, @bucket, @path = directory, bucket, path @remote_base = File.join(path, File.basename(directory)) end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
69 70 71 |
# File 'lib/backup/syncer/cloud/base.rb', line 69 def bucket @bucket end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
69 70 71 |
# File 'lib/backup/syncer/cloud/base.rb', line 69 def directory @directory end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
69 70 71 |
# File 'lib/backup/syncer/cloud/base.rb', line 69 def path @path end |
#remote_base ⇒ Object (readonly)
Returns the value of attribute remote_base.
69 70 71 |
# File 'lib/backup/syncer/cloud/base.rb', line 69 def remote_base @remote_base end |
Instance Method Details
#sync!(mirror = false, concurrency_type = false, concurrency_level = 2) ⇒ Object
Performs the sync operation using the provided techniques (mirroring/concurrency).
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/backup/syncer/cloud/base.rb', line 82 def sync!(mirror = false, concurrency_type = false, concurrency_level = 2) block = Proc.new { |relative_path| sync_file relative_path, mirror } case concurrency_type when FalseClass all_file_names.each(&block) when :threads Parallel.each all_file_names, :in_threads => concurrency_level, &block when :processes Parallel.each all_file_names, :in_processes => concurrency_level, &block else raise Errors::Syncer::Cloud::ConfigurationError, "Unknown concurrency_type setting: #{ concurrency_type.inspect }" end end |