class SSHKit::Interactive::Backend

Public Class Methods

new(host, options = {}, &block) click to toggle source
Calls superclass method
# File lib/sshkit/interactive/backend.rb, line 4
def initialize(host, options = {}, &block)
  super(host, &block)

  @options = options
end

Public Instance Methods

_unsupported_operation(*args) click to toggle source
# File lib/sshkit/interactive/backend.rb, line 50
def _unsupported_operation(*args)
  raise SSHKit::Backend::MethodUnavailableError, 'SSHKit::Interactive does not support this operation.'
end
Also aliased as: upload!, download!, test, capture
as(who) { || ... } click to toggle source
# File lib/sshkit/interactive/backend.rb, line 22
def as(who, &_block)
  if who.is_a?(Hash)
    @user  = who[:user]  || who['user']
    @group = who[:group] || who['group']
  else
    @user  = who
    @group = nil
  end

  raise SSHKit::Interactive::Unsupported, 'Setting group (through `as`) is currently not supported' unless @group.nil?

  yield
ensure
  remove_instance_variable(:@user)
  remove_instance_variable(:@group)
end
capture(*args)
download!(*args)
execute(*args) click to toggle source
Calls superclass method
# File lib/sshkit/interactive/backend.rb, line 39
def execute(*args)
  super

  options = args.extract_options!
  cmd     = Command.new(host, command(args, options), @options)

  debug(cmd.to_s)

  cmd.execute
end
run() click to toggle source
# File lib/sshkit/interactive/backend.rb, line 10
def run
  instance_exec(host, &@block)
end
test(*args)
upload!(*args)
within(directory) { || ... } click to toggle source
# File lib/sshkit/interactive/backend.rb, line 14
def within(directory, &_block)
  (@pwd ||= []).push(directory.to_s)

  yield
ensure
  @pwd.pop
end