Class: EmbeddedJs::Adaptors::CommandRunner
- Inherits:
-
Object
- Object
- EmbeddedJs::Adaptors::CommandRunner
- Defined in:
- lib/embedded_js/adaptors/command_runner.rb
Instance Method Summary collapse
-
#initialize(io: Open3) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #run(cmd, environment_variables = {}) ⇒ Object
Constructor Details
#initialize(io: Open3) ⇒ CommandRunner
Returns a new instance of CommandRunner.
8 9 10 |
# File 'lib/embedded_js/adaptors/command_runner.rb', line 8 def initialize(io: Open3) @io = io end |
Instance Method Details
#run(cmd, environment_variables = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/embedded_js/adaptors/command_runner.rb', line 12 def run(cmd, environment_variables = {}) io.popen3( environment_variables, "#{cmd} 2>&1" ) do |stdin, stdout, _stderr, wait_thread| stdin.close_write while line = stdout.gets puts line end puts wait_thread.value end end |