Sha256: 4113ebe764ebe040d8ef5326e202e6e945a4c2756dbb5316b689b5e70bef4414

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

require 'background_process'

module Aruba
  class Process
    def initialize(cmd, timeout)
      @cmd = cmd
      @timeout = timeout
    end

    def run!(&block)
      @process = BackgroundProcess.run(@cmd)
      yield self if block_given?
    end

    def stdin
      @process.stdin
    end

    def output
      stdout + stderr
    end

    def stdout
      if @process
        @stdout ||= @process.stdout.read
      else
        ''
      end
    end

    def stderr
      if @process
        @stderr ||= @process.stderr.read
      else
        ''
      end
    end

    def stop
      if @process
        stdout && stderr # flush output
        status = @process.wait(@timeout)
        status && status.exitstatus
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aruba-0.2.7 lib/aruba/process.rb