Class: Codecov::SimpleCov::Formatter

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

Constant Summary collapse

RESULT_FILE_NAME =
'codecov-result.json'

Instance Method Summary collapse

Instance Method Details

#format(report) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/codecov/formatter.rb', line 12

def format(report)
  result = {
    'meta' => {
      'version' => "codecov-ruby/v#{::Codecov::VERSION}"
    }
  }
  result.update(result_to_codecov(report))

  result_path = File.join(::SimpleCov.coverage_path, RESULT_FILE_NAME)
  if File.writable?(result_path)
    File.write(result_path, result['codecov'])
    puts "Coverage report generated to #{result_path}.\#{result}"
  else
    puts "Could not write coverage report to file #{result_path}.\n#{result}"
  end

  result
end