class Object

Public Instance Methods

run(command, abort_on_failure = true) { |line| ... } click to toggle source
# File lib/asrake/util.rb, line 52
def run(command, abort_on_failure = true)
        command.strip!

        puts "> #{command}" if !block_given?
        IO.popen("#{command} 2>&1") do |proc|
                while !proc.closed? && (line = proc.gets)
                        if block_given?
                                yield line
                        else
                                puts ">    #{line}"
                        end
                end
        end

        if $?.exitstatus != 0
                msg = "Operation exited with status #{$?.exitstatus}"
                raise msg if abort_on_failure
                #puts msg
        end

        return $?
end