Class: DeepTest::Distributed::RSync::Args

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/distributed/rsync.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection_info, options) ⇒ Args

Returns a new instance of Args.



13
14
15
16
17
18
# File 'lib/deep_test/distributed/rsync.rb', line 13

def initialize(connection_info, options)
  @connection_info = connection_info
  @options = options
  @sync_options = options.sync_options
  raise "Pushing code to a daemon isn't supported at the moment" if @sync_options[:daemon] && @sync_options[:push_code]
end

Instance Method Details

#command(destination) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/deep_test/distributed/rsync.rb', line 20

def command(destination)
  # The '/' after source tells rsync to copy the contents
  # of source to destination, rather than the source directory
  # itself
  cmd = "rsync -az --delete #{@sync_options[:rsync_options]} #{source_location}/ #{destination_location(destination)} 2>&1".strip.squeeze(" ")
  @sync_options[:distribution_server_tunnel] ? tunnelize(cmd) : cmd
end

#common_location_optionsObject



44
45
46
47
48
49
# File 'lib/deep_test/distributed/rsync.rb', line 44

def common_location_options
  loc = ""
  loc << @sync_options[:username] << '@' if @sync_options[:username]
  loc << @connection_info.address
  loc << (@sync_options[:daemon] ? '::' : ':')
end

#destination_location(destination) ⇒ Object



38
39
40
41
42
# File 'lib/deep_test/distributed/rsync.rb', line 38

def destination_location(destination)
  loc = ""
  loc << common_location_options unless @sync_options[:local] || !@sync_options[:push_code]
  loc << destination
end

#source_locationObject



32
33
34
35
36
# File 'lib/deep_test/distributed/rsync.rb', line 32

def source_location
  loc = ""
  loc << common_location_options unless @sync_options[:local] || @sync_options[:push_code]
  loc << (@sync_options[:distribution_server_source] || @sync_options[:source])
end

#tunnelize(rsync_command) ⇒ Object



28
29
30
# File 'lib/deep_test/distributed/rsync.rb', line 28

def tunnelize(rsync_command)
  "ssh #{@sync_options[:ssh_tunnel_options]} #{@sync_options[:username]}@#{@sync_options[:code_distribution_server]} 'cd #{source_location} && #{rsync_command}'"
end