class Fulmar::Infrastructure::Model::Transfer::Rsync
Implements the rsync transfer
Constants
- DEFAULT_CONFIG
Public Class Methods
new(config)
click to toggle source
@param [Fulmar::Domain::Service::ConfigurationService] config
Calls superclass method
Fulmar::Infrastructure::Model::Transfer::Base::new
# 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
Public Instance Methods
release_path()
click to toggle source
Gets the absolute release path @return [String] the release directory
# File lib/fulmar/infrastructure/model/transfer/rsync.rb, line 54 def release_path @config[:remote_path] end
rsync_command()
click to toggle source
Build the rsync command from the given options
# 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()
click to toggle source
# File lib/fulmar/infrastructure/model/transfer/rsync.rb, line 35 def transfer prepare unless @prepared @local_shell.run rsync_command end
Protected Instance Methods
absolute_path(path)
click to toggle source
Get the absolute path of the given path @param [String] path @return [String] absolute path
# File lib/fulmar/infrastructure/model/transfer/rsync.rb, line 63 def absolute_path(path) path = Pathname.new(path) return Pathname.new(@config.base_path) + path unless path.absolute? path end
rsync_command_options()
click to toggle source
Assembles all rsync command line parameters from the configuration options
# File lib/fulmar/infrastructure/model/transfer/rsync.rb, line 76 def rsync_command_options options = ['-rl'] options << rsync_excludes if rsync_excludes options << "--exclude-from='#{@config[:rsync][:exclude_file]}'" if @config[:rsync][:exclude_file] options << "--owner --group --chown='#{@config[:rsync][:chown]}'" if @config[:rsync][:chown] options << "--chmod='#{@config[:rsync][:chmod]}'" if @config[:rsync][:chmod] options << '--delete' if @config[:rsync][:delete] options end
rsync_excludes()
click to toggle source
# File lib/fulmar/infrastructure/model/transfer/rsync.rb, line 69 def rsync_excludes return nil unless @config[:rsync][:exclude] excludes = [*@config[:rsync][:exclude]] excludes.map { |exclude| "--exclude='#{exclude}'" }.join(' ') end