Class: Reviewer::Tool::FileResolver
- Inherits:
-
Object
- Object
- Reviewer::Tool::FileResolver
- Defined in:
- lib/reviewer/tool/file_resolver.rb
Overview
Resolves which files a tool should process by mapping and filtering.
Instance Method Summary collapse
-
#initialize(settings) ⇒ FileResolver
constructor
Creates a FileResolver for a tool's settings.
-
#resolve(files) ⇒ Array<String>
Resolves input files by mapping source files to test files (if configured), filtering by the tool's file pattern, and omitting paths that do not exist.
-
#skip?(files) ⇒ Boolean
Determines if the tool should be skipped because files were requested but none match.
Constructor Details
#initialize(settings) ⇒ FileResolver
Creates a FileResolver for a tool's settings
11 12 13 |
# File 'lib/reviewer/tool/file_resolver.rb', line 11 def initialize(settings) @settings = settings end |
Instance Method Details
#resolve(files) ⇒ Array<String>
Resolves input files by mapping source files to test files (if configured), filtering by the tool's file pattern, and omitting paths that do not exist
20 21 22 23 24 25 26 |
# File 'lib/reviewer/tool/file_resolver.rb', line 20 def resolve(files) return files unless settings.supports_files? resolved = map(files) resolved = filter(resolved) if pattern resolved.select { |file| File.exist?(file) } end |
#skip?(files) ⇒ Boolean
Determines if the tool should be skipped because files were requested but none match
32 33 34 |
# File 'lib/reviewer/tool/file_resolver.rb', line 32 def skip?(files) files.any? && resolve(files).empty? end |