Class: Del::ShellCommand
- Inherits:
-
Object
- Object
- Del::ShellCommand
- Defined in:
- lib/del/shell_command.rb
Overview
Executes shell commands and pipes the results back to the caller.
Instance Method Summary collapse
-
#initialize(command) ⇒ ShellCommand
constructor
A new instance of ShellCommand.
- #run ⇒ Object
Constructor Details
#initialize(command) ⇒ ShellCommand
Returns a new instance of ShellCommand.
7 8 9 |
# File 'lib/del/shell_command.rb', line 7 def initialize(command) @command = Array(command).flatten.join(' ') end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/del/shell_command.rb', line 11 def run Open3.popen3(@command) do |_stdin, stdout, stderr, wait_thr| stdout.each_line { |line| yield line } stderr.each_line { |line| yield line } wait_thr.value.success? end end |