Class: SCSSLint::FileFinder
- Inherits:
-
Object
- Object
- SCSSLint::FileFinder
- Defined in:
- lib/scss_lint/file_finder.rb
Overview
Finds all SCSS files that should be linted given a set of paths, globs, and configuration.
Constant Summary collapse
- VALID_EXTENSIONS =
List of extensions of files to include when only a directory is specified as a path.
%w[.css .scss]
Instance Method Summary collapse
-
#find(patterns) ⇒ Object
Find all files that match given the specified options.
-
#initialize(config) ⇒ FileFinder
constructor
Create a FileFinder.
Constructor Details
#initialize(config) ⇒ FileFinder
Create a SCSSLint::FileFinder.
14 15 16 |
# File 'lib/scss_lint/file_finder.rb', line 14 def initialize(config) @config = config end |
Instance Method Details
#find(patterns) ⇒ Object
Find all files that match given the specified options.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scss_lint/file_finder.rb', line 21 def find(patterns) # If no explicit patterns given, use patterns listed in config patterns = @config.scss_files if patterns.empty? matched_files = extract_files_from(patterns) if matched_files.empty? raise SCSSLint::Exceptions::NoFilesError, "No SCSS files matched by the patterns: #{patterns.join(' ')}" end filtered_files = matched_files.reject { |file| @config.excluded_file?(file) } if filtered_files.empty? raise SCSSLint::Exceptions::AllFilesFilteredError, "All files matched by the patterns [#{patterns.join(', ')}] " \ "were excluded by the patterns: [#{@config.exclude_patterns.join(', ')}]" end filtered_files end |