class Coque::Result

Attributes

exit_code[R]
pid[R]

Public Class Methods

new(pid, out) click to toggle source
# File lib/coque/result.rb, line 5
def initialize(pid, out)
  @pid = pid
  @out = out
end

Public Instance Methods

each(&block) click to toggle source
# File lib/coque/result.rb, line 10
def each(&block)
  begin
    @out.each_line do |line|
      block.call(line.chomp)
    end
  rescue IOError
    # If the command was redirected to an existing standard output stream,
    # i.e. $stdout or $stderr, that output will be streamed as executed, so
    # attempting to read from it here will fail.
    # There may be a better way to handle this case, but for now this is working ok.
  end
  unless defined? @exit_code
    wait
  end
end
success?() click to toggle source
# File lib/coque/result.rb, line 32
def success?
  count
  exit_code == 0
end
wait() click to toggle source
# File lib/coque/result.rb, line 26
def wait
  _pid, status = Process.waitpid2(pid)
  @exit_code = status.exitstatus
  self
end