Class: Txray::Reporters::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/txray/reporters/text.rb

Constant Summary collapse

COLORS =
{ high: 91, medium: 93, low: 96 }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(io: $stdout, color: Reporters.color?(io)) ⇒ Text

Returns a new instance of Text.



10
11
12
13
14
# File 'lib/txray/reporters/text.rb', line 10

def initialize(io: $stdout, color: Reporters.color?(io))
  @io = io
  @color = color
  @width = width
end

Instance Method Details

#report(result) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/txray/reporters/text.rb', line 16

def report(result)
  result.offenses.group_by(&:path).each_with_index do |(path, offenses), index|
    @io.puts if index.positive?
    heading(path, offenses)
    offenses.each_with_index do |offense, position|
      @io.puts if position.positive?
      offense_body(offense)
    end
  end

  @io.puts
  summary(result)
end