class Reviewer::Output

Friendly API for printing nicely-formatted output to the console

Constants

DIVIDER
FAILURE
SUCCESS

Attributes

printer[R]

Public Class Methods

new(printer: Reviewer.configuration.printer) click to toggle source
# File lib/reviewer/output.rb, line 14
def initialize(printer: Reviewer.configuration.printer)
  @printer = printer
end

Public Instance Methods

blank_line() click to toggle source
# File lib/reviewer/output.rb, line 22
def blank_line
  printer.info
end
current_command(command) click to toggle source
# File lib/reviewer/output.rb, line 36
def current_command(command)
  command = String(command)

  printer.info "\nNow Running:"
  printer.info command.light_black
end
divider() click to toggle source
# File lib/reviewer/output.rb, line 26
def divider
  blank_line
  printer.info DIVIDER.light_black
  blank_line
end
exit_status(value) click to toggle source
# File lib/reviewer/output.rb, line 43
def exit_status(value)
  failure("Exit Status #{value}")
end
failure(details, command: nil) click to toggle source
# File lib/reviewer/output.rb, line 54
def failure(details, command: nil)
  printer.error "#{FAILURE} #{details}".red.bold

  return if command.nil?

  blank_line
  printer.error 'Failed Command:'.red.bold
  printer.error String(command).light_black
end
guidance(summary, details) click to toggle source
# File lib/reviewer/output.rb, line 69
def guidance(summary, details)
  return if details.nil?

  blank_line
  printer.info summary
  printer.info details.to_s.light_black
end
info(message) click to toggle source
# File lib/reviewer/output.rb, line 18
def info(message)
  printer.info message
end
missing_executable_guidance(command) click to toggle source
# File lib/reviewer/output.rb, line 77
def missing_executable_guidance(command)
  tool = command.tool
  installation_command = Command.new(tool, :install, :no_silence).string if tool.installable?
  install_link = tool.install_link

  failure("Missing executable for '#{tool}'", command: command)
  guidance('Try installing the tool:', installation_command)
  guidance('Read the installation guidance:', install_link)
end
success(timer) click to toggle source
# File lib/reviewer/output.rb, line 47
def success(timer)
  message = SUCCESS.green.bold + " #{timer.total_seconds}s".green
  message += " (#{timer.prep_percent}% preparation)".yellow if timer.prepped?

  printer.info message
end
syntax_guidance(ignore_link: nil, disable_link: nil) click to toggle source
# File lib/reviewer/output.rb, line 87
def syntax_guidance(ignore_link: nil, disable_link: nil)
  guidance('Selectively Ignore a Rule:', ignore_link)
  guidance('Fully Disable a Rule:', disable_link)
end
tool_summary(tool) click to toggle source
# File lib/reviewer/output.rb, line 32
def tool_summary(tool)
  printer.info "\n#{tool.name}".bold + ' ยท '.light_black + tool.description
end
unrecoverable(details) click to toggle source
# File lib/reviewer/output.rb, line 64
def unrecoverable(details)
  printer.error 'Unrecoverable Error:'.red.bold
  printer.error details
end