Sha256: 7dd7fd3c580900c561dc28cf034992e16fd86d021c8cf2dc612db26dd4de1f61

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

module Acouchi
  class ProcessLauncher
    def initialize(*arguments)
      @arguments = arguments
      @process = ChildProcess.build(*@arguments)
      @process.io.inherit!
    end

    def start
      write_out_arguments
      @process.start
      @process.wait
    end

    def start_in_background
      write_out_arguments
      @process.start
    end

    def stop
      @process.stop
    end

    def start_and_crash_if_process_fails
      start

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

    private
      def write_out_arguments
        p @arguments
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acouchi-0.0.4 lib/acouchi/process_launcher.rb
acouchi-0.0.3 lib/acouchi/process_launcher.rb