Colorize dot formatter

closes #1
This commit is contained in:
Vitalii Elenhaupt 2017-11-01 22:37:21 +02:00
parent c9f229c3f1
commit 75ec695a62
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706

View file

@ -13,7 +13,7 @@ module Ameba
def start(sources)
puts formatter.before sources
puts "\n\n"
puts "\n"
end
def report(source)
@ -36,7 +36,7 @@ module Ameba
end
def format(source : Source)
source.errors.size == 0 ? "." : "F"
source.valid? ? ".".colorize(:green) : "F".colorize(:red)
end
def after(sources)
@ -44,15 +44,17 @@ module Ameba
failures = sources.select { |s| s.errors.any? }
l = failures.map { |f| f.errors.size }.sum
mes << "#{sources.size} inspected, #{l} failure#{"s" if l != 1}.\n\n"
failures.each do |failure|
failure.errors.each do |error|
mes << "#{failure.path}:#{error.pos}"
mes << "\n"
mes << "#{error.rule.name}: #{error.message}\n\n"
mes << "#{failure.path}:#{error.pos}\n".colorize(:cyan)
mes << "#{error.rule.name}: #{error.message}".colorize(:red)
mes << "\n\n"
end
end
color = l == 0 ? :green : :red
mes << "#{sources.size} inspected, #{l} failure#{"s" if l != 1}."
.colorize(color)
end
end
end