Sha256: 02d26d67a451e097ecc535aa898666c740c6198fd8873cfe6d19f3346c86b11e
Contents?: true
Size: 825 Bytes
Versions: 1
Compression:
Stored size: 825 Bytes
Contents
# frozen_string_literal: true require 'open3' module Mnogootex module Job class Runner attr_reader :hid, :log_lines def initialize(cmd:, chdir:) @log_lines = [] _, @stream, @thread = Open3.popen2e(*cmd, chdir: chdir) @poller = start_poller end def alive? @poller.alive? end def successful? @poller.value.exitstatus.zero? end def count_lines return log_lines.size unless alive? @ticks = [@ticks || -1, log_lines.size - 1].min + 1 end private def start_poller Thread.new do until (line = @stream.gets).nil? log_lines << line end # NOTE: waits on @thread and returns its value @thread.value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mnogootex-1.1.0 | lib/mnogootex/job/runner.rb |