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]

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FileFinder


12
13
14
# File 'lib/haml_lint/file_finder.rb', line 12

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.


22
23
24
25
26
27
28
29
30
# File 'lib/haml_lint/file_finder.rb', line 22

def find(patterns, excluded_patterns)
  extract_files_from(patterns).reject do |file|
    excluded_patterns.any? do |exclusion_glob|
      ::File.fnmatch?(exclusion_glob, file,
                      ::File::FNM_PATHNAME | # Wildcards don't match path separators
                      ::File::FNM_DOTMATCH)  # `*` wildcard matches dotfiles
    end
  end
end