Class: SimpleCov::Formatter::JSONFormatter::ResultHashFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/formatter/json_formatter/result_hash_formatter.rb

Overview

Builds the hash that JSONFormatter serializes to coverage.json: meta, per-file coverage data, group totals, and aggregate stats.

Instance Method Summary collapse

Constructor Details

#initialize(result, include_source: true) ⇒ ResultHashFormatter

Returns a new instance of ResultHashFormatter.



25
26
27
28
# File 'lib/simplecov/formatter/json_formatter/result_hash_formatter.rb', line 25

def initialize(result, include_source: true)
  @result = result
  @include_source = include_source
end

Instance Method Details

#formatObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/simplecov/formatter/json_formatter/result_hash_formatter.rb', line 30

def format
  {
    :$schema => SCHEMA_URL,
    :meta => format_meta,
    :total => format_coverage_statistics(@result.coverage_statistics),
    :coverage => format_files,
    :groups => format_groups,
    :errors => ErrorsFormatter.new(@result).call
  }
end