class YardJunk::Janitor::TextReporter

Reporter that just outputs everything in plaintext format. Useful for commandline usage. See {BaseReporter} for details about reporters.

Private Instance Methods

_stats(**stat) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 13
def _stats(**stat)
  @io.puts "\n#{colorized_stats(**stat)}"
end
colorize(text, color) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 23
def colorize(text, color)
  Rainbow(text).color(color)
end
colorized_stats(errors:, problems:, duration:) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 17
def colorized_stats(errors:, problems:, duration:)
  colorize(
    format('%i failures, %i problems', errors, problems), status_color(errors, problems)
  ) + format(' (%s to run)', duration)
end
header(title, explanation) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 35
def header(title, explanation)
  @io.puts
  @io.puts title
  @io.puts '-' * title.length
  @io.puts "#{explanation}\n\n"
end
row(msg) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 42
def row(msg)
  @io.puts msg.to_s # default Message#to_s is good enough
end
status_color(errors, problems) click to toggle source
# File lib/yard-junk/janitor/text_reporter.rb, line 27
def status_color(errors, problems)
  case
  when errors.positive? then :red
  when problems.positive? then :yellow
  else :green
  end
end