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
# 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
  "rsync -az --delete #{@sync_options[:rsync_options]} #{source_location}/ #{destination_location(destination)} 2>&1".strip.squeeze(" ")
end

#common_location_optionsObject



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

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



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

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

#source_locationObject



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

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