Module: SimpleCov::Formatter

Defined in:
lib/simplecov/formatter.rb,
lib/simplecov/formatter/base.rb,
lib/simplecov/formatter/html_formatter.rb,
lib/simplecov/formatter/json_formatter.rb,
lib/simplecov/formatter/multi_formatter.rb,
lib/simplecov/formatter/simple_formatter.rb,
lib/simplecov/formatter/coverage_json_writer.rb,
lib/simplecov/formatter/json_formatter/errors_formatter.rb,
lib/simplecov/formatter/html_formatter/viewer_data_validator.rb,
lib/simplecov/formatter/json_formatter/result_hash_formatter.rb,
lib/simplecov/formatter/json_formatter/source_file_formatter.rb,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs

Overview

Namespace for result formatters. A formatter is any class whose instances respond to #format(result) and that can be instantiated with no arguments, or a ready-built instance responding to #format(result); wire one up via SimpleCov.formatter= or SimpleCov.formatters=.

Defined Under Namespace

Modules: CoverageJSONWriter, _Formatter Classes: Base, HTMLFormatter, JSONFormatter, MultiFormatter, SimpleFormatter

Class Method Summary collapse

Class Method Details

.format(formatter, result) ⇒ Object

Instantiates a formatter class when necessary and dispatches the result.

Parameters:

Returns:

  • (Object)


18
19
20
# File 'lib/simplecov/formatter.rb', line 18

def self.format(formatter, result)
  instance_for(formatter).format(result)
end

.instance_for(formatter) ⇒ Object

Normalizes a configured formatter — class or ready-built instance — into an instance. See #1240.

Parameters:

  • formatter (Object)

Returns:

  • (Object)


13
14
15
# File 'lib/simplecov/formatter.rb', line 13

def self.instance_for(formatter)
  formatter.is_a?(Class) ? formatter.new : formatter
end