Class: SimpleCov::Formatter::JSONFormatter

Inherits:
Base
  • Object
show all
Defined in:
lib/simplecov/formatter/json_formatter.rb,
lib/simplecov/formatter/json_formatter/errors_formatter.rb,
lib/simplecov/formatter/json_formatter/result_hash_formatter.rb,
lib/simplecov/formatter/json_formatter/source_file_formatter.rb,
lib/simplecov/formatter/json_formatter/production_section_formatter.rb,
sig/simplecov.rbs

Defined Under Namespace

Modules: ProductionSectionFormatter Classes: ErrorsFormatter, ResultHashFormatter, SourceFileFormatter

Constant Summary collapse

FILENAME =

Returns:

  • ("coverage.json")
CoverageJSONWriter::FILENAME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#displayable_output_path, #emit_status, #initialize, #output_message, #output_path, #relative_or_absolute_output_path, #stats_line

Constructor Details

This class inherits a constructor from SimpleCov::Formatter::Base

Class Method Details

.build_hash(result, include_source: SimpleCov.source_in_json) ⇒ Hash[Symbol, untyped]

Callers that need the source array regardless of the global setting (the HTML formatter, which feeds the client-side viewer) pass include_source: true explicitly.

Parameters:

  • result (SimpleCov::Result)
  • include_source: (Boolean) (defaults to: SimpleCov.source_in_json)

Returns:

  • (Hash[Symbol, untyped])


15
16
17
# File 'lib/simplecov/formatter/json_formatter.rb', line 15

def self.build_hash(result, include_source: SimpleCov.source_in_json)
  ResultHashFormatter.format(result, include_source: include_source)
end

Instance Method Details

#entry_point_filenameString

Returns:

  • (String)


30
31
32
# File 'lib/simplecov/formatter/json_formatter.rb', line 30

def entry_point_filename
  FILENAME
end

#format(result) ⇒ void

This method returns an undefined value.

Parameters:



19
20
21
22
# File 'lib/simplecov/formatter/json_formatter.rb', line 19

def format(result)
  CoverageJSONWriter.write(output_path, self.class.build_hash(result), result)
  emit_status(result)
end

#message_prefixString

Returns:

  • (String)


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

def message_prefix
  "JSON "
end