Class: Mnogootex::Job::Runner

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

Constant Summary collapse

POLLING_TIMEOUT =
0.02

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hidObject (readonly)

Returns the value of attribute hid.



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

def hid
  @hid
end

#log_linesObject (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

Returns:

  • (Boolean)


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

def alive?
  @poller.alive?
end

#count_linesObject



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

Returns:

  • (Boolean)


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

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