Sha256: 68fe5e68ecef5b7a04cdebc9e39229891522488e0e0031a442d4670ddd4716f3
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
require 'shellwords' require 'stringio' module Aruba class InProcess include Shellwords class FakeKernel attr_reader :exitstatus def initialize @exitstatus = 0 end def exit(exitstatus) @exitstatus = exitstatus end end def self.main_class=(main_class) @@main_class = main_class end def initialize(cmd, exit_timeout, io_wait) args = shellwords(cmd) @argv = args[1..-1] @stdin = StringIO.new @stdout = StringIO.new @stderr = StringIO.new @kernel = FakeKernel.new end def run!(&block) raise "You need to call Aruba::InProcess.main_class = YourMainClass" unless @@main_class @@main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute! yield self if block_given? end def stop(reader) @kernel.exitstatus end def stdout @stdout.string end def stderr @stderr.string end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aruba-0.5.3 | lib/aruba/in_process.rb |
aruba-0.5.2 | lib/aruba/in_process.rb |