Sha256: 9211708897ca83f61e3b8c6612b95797b2612d21c1aa5c88f8a6b1714af6aab8

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

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

3 entries across 3 versions & 1 rubygems

Version Path
reek-1.3.1 lib/reek/source/source_locator.rb
reek-1.3 lib/reek/source/source_locator.rb
reek-1.2.13 lib/reek/source/source_locator.rb