Sha256: 0d7b1a7952ce5d1d82fd54d5dba5228e0f58a83ee7bef88f277b8ef81b8fc4f4
Contents?: true
Size: 729 Bytes
Versions: 3
Compression:
Stored size: 729 Bytes
Contents
$:.unshift File.dirname(__FILE__) require 'command_error' module BuildMaster class CommandRunner attr_reader :outputs def initialize(command) @command = command end def execute id = rand(10000) puts "[#{id}]$> #{@command}" output = nil IO.popen(@command) do |io| if (block_given?) output = yield io else output = load_output(id, io) end end last_process = $? raise CommandError.new(last_process, output), @command unless last_process.exitstatus == 0 return output end private def load_output(id, io) output = '' while (line = io.gets) do puts "[#{id}] #{line}" output << line end return output end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-1.0.6 | lib/buildmaster/cotta/command_runner.rb |
BuildMaster-1.0.9 | lib/buildmaster/cotta/command_runner.rb |
BuildMaster-1.1.9 | lib/buildmaster/cotta/command_runner.rb |