Class: Mnogootex::Job::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/mnogootex/job/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cl:, chdir:) ⇒ Runner

Returns a new instance of Runner.



10
11
12
13
14
# File 'lib/mnogootex/job/runner.rb', line 10

def initialize(cl:, chdir:)
  @log_lines = []
  _, @stream, @thread = Open3.popen2e(*cl, chdir: chdir)
  @poller = start_poller
end

Instance Attribute Details

#hidObject (readonly)

Returns the value of attribute hid.



8
9
10
# File 'lib/mnogootex/job/runner.rb', line 8

def hid
  @hid
end

#log_linesObject (readonly)

Returns the value of attribute log_lines.



8
9
10
# File 'lib/mnogootex/job/runner.rb', line 8

def log_lines
  @log_lines
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mnogootex/job/runner.rb', line 16

def alive?
  @poller.alive?
end

#count_linesObject



24
25
26
27
# File 'lib/mnogootex/job/runner.rb', line 24

def count_lines
  return log_lines.size unless alive?
  @ticks = [@ticks || -1, log_lines.size - 1].min + 1
end

#successful?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/mnogootex/job/runner.rb', line 20

def successful?
  @poller.value.exitstatus.zero?
end