class BitGirder::Io::UnixProcessBuilder
Public Class Methods
new( opts )
click to toggle source
Calls superclass method
# File lib/bitgirder/io.rb, line 921 def initialize( opts ) super( opts ) end
Public Instance Methods
exec()
click to toggle source
# File lib/bitgirder/io.rb, line 971 def exec debug_call( :call_type => "exec" ) Kernel.exec( *get_call_argv ) end
popen( mode, &blk )
click to toggle source
# File lib/bitgirder/io.rb, line 999 def popen( mode, &blk ) debug_call( :call_type => "popen" ) if RUBY_VERSION >= "1.9" IO.popen( get_call_argv, mode, &blk ) else IO.popen( get_call_argv18.join( " " ), mode, &blk ) end end
spawn()
click to toggle source
# File lib/bitgirder/io.rb, line 964 def spawn debug_call( :call_type => "spawn" ) Process.spawn( *get_call_argv ) end
system( opts = {} )
click to toggle source
# File lib/bitgirder/io.rb, line 978 def system( opts = {} ) debug_call( :call_type => "system" ) proc_res_raise = lambda { raise "Command exited with status #{$?.exitstatus}" } if RUBY_VERSION >= "1.9" proc_res_raise.call unless Kernel.system( *get_call_argv ) else if pid = Kernel.fork Process.wait( pid ) proc_res_raise.call unless $?.success? else Kernel.exec( *get_call_argv18 ) end end end
Private Instance Methods
debug_call( opts )
click to toggle source
# File lib/bitgirder/io.rb, line 926 def debug_call( opts ) dbg = { :cmd => @cmd, :argv => @argv, :opts => @opts } dbg[ :env ] = @env if @show_env_in_debug code( "Doing #{opts[ :call_type ]} in #{Dir.pwd} with #{dbg.inspect}" ) end
get_call_argv()
click to toggle source
# File lib/bitgirder/io.rb, line 952 def get_call_argv [ str_map( @env ), str_map( @cmd ), str_map( @argv ), @opts ].flatten end
get_call_argv18()
click to toggle source
# File lib/bitgirder/io.rb, line 957 def get_call_argv18 res = get_call_argv [ res[ 1 ], *( res[ 2 ] ) ] # [ cmd, *argv ] end
str_map( val )
click to toggle source
# File lib/bitgirder/io.rb, line 935 def str_map( val ) case val when Array then val.map { |o| str_map( o ) } when Hash val.inject( {} ) do |h, pair| h[ str_map( pair[ 0 ] ) ] = str_map( pair[ 1 ] ) h end else val.to_s end end