Class: CodeClimate::TestReporter::Formatter

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

Defined Under Namespace

Classes: InvalidSimpleCovResultError

Instance Method Summary collapse

Instance Method Details

#format(results) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/code_climate/test_reporter/formatter.rb', line 17

def format(results)
  begin
    validated_results = results.values.fetch(0).fetch("coverage")
  rescue NoMethodError, KeyError => ex
    raise InvalidSimpleCovResultError, ex.message
  end

  simplecov_results = SimpleCov::Result.new(validated_results)

  payload = to_payload(simplecov_results)
  PayloadValidator.validate(payload)

  payload
end