Class: ThemeCheck::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/theme_check/printer.rb

Instance Method Summary collapse

Instance Method Details



5
6
7
8
9
10
11
12
13
14
# File 'lib/theme_check/printer.rb', line 5

def print(theme, offenses, auto_correct)
  offenses.each do |offense|
    print_offense(offense, auto_correct)
    puts
  end

  correctable = offenses.select(&:correctable?)
  puts "#{theme.all.size} files inspected, #{red(offenses.size.to_s + ' offenses')} detected, \
#{yellow(correctable.size.to_s + ' offenses')} #{auto_correct ? 'corrected' : 'auto-correctable'}"
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/theme_check/printer.rb', line 16

def print_offense(offense, auto_correct)
  location = if offense.location
    blue(offense.location) + ": "
  else
    ""
  end

  corrected = if auto_correct && offense.correctable?
    green("[Corrected] ")
  else
    ""
  end

  puts location +
    colorized_severity(offense.severity) + ": " +
    yellow(offense.check_name) + ": " +
    corrected +
    offense.message + "."
  if offense.source_excerpt
    puts "\t#{offense.source_excerpt}"
    if offense.markup_start_in_excerpt
      puts "\t" + (" " * offense.markup_start_in_excerpt) + ("^" * offense.markup.size)
    end
  end
end