Class: DebDeploy::Rsync
- Inherits:
-
Object
- Object
- DebDeploy::Rsync
- Defined in:
- lib/deb_deploy/rsync.rb
Class Method Summary collapse
- .command(from, to, options = {}) ⇒ Object
- .excludes(patterns) ⇒ Object
- .includes(patterns) ⇒ Object
- .remote_address(user, host, path) ⇒ Object
- .ssh_options(options) ⇒ Object
Class Method Details
.command(from, to, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/deb_deploy/rsync.rb', line 4 def command(from, to, ={}) flags = ['-az'] flags << '--delete' flags << '--prune-empty-dirs' flags << '--delete-excluded' flags << includes([:filter]) flags << excludes(["*"]) flags << ([:ssh]) if .has_key?(:ssh) "rsync #{flags.compact.join(' ')} #{from} #{to}" end |
.excludes(patterns) ⇒ Object
21 22 23 |
# File 'lib/deb_deploy/rsync.rb', line 21 def excludes(patterns) patterns.map { |p| "--exclude=#{p}" } end |
.includes(patterns) ⇒ Object
26 27 28 |
# File 'lib/deb_deploy/rsync.rb', line 26 def includes(patterns) patterns.map { |p| "--include=#{p}" } end |
.remote_address(user, host, path) ⇒ Object
16 17 18 19 |
# File 'lib/deb_deploy/rsync.rb', line 16 def remote_address(user, host, path) user_with_host = [user, host].compact.join('@') [user_with_host, path].join(':') end |
.ssh_options(options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/deb_deploy/rsync.rb', line 30 def () = .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}" when :port then "-p #{value}" end end.compact %[-e "ssh #{mapped_options.join(' ')}"] unless .empty? end |