Class: SSHKit::Backend::SshCommand

Inherits:
Printer
  • Object
show all
Defined in:
lib/sshkit/backends/ssh_command.rb

Instance Method Summary collapse

Instance Method Details

#execute(*args, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/sshkit/backends/ssh_command.rb', line 18

def execute(*args, &block)
  host_url = String(host.hostname)
  host_url = '%s@%s' % [host.username, host_url] if host.username
  result = 'ssh %s -t "%s"' % [host_url, command(*args).to_command]
  output << Command.new(result, host: host)
  system(result)
end

#runObject



7
8
9
# File 'lib/sshkit/backends/ssh_command.rb', line 7

def run
  instance_exec(host, &@block)
end

#within(directory, &block) ⇒ Object



11
12
13
14
15
16
# File 'lib/sshkit/backends/ssh_command.rb', line 11

def within(directory, &block)
  (@pwd ||= []).push directory.to_s
  yield
ensure
  @pwd.pop
end