Module: SimcovAiFormatter

Defined in:
lib/simcov_ai_formatter.rb,
lib/simcov_ai_formatter/errors.rb,
lib/simcov_ai_formatter/version.rb,
lib/simcov_ai_formatter/renderer.rb,
lib/simcov_ai_formatter/formatter.rb,
lib/simcov_ai_formatter/suite_merger.rb,
lib/simcov_ai_formatter/source_reader.rb,
lib/simcov_ai_formatter/resultset_loader.rb,
lib/simcov_ai_formatter/simple_cov_formatter.rb

Defined Under Namespace

Classes: Error, Formatter, InvalidResultset, Renderer, ResultsetLoader, ResultsetNotFound, SimpleCovFormatter, SourceReader, SuiteMerger, SuiteNotFound

Constant Summary collapse

DEFAULT_RESULTSET_PATH =
"coverage/.resultset.json".freeze
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.format(path, root: Dir.pwd, suite: nil, with_source: false, context: 2, source_warnings: nil) ⇒ Hash

Public API: convert resultset.json into an AI-friendly Hash.

Parameters:

  • path (String)

    path to resultset.json

  • root (String) (defaults to: Dir.pwd)

    base directory for relative paths (default: Dir.pwd)

  • suite (String, nil) (defaults to: nil)

    pick a single suite; if nil, merge all suites via max(hit)

  • with_source (Boolean) (defaults to: false)

    embed source lines around uncovered ranges

  • context (Integer) (defaults to: 2)

    lines of context when with_source is true

  • source_warnings (IO, nil) (defaults to: nil)

    destination for source-missing warnings

Returns:

  • (Hash)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/simcov_ai_formatter.rb', line 21

def self.format(path, root: Dir.pwd, suite: nil, with_source: false, context: 2, source_warnings: nil)
  raw = ResultsetLoader.new(path).load
  selected_suite, coverage = SuiteMerger.new(raw, suite: suite).select
  source_reader = with_source ? SourceReader.new(warnings: source_warnings) : nil
  Formatter.new(
    coverage: coverage,
    suite: selected_suite,
    suites_merged: suite.nil? ? raw.keys : nil,
    root: root,
    with_source: with_source,
    context: context,
    source_reader: source_reader
  ).call
end