Class: Fulmar::Infrastructure::Service::Transfer::Rsync
- Defined in:
- lib/fulmar/infrastructure/service/transfer/rsync.rb
Overview
Implements the rsync transfer
Constant Summary collapse
- DEFAULT_CONFIG =
{ rsync: { exclude: nil, exclude_file: nil, chown: nil, chmod: nil, delete: true, direction: 'up' } }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(config) ⇒ Rsync
constructor
A new instance of Rsync.
-
#rsync_command ⇒ Object
Build the rsync command from the given options.
- #transfer ⇒ Object
Methods inherited from Base
#prepare, #publish, #test_config
Constructor Details
#initialize(config) ⇒ Rsync
Returns a new instance of Rsync.
21 22 23 24 25 26 27 28 29 |
# File 'lib/fulmar/infrastructure/service/transfer/rsync.rb', line 21 def initialize(config) @config = DEFAULT_CONFIG.deep_merge(config) if @config[:rsync][:exclude_file].blank? && File.exist?(@config[:local_path] + '/.rsyncignore') @config[:rsync][:exclude_file] = @config[:local_path] + '/.rsyncignore' end super(@config) end |
Instance Method Details
#rsync_command ⇒ Object
Build the rsync command from the given options
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fulmar/infrastructure/service/transfer/rsync.rb', line 37 def rsync_command if @config[:rsync][:direction] == 'up' from = @config[:local_path] to = ssh_user_and_host + ':' + @config[:remote_path] else from = ssh_user_and_host + ':' + @config[:remote_path] to = @config[:local_path] end "rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'" end |
#transfer ⇒ Object
31 32 33 34 |
# File 'lib/fulmar/infrastructure/service/transfer/rsync.rb', line 31 def transfer prepare unless @prepared @local_shell.run rsync_command end |