Class: TodoLint::FileFinder

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

Overview

Which files are we going to inspect?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options) ⇒ FileFinder

Instantiate a FileFinder with the path to a folder

Examples:

FileFinder.new("/Users/max/src/layabout")


10
11
12
13
14
15
# 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

Instance Attribute Details

#optionsHash (readonly)

Options hash for all configurations

Examples:

FileFinder.new(path, options).options

Returns:

  • (Hash)


34
35
36
# File 'lib/todo_lint/file_finder.rb', line 34

def options
  @options
end

Instance Method Details

#list(*extensions) ⇒ Array<String>

Absolute paths to all the files with the provided extensions

Examples:

FileFinder.new("/Users/max/src/layabout").list(".rb", ".coffee")

Returns:

  • (Array<String>)


22
23
24
25
26
27
28
# 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