lib/acouchi/process_launcher.rb in acouchi-0.0.4 vs lib/acouchi/process_launcher.rb in acouchi-0.0.5
- old
+ new
@@ -1,37 +1,41 @@
+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
- write_out_arguments
@process.start
+ self
+ end
+
+ def wait
@process.wait
+ self
end
def start_in_background
- write_out_arguments
@process.start
+ self
end
- def stop
- @process.stop
- end
-
def start_and_crash_if_process_fails
- start
-
+ start.wait
if @process.crashed?
raise "A process exited with a non-zero exit code.\nThe command executed was \"#{@arguments.join(" ")}\""
end
+ self
end
-
- private
- def write_out_arguments
- p @arguments
- end
end
end