Class: CovLoupe::Resolvers::CoverageLineResolver
- Inherits:
-
Object
- Object
- CovLoupe::Resolvers::CoverageLineResolver
- Defined in:
- lib/cov_loupe/resolvers/coverage_line_resolver.rb
Overview
Finds a SimpleCov line coverage array for a given file path.
Resolution strategy (in order):
- Exact match on the normalized input path
- Match after stripping the project root prefix (handles relative keys in resultsets)
On case-insensitive volumes, all comparisons are case-normalized to avoid false negatives. If multiple coverage entries normalize to the same path, an ambiguity error is raised to prevent silent data corruption.
This resolver is string-based only — it does not touch the filesystem.
Instance Attribute Summary collapse
-
#cov_data ⇒ Object
readonly
Returns the value of attribute cov_data.
Instance Method Summary collapse
-
#initialize(cov_data, root:, volume_case_sensitive:) ⇒ CoverageLineResolver
constructor
A new instance of CoverageLineResolver.
-
#lookup_lines(file_abs) ⇒ Array<Integer, nil>
Resolve coverage lines for a file path, trying fallbacks before raising.
Constructor Details
#initialize(cov_data, root:, volume_case_sensitive:) ⇒ CoverageLineResolver
Returns a new instance of CoverageLineResolver.
22 23 24 25 26 |
# File 'lib/cov_loupe/resolvers/coverage_line_resolver.rb', line 22 def initialize(cov_data, root:, volume_case_sensitive:) @cov_data = cov_data @root = root @normalize_case = !volume_case_sensitive end |
Instance Attribute Details
#cov_data ⇒ Object (readonly)
Returns the value of attribute cov_data.
46 47 48 |
# File 'lib/cov_loupe/resolvers/coverage_line_resolver.rb', line 46 def cov_data @cov_data end |
Instance Method Details
#lookup_lines(file_abs) ⇒ Array<Integer, nil>
Resolve coverage lines for a file path, trying fallbacks before raising.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cov_loupe/resolvers/coverage_line_resolver.rb', line 31 def lookup_lines(file_abs) # Normalize the input path first to handle platform-specific differences normalized_path = normalize_path(file_abs) # First try exact match direct_match = find_direct_match(normalized_path) return direct_match if direct_match # Then try without current working directory prefix stripped_match = find_stripped_match(normalized_path) return stripped_match if stripped_match raise_not_found_error(file_abs) end |