Class: CovLoupe::Resolvers::ResultsetPathResolver
- Inherits:
-
Object
- Object
- CovLoupe::Resolvers::ResultsetPathResolver
- Defined in:
- lib/cov_loupe/resolvers/resultset_path_resolver.rb
Overview
Locates the .resultset.json file for a project.
Resolution order:
- If the user provides an explicit path, resolve it (supports files and directories)
- If not found, search a list of default candidate locations relative to the project root
When a relative path is given, it is expanded against both the current working directory and the project root. If both expansions point to valid locations, an ambiguity error is raised to prevent silently using the wrong file.
Constant Summary collapse
- DEFAULT_CANDIDATES =
[ '.resultset.json', 'coverage/.resultset.json', 'tmp/.resultset.json', ].freeze
Instance Method Summary collapse
- #find_resultset(resultset: nil) ⇒ Object
-
#initialize(root: Dir.pwd, candidates: DEFAULT_CANDIDATES) ⇒ ResultsetPathResolver
constructor
A new instance of ResultsetPathResolver.
Constructor Details
#initialize(root: Dir.pwd, candidates: DEFAULT_CANDIDATES) ⇒ ResultsetPathResolver
Returns a new instance of ResultsetPathResolver.
26 27 28 29 |
# File 'lib/cov_loupe/resolvers/resultset_path_resolver.rb', line 26 def initialize(root: Dir.pwd, candidates: DEFAULT_CANDIDATES) @root = root @candidates = candidates end |
Instance Method Details
#find_resultset(resultset: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cov_loupe/resolvers/resultset_path_resolver.rb', line 31 def find_resultset(resultset: nil) if resultset && !resultset.empty? path = normalize_resultset_path(resultset) if (resolved = resolve_candidate(path, strict: true)) return resolved end end resolve_fallback or raise_not_found_error end |