Class: Sh
- Inherits:
-
Object
- Object
- Sh
- Defined in:
- lib/command/sh/sh.rb
Overview
Run bash commands locally on machine.
Instance Method Summary collapse
-
#initialize ⇒ Sh
constructor
A new instance of Sh.
-
#run(command) ⇒ Object
Run a bash command locally.
Constructor Details
#initialize ⇒ Sh
Returns a new instance of Sh.
5 |
# File 'lib/command/sh/sh.rb', line 5 def initialize; end |
Instance Method Details
#run(command) ⇒ Object
Run a bash command locally.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/command/sh/sh.rb', line 8 def run(command) output = '' exit_status = nil Open3.popen3(command) do |stdin, stdout, stderr, wait_thr| stdin.close stdout.each_line do |line| puts line output += line end stderr.each_line do |line| puts line output += line end exit_status = wait_thr.value return { output: output, result: exit_status.success? } end end |