Class: CovLoupe::Repositories::CoverageRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/cov_loupe/repositories/coverage_repository.rb

Overview

CoverageRepository handles the discovery, loading, and normalization of SimpleCov coverage data. It decouples data access concerns from the domain logic in CoverageModel.

Its primary responsibilities are:

  1. Locating the .resultset.json file using ResolverHelpers.
  2. Loading and parsing the JSON data using ResultsetLoader (handling suite merging if needed).
  3. Normalizing all coverage map keys to absolute paths relative to the project root.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, resultset_path: nil, logger: nil) ⇒ CoverageRepository

Returns a new instance of CoverageRepository.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 25

def initialize(root:, resultset_path: nil, logger: nil)
  @root = root
  @logger = logger || CovLoupe.logger

  begin
    # 1. Locate the file
    @resultset_path = resolve_resultset_path(resultset_path)

    # 2. Load the data
    loaded_data = load_data

    # 3. Detect volume case sensitivity from project root
    @volume_case_sensitive = detect_volume_case_sensitivity

    # 4. Normalize keys to absolute paths
    @coverage_map = normalize_paths(loaded_data.coverage_map)
    @timestamp = loaded_data.timestamp
  rescue CovLoupe::Error
    raise # Re-raise our own errors as-is
  rescue => e
    raise ErrorHandler.new.convert_standard_error(e, context: :coverage_loading)
  end
end

Instance Attribute Details

#coverage_mapHash (readonly)

A map of absolute file paths to coverage data.

Returns:

  • (Hash)

    the current value of coverage_map



22
23
24
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22

def coverage_map
  @coverage_map
end

#resultset_pathString (readonly)

The resolved absolute path to the .resultset.json file.

Returns:

  • (String)

    the current value of resultset_path



22
23
24
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22

def resultset_path
  @resultset_path
end

#timestampInteger (readonly)

The latest timestamp from the loaded coverage suites.

Returns:

  • (Integer)

    the current value of timestamp



22
23
24
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22

def timestamp
  @timestamp
end