class Reviewer::Runner
Wrapper for executng a command and printing the results
Attributes
command[R]
output[R]
shell[R]
strategy[RW]
Public Class Methods
new(tool, command_type, strategy = Strategies::Quiet, output: Reviewer.output)
click to toggle source
# File lib/reviewer/runner.rb, line 19 def initialize(tool, command_type, strategy = Strategies::Quiet, output: Reviewer.output) @command = Command.new(tool, command_type) @strategy = strategy @shell = Shell.new @output = output end
Public Instance Methods
guidance()
click to toggle source
# File lib/reviewer/runner.rb, line 69 def guidance @guidance ||= Reviewer::Guidance.new(command: command, result: result, output: output) end
prepare_command()
click to toggle source
# File lib/reviewer/runner.rb, line 60 def prepare_command @prepare_command ||= Command.new(tool, :prepare, command.verbosity) end
run()
click to toggle source
# File lib/reviewer/runner.rb, line 26 def run # Show which tool is about to run output.tool_summary(tool) # Run the provided strategy strategy.new(self).tap do |run_strategy| run_strategy.prepare if run_prepare_step? run_strategy.run end # If it failed, guidance.show unless success? exit_status end
run_prepare_step?()
click to toggle source
# File lib/reviewer/runner.rb, line 56 def run_prepare_step? command.type != :prepare && tool.prepare? end
success?()
click to toggle source
# File lib/reviewer/runner.rb, line 42 def success? # Some review tools return a range of non-zero exit statuses and almost never return 0. # (`yarn audit` is a good example.) Those tools can be configured to accept a non-zero exit # status so they aren't constantly considered to be failing over minor issues. # # But when other command types (prepare, install, format) are run, they either succeed or they # fail. With no shades of gray in those cases, anything other than a 0 is a failure. if command.type == :review exit_status <= tool.max_exit_status else exit_status.zero? end end
update_last_prepared_at()
click to toggle source
# File lib/reviewer/runner.rb, line 64 def update_last_prepared_at # Touch the `last_prepared_at` timestamp for the tool so it waits before running again. tool.last_prepared_at = Time.now end