Class: Hasta::ExecutionContext::Subprocess
- Inherits:
-
Object
- Object
- Hasta::ExecutionContext::Subprocess
- Defined in:
- lib/hasta/execution_context.rb
Overview
A Subprocess
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(ruby_files, env) ⇒ Subprocess
constructor
A new instance of Subprocess.
- #start(source_file) ⇒ Object
Constructor Details
#initialize(ruby_files, env) ⇒ Subprocess
Returns a new instance of Subprocess.
14 15 16 17 |
# File 'lib/hasta/execution_context.rb', line 14 def initialize(ruby_files, env) @ruby_files = ruby_files @env = env end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
12 13 14 |
# File 'lib/hasta/execution_context.rb', line 12 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
12 13 14 |
# File 'lib/hasta/execution_context.rb', line 12 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
12 13 14 |
# File 'lib/hasta/execution_context.rb', line 12 def stdout @stdout end |
Instance Method Details
#start(source_file) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hasta/execution_context.rb', line 19 def start(source_file) Open3.popen3(*cmd_line(source_file)) do |stdin, stdout, stderr, wait_thr| @stdin, @stdout, @stderr, @wait_thr = stdin, stdout, stderr, wait_thr yield self if (exit_code = wait_thr.value.exitstatus) != 0 raise ExecutionError, "#{source_file} exited with non-zero status: #{exit_code}" end end end |