Class: LetItCrash::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/letitcrash/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(rewriter: nil, reporters: [Reporters::Upload.from_env]) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
8
# File 'lib/letitcrash/formatter.rb', line 5

def initialize(rewriter: nil, reporters: [Reporters::Upload.from_env])
  @rewriter = rewriter
  @reporters = reporters
end

Instance Method Details

#format(result) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/letitcrash/formatter.rb', line 10

def format(result)
  report = Builders::ReportBuilder.build(
    environment: ENV,
    result: result,
    rewriter: rewriter,
  )
  reporters.each { |reporter| reporter.report(report) }
end

#newObject

This unfortunate trick is required since SimpleCov expects formatters to be classes rather than instances, and calls ‘new` on them.



21
22
23
# File 'lib/letitcrash/formatter.rb', line 21

def new
  self
end