Method: Enolib::TerminalReporter#initialize

Defined in:
lib/enolib/reporters/terminal_reporter.rb

#initialize(context) ⇒ TerminalReporter

Returns a new instance of TerminalReporter.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/enolib/reporters/terminal_reporter.rb', line 49

def initialize(context)
  super(context)

  highest_shown_line_number = @snippet.length

  @snippet.reverse.each_with_index do |tag, index|
    if tag && tag != :omission
      highest_shown_line_number = index + 1
      break
    end
  end

  @line_number_padding = [4, highest_shown_line_number.to_s.length].max
  @header = ''

  if @context.source
    @header += "#{BLACK + BRIGHT_RED_BACKGROUND} #{INDICATORS[EMPHASIZE]} #{' '.rjust(@line_number_padding)} #{RESET} #{BOLD}#{@context.source}#{RESET}\n"
  end
end