Class: Mnogootex::Job::Runner
- Inherits:
-
Object
- Object
- Mnogootex::Job::Runner
- Defined in:
- lib/mnogootex/job/runner.rb
Constant Summary collapse
- POLLING_TIMEOUT =
0.02
Instance Attribute Summary collapse
-
#hid ⇒ Object
readonly
Returns the value of attribute hid.
-
#log_lines ⇒ Object
readonly
Returns the value of attribute log_lines.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #count_lines ⇒ Object
-
#initialize(cmd:, chdir:) ⇒ Runner
constructor
A new instance of Runner.
- #successful? ⇒ Boolean
Constructor Details
#initialize(cmd:, chdir:) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 |
# File 'lib/mnogootex/job/runner.rb', line 13 def initialize(cmd:, chdir:) @log_lines = [] _, @stream, @thread = Open3.popen2e(*cmd, chdir: chdir) @poller = start_poller end |
Instance Attribute Details
#hid ⇒ Object (readonly)
Returns the value of attribute hid.
11 12 13 |
# File 'lib/mnogootex/job/runner.rb', line 11 def hid @hid end |
#log_lines ⇒ Object (readonly)
Returns the value of attribute log_lines.
11 12 13 |
# File 'lib/mnogootex/job/runner.rb', line 11 def log_lines @log_lines end |
Instance Method Details
#alive? ⇒ Boolean
19 20 21 |
# File 'lib/mnogootex/job/runner.rb', line 19 def alive? @poller.alive? end |
#count_lines ⇒ Object
27 28 29 30 31 |
# File 'lib/mnogootex/job/runner.rb', line 27 def count_lines return log_lines.size unless alive? @ticks = [@ticks || -1, log_lines.size - 1].min + 1 end |
#successful? ⇒ Boolean
23 24 25 |
# File 'lib/mnogootex/job/runner.rb', line 23 def successful? @poller.value.exitstatus.zero? end |