class TodoLint::FileFinder
Which files are we going to inspect?
Attributes
all_files[R]
Absolute paths to all the files which exist within the provided folder @return [Array<String>] @api private
options[R]
Options
hash for all configurations @return [Hash] @example FileFinder.new
(path, options).options @api public
path[R]
Which folder to look within for files @return [String] @api private
Public Class Methods
new(path, options)
click to toggle source
Instantiate a FileFinder
with the path to a folder @example
FileFinder.new("/Users/max/src/layabout")
@api public
# File lib/todo_lint/file_finder.rb, line 10 def initialize(path, options) @path = path @options = options @all_files = Dir.glob(Pathname.new(path).join("**", "*")) @excluded = options[:excluded_files] end
Public Instance Methods
list(*extensions)
click to toggle source
Absolute paths to all the files with the provided extensions @example
FileFinder.new("/Users/max/src/layabout").list(".rb", ".coffee")
@api public @return [Array<String>]
# File lib/todo_lint/file_finder.rb, line 22 def list(*extensions) all_files.keep_if do |filename| extensions.include?(Pathname.new(filename).extname) end all_files.reject! { |file| excluded_file?(file) } all_files end
Private Instance Methods
excluded_file?(file)
click to toggle source
Check if this file has been excluded @api private @return [Boolean]
# File lib/todo_lint/file_finder.rb, line 51 def excluded_file?(file) full_path = File.expand_path(file) options.fetch(:excluded_files, []).any? do |file_to_exclude| File.fnmatch(file_to_exclude, full_path) end end