Sha256: f4ca56338d9245b4d8c672f8a84d1c6ee08bb450d45bc663d6649ca211fc169e

Contents?: true

Size: 853 Bytes

Versions: 15

Compression:

Stored size: 853 Bytes

Contents

require 'reek/source/core_extras'

module Reek
  module Source
    #
    # Finds Ruby source files in a filesystem.
    #
    class SourceLocator
      def initialize(paths)
        @paths = paths.map { |path| path.chomp('/') }
      end

      def all_sources
        valid_paths.map { |path| File.new(path).to_reek_source }
      end

      private

      def all_ruby_source_files(paths)
        paths.map do |path|
          if test 'd', path
            all_ruby_source_files(Dir["#{path}/**/*.rb"])
          else
            path
          end
        end.flatten.sort
      end

      def valid_paths
        all_ruby_source_files(@paths).select do |path|
          if test 'f', path
            true
          else
            $stderr.puts "Error: No such file - #{path}"
            false
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reek-2.0.4 lib/reek/source/source_locator.rb
reek-2.0.3 lib/reek/source/source_locator.rb
reek-2.0.2 lib/reek/source/source_locator.rb
reek-2.0.1 lib/reek/source/source_locator.rb
reek-2.0.0 lib/reek/source/source_locator.rb
reek-1.6.6 lib/reek/source/source_locator.rb
reek-1.6.5 lib/reek/source/source_locator.rb
reek-1.6.4 lib/reek/source/source_locator.rb
reek-1.6.3 lib/reek/source/source_locator.rb
reek-1.6.2 lib/reek/source/source_locator.rb
reek-1.6.1 lib/reek/source/source_locator.rb
reek-1.6.0 lib/reek/source/source_locator.rb
reek-1.5.1 lib/reek/source/source_locator.rb
reek-1.5.0 lib/reek/source/source_locator.rb
reek-1.4.0 lib/reek/source/source_locator.rb