class Jive::BatchRunner
Attributes
runner[R]
stdout[R]
Public Class Methods
new(runner: Runner.new, stdout: $stdout)
click to toggle source
# File lib/jive/batch_runner.rb, line 7 def initialize(runner: Runner.new, stdout: $stdout) @runner = runner @stdout = stdout end
Public Instance Methods
run(tasks)
click to toggle source
# File lib/jive/batch_runner.rb, line 12 def run(tasks) stream_output_for(runner, tasks) stdout.puts "===================================================" print_result_for(runner) end
Private Instance Methods
emit_errors_for(runner)
click to toggle source
# File lib/jive/batch_runner.rb, line 59 def emit_errors_for(runner) runner.failed_results.each do |result| stdout.puts stdout.puts "**** #{result.command.join(" ")} failed with the following error(s):" stdout.puts stdout.puts result.stdout stdout.puts result.stderr stdout.puts end end
emit_warnings_for(runner)
click to toggle source
# File lib/jive/batch_runner.rb, line 49 def emit_warnings_for(runner) runner.warned_results.each do |result| stdout.puts stdout.puts "**** #{result.command.join(" ")} had the following warning(s):" stdout.puts stdout.puts result.stderr stdout.puts end end
print_result_for(runner)
click to toggle source
# File lib/jive/batch_runner.rb, line 32 def print_result_for(runner) if runner.all_success_and_clean? stdout.puts "Passed successfully." 0 elsif runner.all_success? stdout.puts "Passed successfully, but we have warnings:" stdout.puts emit_warnings_for(runner) 2 else stdout.puts "Something failed:" emit_warnings_for(runner) emit_errors_for(runner) 1 end end
stream_output_for(runner, tasks)
click to toggle source
# File lib/jive/batch_runner.rb, line 20 def stream_output_for(runner, tasks) runner.run(tasks) do |command, &run| stdout.puts stdout.puts "$ #{command.join(" ")}" result = run.call stdout.print result.stdout stdout.print result.stderr stdout.puts "==> Finished in #{result.duration} seconds" stdout.puts end end