class RubyCritic::SourceLocator

Constants

RUBY_EXTENSION
RUBY_FILES

Public Class Methods

new(paths) click to toggle source
# File lib/rubycritic/source_locator.rb, line 11
def initialize(paths)
  @initial_paths = Array(paths)
end

Public Instance Methods

pathnames() click to toggle source
# File lib/rubycritic/source_locator.rb, line 19
def pathnames
  @pathnames ||= expand_paths
end
paths() click to toggle source
# File lib/rubycritic/source_locator.rb, line 15
def paths
  @paths ||= pathnames.map(&:to_s)
end

Private Instance Methods

expand_paths() click to toggle source
# File lib/rubycritic/source_locator.rb, line 38
def expand_paths
  path_list = @initial_paths.flat_map do |path|
    if File.directory?(path)
      Pathname.glob(File.join(path, RUBY_FILES))
    elsif File.exist?(path) && File.extname(path) == RUBY_EXTENSION
      Pathname.new(path)
    end
  end.compact

  deduplicate_symlinks(path_list) if Config.deduplicate_symlinks

  path_list.map(&:cleanpath)
end