class RakeDeploy::Rsyncer
Attributes
name[R]
Public Class Methods
new(name, options)
click to toggle source
# File lib/rake_deploy.rb, line 41 def initialize(name, options) @name = name @options = options end
option_accessor(name)
click to toggle source
# File lib/rake_deploy.rb, line 50 def self.option_accessor(name) define_method name do indifferent_hash_access(name) || missing_option(name) end end
Public Instance Methods
exitstatus()
click to toggle source
# File lib/rake_deploy.rb, line 84 def exitstatus @wait_thr.value.exitstatus == 0 ? 'succeeded' : 'failed' end
indifferent_hash_access(name)
click to toggle source
# File lib/rake_deploy.rb, line 46 def indifferent_hash_access(name) @options[name.to_s] || @options[name] end
missing_option(name)
click to toggle source
# File lib/rake_deploy.rb, line 60 def missing_option(name) raise Error.new("Missing option #{name}") end
rsync()
click to toggle source
# File lib/rake_deploy.rb, line 68 def rsync _stdin, @stdout, @stderr, @wait_thr = Open3.popen3(rsync_command) write_output end
rsync_command()
click to toggle source
# File lib/rake_deploy.rb, line 88 def rsync_command "rsync -r #{rsync_options} #{source} #{user}@#{domain}:#{target_dir}" end
rsync_options()
click to toggle source
# File lib/rake_deploy.rb, line 64 def rsync_options indifferent_hash_access(:rsync_options).to_a.join(' ') end
write_if_exists(io)
click to toggle source
# File lib/rake_deploy.rb, line 79 def write_if_exists(io) op = io.read puts op unless op.empty? end
write_output()
click to toggle source
# File lib/rake_deploy.rb, line 73 def write_output write_if_exists(@stdout) write_if_exists(@stderr) puts "Deploying #{name} #{exitstatus}." end