Sha256: d19ea8a7869950b3bd54337559b676cfdce96121ebaa7350bcaa239c6ad618af
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require "buildem/base" require "buildem/condition_matcher" class BuildEm::Executor attr_accessor :argz def initialize(args, kernel=Kernel, matcher=BuildEm::ConditionMatcher.new) @kernel = kernel @argz ||= args @matcher = matcher end def name BuildEm::Executor end def run optz = argz[1] quit_on_error = (optz[:quit_on_error].nil? ? true : optz[:quit_on_error]) retry_amount = (optz[:retry_amount].nil? ? 1 : optz[:retry_amount]) condition = (optz[:retry_condition].nil? ? 0 : optz[:retry_condition]) executions = 0 begin puts "retrying command [#{argz[0]}]" if executions > 0 executions += 1 @comamnd_output = @kernel.run_command("#{argz[0]}") @command_exitstatus = @kernel.exitstatus match = @matcher.match(@command_exitstatus, @comamnd_output, condition) puts @comamnd_output if match return @command_exitstatus if match rescue Exception => e if quit_on_error raise e end end while executions < retry_amount fail "Failed to execute [#{argz[0]}]. Tried #{retry_amount} time(s), expected match was [#{condition}] got [#{@command_exitstatus}]." if quit_on_error @command_exitstatus end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
buildem-1.0.0 | lib/buildem/executor.rb |