Class: Koality::Reporter::Cane
- Defined in:
- lib/koality/reporter/cane.rb
Instance Method Summary collapse
- #columns_for_type(type, error) ⇒ Object
- #report(type, violations) ⇒ Object
- #show_table(type, errors) ⇒ Object
Methods inherited from Base
Instance Method Details
#columns_for_type(type, error) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/koality/reporter/cane.rb', line 39 def columns_for_type(type, error) case type when :abc ["#{color(error.detail, :red)}\n #{error.file_name}", error.complexity] when :style ["#{color(error., :red)}\n #{error.file_name}:#{error.line}"] when :threshold [color(error.name, :red), "expected: #{error.operator} #{color(error.limit, :green)}, actual: #{color(error.value, :red)}"] else error.columns end end |
#report(type, violations) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/koality/reporter/cane.rb', line 5 def report(type, violations) unless violations.count > 0 report_success(type) return end show_table(type, violations) end |
#show_table(type, errors) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/koality/reporter/cane.rb', line 14 def show_table(type, errors) return if errors.empty? table = build_table table.title = color("Cane - #{type} - #{errors.count} Errors", :bold) if type == :style = errors.group_by { |e| e..split(/\(\d+\)/).first } .each do |, errors| msg = color(, :red) locations = errors.map { |e| " #{e.file_name}:#{e.line}" } table.add_row ["#{msg}\n#{locations.join("\n")}", errors.count] table.add_row :separator unless == .keys.last end else errors.each do |error| table.add_row columns_for_type(type, error) table.add_row :separator unless error == errors.last end end puts table end |