Class: CovLoupe::Repositories::CoverageRepository
- Inherits:
-
Object
- Object
- CovLoupe::Repositories::CoverageRepository
- 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:
- Locating the .resultset.json file using ResolverHelpers.
- Loading and parsing the JSON data using ResultsetLoader (handling suite merging if needed).
- Normalizing all coverage map keys to absolute paths relative to the project root.
Instance Attribute Summary collapse
-
#coverage_map ⇒ Hash
readonly
A map of absolute file paths to coverage data.
-
#resultset_path ⇒ String
readonly
The resolved absolute path to the .resultset.json file.
-
#timestamp ⇒ Integer
readonly
The latest timestamp from the loaded coverage suites.
Instance Method Summary collapse
-
#initialize(root:, resultset_path: nil, logger: nil) ⇒ CoverageRepository
constructor
A new instance of CoverageRepository.
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. 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_map ⇒ Hash (readonly)
A map of absolute file paths to coverage data.
22 23 24 |
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22 def coverage_map @coverage_map end |
#resultset_path ⇒ String (readonly)
The resolved absolute path to the .resultset.json file.
22 23 24 |
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22 def resultset_path @resultset_path end |
#timestamp ⇒ Integer (readonly)
The latest timestamp from the loaded coverage suites.
22 23 24 |
# File 'lib/cov_loupe/repositories/coverage_repository.rb', line 22 def @timestamp end |