Class: Rvm2::Shell::Runner::Ssh
- Inherits:
-
Object
- Object
- Rvm2::Shell::Runner::Ssh
- Defined in:
- lib/rvm2/shell/runner/ssh.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#last_status ⇒ Object
readonly
Returns the value of attribute last_status.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#execute(command) ⇒ Object
TODO: make it run in one session.
-
#initialize(host, user) ⇒ Ssh
constructor
A new instance of Ssh.
- #ssh ⇒ Object
Constructor Details
#initialize(host, user) ⇒ Ssh
Returns a new instance of Ssh.
6 7 8 9 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 6 def initialize(host, user) @host = host @user = user end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 4 def host @host end |
#last_status ⇒ Object (readonly)
Returns the value of attribute last_status.
4 5 6 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 4 def last_status @last_status end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 4 def user @user end |
Instance Method Details
#execute(command) ⇒ Object
TODO: make it run in one session
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 12 def execute(command) @last_status = nil ssh.open_channel do |channel| channel.request_pty channel.exec command do |ch, success| channel.on_data do |ch, data| yield(data, nil) end channel.on_extended_data do |ch, type, data| yield(nil, data) end channel.on_request("exit-status") do |ch, data| @last_status = data.read_long end end channel.wait end ssh.loop @last_status end |
#ssh ⇒ Object
33 34 35 |
# File 'lib/rvm2/shell/runner/ssh.rb', line 33 def ssh @ssh ||= Net::SSH.start(host, user) end |