Sha256: 6453b646548959d4a59467491aca2d020656e37015bd30de974c53f73a3cebaf
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module SupplyDrop class Rsync class << self def command(from, to, options={}) flags = ['-az'] flags << '--delete' if options[:delete] flags << excludes(options[:excludes]) if options.has_key?(:excludes) flags << ssh_options(options[:ssh]) if options.has_key?(:ssh) "rsync #{flags.compact.join(' ')} #{from} #{to}" end def remote_address(user, host, path) user_with_host = [user, host].compact.join('@') [user_with_host, path].join(':') end def excludes(patterns) [patterns].flatten.map { |p| "--exclude=#{p}" } end def ssh_options(options) mapped_options = options.map do |key, value| next unless value case key when :keys then [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i #{k}" } when :config then "-F #{value}" end end.compact %[-e "ssh #{mapped_options.join(' ')}"] unless mapped_options.empty? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
supply_drop-0.5.0 | lib/supply_drop/rsync.rb |