class Scripto::RunCommands::CommandLine
Attributes
args[RW]
command[RW]
Public Class Methods
new(command, args)
click to toggle source
# File lib/scripto/run_commands.rb, line 57 def initialize(command, args) self.command = command self.args = begin if args args.map(&:to_s) else [] end end end
Public Instance Methods
capture()
click to toggle source
# File lib/scripto/run_commands.rb, line 73 def capture begin captured = `#{self}` rescue Errno::ENOENT raise Error, "#{self} failed : ENOENT (No such file or directory)" end raise!($CHILD_STATUS) if $CHILD_STATUS != 0 captured end
raise!(status)
click to toggle source
# File lib/scripto/run_commands.rb, line 83 def raise!(status) if status.termsig == Signal.list['INT'] raise "#{self} interrupted" end raise Error, "#{self} failed : #{status.to_i / 256}" end
run()
click to toggle source
# File lib/scripto/run_commands.rb, line 68 def run system(command, *args) raise!($CHILD_STATUS) if $CHILD_STATUS != 0 end
to_s()
click to toggle source
# File lib/scripto/run_commands.rb, line 91 def to_s if !args.empty? escaped = args.map { |i| Shellwords.escape(i) } "#{command} #{escaped.join(' ')}" else command end end