Class: Tracetool::Pipe::Executor
- Inherits:
-
Object
- Object
- Tracetool::Pipe::Executor
- Defined in:
- lib/tracetool/utils/pipe.rb
Overview
Executes shell command
Instance Method Summary collapse
- #<<(args) ⇒ Object
- #cmd ⇒ Object
-
#initialize(cmd, *args) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(cmd, *args) ⇒ Executor
Returns a new instance of Executor.
8 9 10 11 |
# File 'lib/tracetool/utils/pipe.rb', line 8 def initialize(cmd, *args) @cmd = cmd @args = args end |
Instance Method Details
#<<(args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/tracetool/utils/pipe.rb', line 17 def <<(args) out, err, status = Open3.capture3({}, *cmd, stdin_data: args) raise "#{cmd.join(' ')} (exit: #{status.exitstatus}) #{err.chomp}" unless status.success? out.chomp end |
#cmd ⇒ Object
13 14 15 |
# File 'lib/tracetool/utils/pipe.rb', line 13 def cmd [@cmd, @args].flatten end |