Class: SSHKit::Interactive::Backend
- Inherits:
-
Backend::Printer
- Object
- Backend::Printer
- SSHKit::Interactive::Backend
- Defined in:
- lib/sshkit/interactive/backend.rb
Instance Method Summary collapse
- #_unsupported_operation(*args) ⇒ Object (also: #upload!, #download!, #test, #capture)
- #as(who, &_block) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize(host, options = {}, &block) ⇒ Backend
constructor
A new instance of Backend.
- #run ⇒ Object
- #within(directory, &_block) ⇒ Object
Constructor Details
#initialize(host, options = {}, &block) ⇒ Backend
Returns a new instance of Backend.
4 5 6 7 8 |
# File 'lib/sshkit/interactive/backend.rb', line 4 def initialize(host, = {}, &block) super(host, &block) @options = end |
Instance Method Details
#_unsupported_operation(*args) ⇒ Object Also known as: upload!, download!, test, capture
50 51 52 |
# File 'lib/sshkit/interactive/backend.rb', line 50 def _unsupported_operation(*args) raise SSHKit::Backend::MethodUnavailableError, 'SSHKit::Interactive does not support this operation.' end |
#as(who, &_block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |
#execute(*args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sshkit/interactive/backend.rb', line 39 def execute(*args) super = args. cmd = Command.new(host, command(args, ), @options) debug(cmd.to_s) cmd.execute end |
#run ⇒ Object
10 11 12 |
# File 'lib/sshkit/interactive/backend.rb', line 10 def run instance_exec(host, &@block) end |
#within(directory, &_block) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sshkit/interactive/backend.rb', line 14 def within(directory, &_block) (@pwd ||= []).push(directory.to_s) yield ensure @pwd.pop end |