Class: LogicalConstruct::RemoteCopyFile

Inherits:
Mattock::Rake::CommandTask
  • Object
show all
Defined in:
lib/logical-construct/ground-control/setup/copy-files.rb

Instance Method Summary collapse

Instance Method Details

#default_configuration(copy) ⇒ Object



12
13
14
15
# File 'lib/logical-construct/ground-control/setup/copy-files.rb', line 12

def default_configuration(copy)
  super
  self.remote_server = copy.proxy_value.remote_server
end

#resolve_configurationObject



17
18
19
20
21
# File 'lib/logical-construct/ground-control/setup/copy-files.rb', line 17

def resolve_configuration
  super
  self.source_path ||= File::join(source_dir, basename)
  self.destination_path ||= File::join(destination_dir, basename)
end

#resolve_runtime_configurationObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/logical-construct/ground-control/setup/copy-files.rb', line 30

def resolve_runtime_configuration
  self.destination_address ||= [remote_server.address, destination_path].join(":")

  self.command = cmd("rsync") do |rsync|
    rsync.options << "-a"
    rsync.options << "--copy-unsafe-links"
    rsync.options << "-e #{secure_shell_command}"
    exclude.each do |pattern|
      rsync.options << "--exclude #{pattern}"
    end
    rsync.options << source_path
    rsync.options << destination_address
  end
  super
end

#secure_shell_commandObject



23
24
25
26
27
28
# File 'lib/logical-construct/ground-control/setup/copy-files.rb', line 23

def secure_shell_command
  escaped_command("ssh") do |ssh|
    ssh.options += RunOnTarget::SSH_OPTIONS.map{|opt| "-o #{opt}"}
    ssh.options << "-l #{remote_server.user}" unless remote_server.user.nil?
  end
end