Class: HamlLint::FileFinder

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

Overview

Finds Haml 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[.haml].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FileFinder

Create a file finder using the specified configuration.

Parameters:



16
17
18
# File 'lib/haml_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
33
34
# File 'lib/haml_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|
    excluded_patterns.any? do |exclusion_glob|
      HamlLint::Utils.any_glob_matches?(exclusion_glob, file)
    end
  end
end