Object
# File lib/cocaine/command_line.rb, line 26 def environment @supplemental_environment ||= {} end
# File lib/cocaine/command_line.rb, line 34 def fake! @runner = FakeRunner.new end
# File lib/cocaine/command_line.rb, line 55 def initialize(binary, params = "", options = {}) @binary = binary.dup @params = params.dup @options = options.dup @runner = @options.delete(:runner) || self.class.runner @logger = @options.delete(:logger) || self.class.logger @swallow_stderr = @options.delete(:swallow_stderr) @expected_outcodes = @options.delete(:expected_outcodes) || [0] @environment = @options.delete(:environment) || {} end
# File lib/cocaine/command_line.rb, line 7 def path @supplemental_path end
# File lib/cocaine/command_line.rb, line 11 def path=(supplemental_path) @supplemental_path = supplemental_path @supplemental_environment ||= {} @supplemental_environment['PATH'] = (Array(supplemental_path) + [ENV['PATH']]).join(File::PATH_SEPARATOR) end
# File lib/cocaine/command_line.rb, line 66 def command(interpolations = {}) cmd = [] cmd << @binary cmd << interpolate(@params, interpolations) cmd << bit_bucket if @swallow_stderr cmd.join(" ").strip end
# File lib/cocaine/command_line.rb, line 74 def run(interpolations = {}) output = '' begin full_command = command(interpolations) log("#{colored("Command")} :: #{full_command}") output = execute(full_command) rescue Errno::ENOENT raise Cocaine::CommandNotFoundError ensure @exit_status = $?.exitstatus end if $?.exitstatus == 127 raise Cocaine::CommandNotFoundError end unless @expected_outcodes.include?($?.exitstatus) message = [ "Command '#{full_command}' returned #{$?.exitstatus}. Expected #{@expected_outcodes.join(", ")}", "Here is the command output:\n", output ].join("\n") raise Cocaine::ExitStatusError, message end output end
Generated with the Darkfish Rdoc Generator 2.