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(address, sync_options) ⇒ Args

Returns a new instance of Args.



18
19
20
21
# File 'lib/deep_test/distributed/rsync.rb', line 18

def initialize(address, sync_options)
  @address = address
  @sync_options = sync_options
end

Instance Method Details

#command(source, destination) ⇒ Object



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

def command(source, 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]} #{DeepTest::LIB_ROOT} #{source} #{destination}".strip.squeeze(" ")
end

#pull_command(destination) ⇒ Object



23
24
25
# File 'lib/deep_test/distributed/rsync.rb', line 23

def pull_command(destination)
  command remote_location(@sync_options[:source]), destination
end

#push_command(destination) ⇒ Object



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

def push_command(destination)
  command @sync_options[:source], remote_location(destination)
end

#remote_location(path) ⇒ Object



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

def remote_location(path)
  source = ""
  unless @sync_options[:local]
    source << @sync_options[:username] << '@' if @sync_options[:username]
    source << @address
    source << (@sync_options[:daemon] ? '::' : ':')
  end
  source << path
end