Class: Fulmar::Infrastructure::Model::Transfer::Rsync
- Defined in:
- lib/fulmar/infrastructure/model/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.
-
#release_path ⇒ String
Gets the absolute release path.
-
#rsync_command ⇒ Object
Build the rsync command from the given options.
- #transfer ⇒ Object
Methods inherited from Base
config_hash, #prepare, #publish, #test_config
Constructor Details
#initialize(config) ⇒ Rsync
Returns a new instance of Rsync.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fulmar/infrastructure/model/transfer/rsync.rb', line 22 def initialize(config) @config = config @config.merge(DEFAULT_CONFIG) if @config[:rsync][:exclude_file].blank? && File.exist?(@config[:local_path] + '/.rsyncignore') @config[:rsync][:exclude_file] = @config[:local_path] + '/.rsyncignore' end raise 'Hostname not set. Cannot initialize sync.' if @config[:hostname].nil? || @config[:hostname].empty? super(@config) end |
Instance Method Details
#release_path ⇒ String
Gets the absolute release path
54 55 56 |
# File 'lib/fulmar/infrastructure/model/transfer/rsync.rb', line 54 def release_path @config[:remote_path] end |
#rsync_command ⇒ Object
Build the rsync command from the given options
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fulmar/infrastructure/model/transfer/rsync.rb', line 41 def rsync_command if @config[:rsync][:direction] == 'up' from = absolute_path(@config[:local_path]) to = @config.ssh_user_and_host + ':' + @config[:remote_path] else from = @config.ssh_user_and_host + ':' + @config[:remote_path] to = absolute_path(@config[:local_path]) end "rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'" end |
#transfer ⇒ Object
35 36 37 38 |
# File 'lib/fulmar/infrastructure/model/transfer/rsync.rb', line 35 def transfer prepare unless @prepared @local_shell.run rsync_command end |