Sha256: 4e35227fc2feb6e7bef23378bb41c1eaebc8cf6551ea871ba37a3288d477f4c6

Contents?: true

Size: 731 Bytes

Versions: 10

Compression:

Stored size: 731 Bytes

Contents

require "childprocess"

module Acouchi
  class ProcessLauncher
    DEFAULT_START_OPTIONS = {:inherit_io => true}

    def initialize(*arguments)
      @arguments = arguments
      @process = ChildProcess.build(*@arguments)
      self
    end

    def with_inherited_io
      @process.io.inherit!
      self
    end

    def start
      @process.start
      self
    end

    def wait
      @process.wait
      self
    end

    def start_in_background
      @process.start
      self
    end

    def start_and_crash_if_process_fails
      start.wait
      if @process.crashed?
        raise "A process exited with a non-zero exit code.\nThe command executed was \"#{@arguments.join(" ")}\""
      end
      self
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
acouchi-0.0.14 lib/acouchi/process_launcher.rb
acouchi-0.0.13 lib/acouchi/process_launcher.rb
acouchi-0.0.12 lib/acouchi/process_launcher.rb
acouchi-0.0.11 lib/acouchi/process_launcher.rb
acouchi-0.0.10 lib/acouchi/process_launcher.rb
acouchi-0.0.9 lib/acouchi/process_launcher.rb
acouchi-0.0.8 lib/acouchi/process_launcher.rb
acouchi-0.0.7 lib/acouchi/process_launcher.rb
acouchi-0.0.6 lib/acouchi/process_launcher.rb
acouchi-0.0.5 lib/acouchi/process_launcher.rb