Sha256: 5667e99868051c98d27f13d01497e32b06532e08f20fced475dc00c93eaf21dd

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 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

5 entries across 5 versions & 1 rubygems

Version Path
reek-1.3.8 lib/reek/source/source_locator.rb
reek-1.3.7 lib/reek/source/source_locator.rb
reek-1.3.6 lib/reek/source/source_locator.rb
reek-1.3.5 lib/reek/source/source_locator.rb
reek-1.3.4 lib/reek/source/source_locator.rb