Class: Chutney::RainbowFormatter
Overview
Instance Attribute Summary
Attributes inherited from Formatter
#results
Instance Method Summary
collapse
Methods inherited from Formatter
#files, #files_with_issues
Constructor Details
Returns a new instance of RainbowFormatter.
8
9
10
11
12
|
# File 'lib/chutney/formatter/rainbow_formatter.rb', line 8
def initialize
super
@pastel = Pastel.new
end
|
Instance Method Details
14
15
16
17
18
19
20
21
22
23
|
# 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) ⇒ Object
25
26
27
|
# File 'lib/chutney/formatter/rainbow_formatter.rb', line 25
def put_file(file)
puts @pastel.cyan(file.to_s)
end
|
#put_issue(file, issue) ⇒ Object
33
34
35
36
|
# 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) ⇒ Object
29
30
31
|
# File 'lib/chutney/formatter/rainbow_formatter.rb', line 29
def put_linter(linter)
puts @pastel.red(" #{linter[:linter]}")
end
|
#put_summary ⇒ Object
38
39
40
41
42
43
44
45
|
# 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
|