Class: Wordmove::RemoteHost
Instance Attribute Summary collapse
Attributes inherited from LocalHost
#logger, #options, #ssh_extras
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ RemoteHost
Returns a new instance of RemoteHost.
11
12
13
|
# File 'lib/wordmove/hosts/remote_host.rb', line 11
def initialize(options = {})
super
end
|
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
9
10
11
|
# File 'lib/wordmove/hosts/remote_host.rb', line 9
def session
@session
end
|
Instance Method Details
#close ⇒ Object
20
21
22
|
# File 'lib/wordmove/hosts/remote_host.rb', line 20
def close
session.close
end
|
#download_dir(source_dir, destination_dir) ⇒ Object
39
40
41
|
# File 'lib/wordmove/hosts/remote_host.rb', line 39
def download_dir(source_dir, destination_dir)
rsync "#{source_dir}/", "#{options.ssh.username}@#{options.ssh.host}:#{destination_dir}"
end
|
#download_file(source_file, destination_file) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/wordmove/hosts/remote_host.rb', line 31
def download_file(source_file, destination_file)
logger.verbose "Copying local #{source_file} to #{destination_file}..."
puts "SSH options: #{@ssh_extras.inspect}"
Net::SSH.start options.ssh.host, options.ssh.username, @ssh_extras do |ssh|
ssh.scp.upload! source_file, destination_file
end
end
|
#locally_run ⇒ Object
7
|
# File 'lib/wordmove/hosts/remote_host.rb', line 7
alias :locally_run :run
|
#run(*args) ⇒ Object
47
48
49
50
51
|
# File 'lib/wordmove/hosts/remote_host.rb', line 47
def run(*args)
command = shell_command(*args)
logger.verbose "Executing remotely #{command}"
session.exec!(command)
end
|
#upload_dir(source_dir, destination_dir) ⇒ Object
43
44
45
|
# File 'lib/wordmove/hosts/remote_host.rb', line 43
def upload_dir(source_dir, destination_dir)
rsync "#{options.ssh.username}@#{options.ssh.host}:#{source_dir}/", destination_dir
end
|
#upload_file(source_file, destination_file) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/wordmove/hosts/remote_host.rb', line 24
def upload_file(source_file, destination_file)
logger.verbose "Copying remote #{source_file} to #{destination_file}..."
Net::SSH.start options.ssh.host, options.ssh.username, @ssh_extras do |ssh|
ssh.scp.download! source_file, destination_file
end
end
|