Sha256: c1411a53be5db654c270e37ec7e00ffb92ea50bd4d56ff958f1ec8cf0e75b7a3

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), 'core_extras')

module Reek
  module Source

    #
    # Finds Ruby source files in a filesystem.
    #
    class SourceLocator
      def initialize(paths)
        @paths = paths
      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

6 entries across 6 versions & 1 rubygems

Version Path
reek-1.2.12 lib/reek/source/source_locator.rb
reek-1.2.11 lib/reek/source/source_locator.rb
reek-1.2.10 lib/reek/source/source_locator.rb
reek-1.2.9 lib/reek/source/source_locator.rb
reek-1.2.8 lib/reek/source/source_locator.rb
reek-1.2.7.3 lib/reek/source/source_locator.rb