Class: SlimLint::FileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/slim_lint/file_finder.rb

Overview

Finds Slim files that should be linted given a specified list of paths, glob patterns, and configuration.

Constant Summary collapse

VALID_EXTENSIONS =

List of extensions of files to include under a directory when a directory is specified instead of a file.

%w[.slim].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FileFinder

Create a file finder using the specified configuration.

Parameters:



16
17
18
# File 'lib/slim_lint/file_finder.rb', line 16

def initialize(config)
  @config = config
end

Instance Method Details

#find(patterns, excluded_patterns) ⇒ Array<String>

Return list of files to lint given the specified set of paths and glob patterns.

Parameters:

  • patterns (Array<String>)
  • excluded_patterns (Array<String>)

Returns:

  • (Array<String>)

    list of actual files

Raises:



26
27
28
29
30
31
32
# File 'lib/slim_lint/file_finder.rb', line 26

def find(patterns, excluded_patterns)
  excluded_patterns = excluded_patterns.map { |pattern| normalize_path(pattern) }

  extract_files_from(patterns).reject do |file|
    SlimLint::Utils.any_glob_matches?(excluded_patterns, file)
  end
end