Module: RubySSH

Defined in:
lib/ruby-ssh.rb,
lib/ruby-ssh/result.rb,
lib/ruby-ssh/version.rb,
lib/ruby-ssh/shell_runner.rb

Defined Under Namespace

Classes: Result, ShellRunner

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.run(host, user, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-ssh.rb', line 15

def run(host, user, options = {})
  script = options.delete(:script)

  result = nil  # TODO 明示的に初期化したくない
  Net::SSH.start(host, user, options) do |ssh|
    ssh.shell_runner do |runner|
      result = runner.exec(script)
    end
  end
  result
end

.start(host, user, options = {}, &block) ⇒ Object



9
10
11
12
13
# File 'lib/ruby-ssh.rb', line 9

def start(host, user, options = {}, &block)
  Net::SSH.start(host, user, options) do |ssh|
    yield ssh
  end
end