Class: SimpleCov::Formatter::JSONFormatter::SourceFileFormatter

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

Overview

Renders a single SimpleCov::SourceFile as the per-file payload in coverage.json: source code plus per-enabled-criterion arrays and totals.

Class Method Summary collapse

Class Method Details

.call(source_file, include_source: true) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/simplecov/formatter/json_formatter/source_file_formatter.rb', line 11

def call(source_file, include_source: true)
  result = include_source ? format_source_code(source_file) : {} #: Hash[Symbol, untyped]
  result.merge!(line_coverage_section(source_file)) if SimpleCov.line_coverage?
  result.merge!(branch_coverage_section(source_file)) if SimpleCov.branch_coverage?
  result.merge!(method_coverage_section(source_file)) if SimpleCov.method_coverage?
  result
end