Sha256: d6441dcb09b3659038435b4897a322b94ca3f42e6db57512d67231f2868bfe37

Contents?: true

Size: 667 Bytes

Versions: 7

Compression:

Stored size: 667 Bytes

Contents

require "pathname"

module Rubycritic

  class SourceLocator
    RUBY_EXTENSION = ".rb"
    RUBY_FILES = File.join("**", "*#{RUBY_EXTENSION}")

    def initialize(paths)
      @initial_paths = paths
    end

    def paths
      @paths ||= pathnames.map(&:to_s)
    end

    def pathnames
      @pathnames ||= expand_paths
    end

    private

    def expand_paths
      @initial_paths.map do |path|
        if File.directory?(path)
          Pathname.glob(File.join(path, RUBY_FILES))
        elsif File.exists?(path) && File.extname(path) == RUBY_EXTENSION
          Pathname.new(path)
        end
      end.flatten.compact.map(&:cleanpath).sort
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-1.0.2 lib/rubycritic/source_locator.rb
rubycritic-1.0.1 lib/rubycritic/source_locator.rb
rubycritic-1.0.0 lib/rubycritic/source_locator.rb
rubycritic-0.0.16 lib/rubycritic/source_locator.rb
rubycritic-0.0.15 lib/rubycritic/source_locator.rb
rubycritic-0.0.14 lib/rubycritic/source_locator.rb
rubycritic-0.0.13 lib/rubycritic/source_locator.rb