Class: Reviewer::Tool::FileResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/tool/file_resolver.rb

Overview

Resolves which files a tool should process by mapping and filtering.

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ FileResolver

Creates a FileResolver for a tool’s settings

Parameters:

  • settings (Tool::Settings)

    the tool’s settings containing file configuration



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) and filtering by the tool’s file pattern

Parameters:

  • files (Array<String>)

    the input files to resolve

Returns:

  • (Array<String>)

    files after mapping and filtering



20
21
22
23
24
# File 'lib/reviewer/tool/file_resolver.rb', line 20

def resolve(files)
  return files unless pattern

  filter(map(files))
end

#skip?(files) ⇒ Boolean

Determines if the tool should be skipped because files were requested but none match

Parameters:

  • files (Array<String>)

    the requested files

Returns:

  • (Boolean)

    true if files were requested but none remain after resolution



30
31
32
# File 'lib/reviewer/tool/file_resolver.rb', line 30

def skip?(files)
  files.any? && resolve(files).empty?
end