Class: SSHKit::Interactive::Backend

Inherits:
Backend::Printer
  • Object
show all
Defined in:
lib/sshkit/interactive/backend.rb

Instance Method Summary collapse

Instance Method Details

#_unsupported_operation(*args) ⇒ Object Also known as: upload!, download!, test, capture

Raises:

  • (SSHKit::Backend::MethodUnavailableError)


44
45
46
# File 'lib/sshkit/interactive/backend.rb', line 44

def _unsupported_operation(*args)
  raise SSHKit::Backend::MethodUnavailableError, 'SSHKit::Interactive does not support this operation.'
end

#as(who, &_block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sshkit/interactive/backend.rb', line 16

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

#execute(*args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/sshkit/interactive/backend.rb', line 33

def execute(*args)
  super

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

  debug(cmd.to_s)

  cmd.execute
end

#runObject



4
5
6
# File 'lib/sshkit/interactive/backend.rb', line 4

def run
  instance_exec(host, &@block)
end

#within(directory, &_block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/sshkit/interactive/backend.rb', line 8

def within(directory, &_block)
  (@pwd ||= []).push(directory.to_s)

  yield
ensure
  @pwd.pop
end