Class: ImproveYourCode::Source::SourceLocator

Inherits:
Object
  • Object
show all
Defined in:
lib/improve_your_code/source/source_locator.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ SourceLocator

Returns a new instance of SourceLocator.



9
10
11
# File 'lib/improve_your_code/source/source_locator.rb', line 9

def initialize(paths)
  @paths = paths.flat_map { |string| Pathname.new(string).entries }
end

Instance Method Details

#sourcesObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/improve_your_code/source/source_locator.rb', line 13

def sources
  paths.each_with_object([]) do |given_path, relevant_paths|
    given_path.find do |path|
      if path.directory?
        ignore_path?(path) ? Find.prune : next
      elsif ruby_file?(path)
        relevant_paths << path
      end
    end
  end
end