class Chutney::RainbowFormatter

pretty formatter

Public Class Methods

new() click to toggle source
Calls superclass method Chutney::Formatter::new
# File lib/chutney/formatter/rainbow_formatter.rb, line 8
def initialize
  super

  @pastel = Pastel.new
end

Public Instance Methods

format() click to toggle source
# File lib/chutney/formatter/rainbow_formatter.rb, line 14
def format
  files_with_issues.each do |file, linter|
    put_file(file)
    linter.filter { |l| !l[:issues].empty? }.each do |linter_with_issues|
      put_linter(linter_with_issues)
      linter_with_issues[:issues].each { |i| put_issue(file, i) }
    end
  end
  put_summary
end
put_file(file) click to toggle source
# File lib/chutney/formatter/rainbow_formatter.rb, line 25
def put_file(file)
  puts @pastel.cyan(file.to_s)
end
put_issue(file, issue) click to toggle source
# File lib/chutney/formatter/rainbow_formatter.rb, line 33
def put_issue(file, issue)
  puts "    #{issue[:message]}"
  puts "    #{@pastel.dim file.to_s}:#{@pastel.dim(issue.dig(:location, :line))}"
end
put_linter(linter) click to toggle source
# File lib/chutney/formatter/rainbow_formatter.rb, line 29
def put_linter(linter)
  puts @pastel.red("  #{linter[:linter]}")
end
put_summary() click to toggle source
# File lib/chutney/formatter/rainbow_formatter.rb, line 38
def put_summary
  print "#{files.count} features inspected, "
  if files_with_issues.count.zero?
    puts @pastel.green('all taste delicious')
  else
    puts @pastel.red("#{files_with_issues.count} taste nasty")
  end
end