Sha256: 3bee52adc7000ecc7b85a277bc8ca6a9257d8eaf9d4013c6d2f9b1c742a6aba7

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

require 'reek/source/core_extras'
require 'reek/source/source_code'
require 'reek/source/source_locator'

module Reek
  module Source
    #
    # A collection of source code. If the collection is initialized with an array
    # it is assumed to be a list of file paths. Otherwise it is assumed to be a
    # single unit of Ruby source code.
    #
    class SourceRepository
      def self.parse(source)
        case source
        when Array
          new 'dir', Source::SourceLocator.new(source).all_sources
        when Source::SourceCode
          new source.desc, [source]
        else
          src = source.to_reek_source
          new src.desc, [src]
        end
      end

      include Enumerable
      attr_reader :description

      def initialize(description, sources)
        @description = description
        @sources = sources
      end

      def each(&block)
        @sources.each(&block)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reek-1.5.1 lib/reek/source/source_repository.rb
reek-1.5.0 lib/reek/source/source_repository.rb
reek-1.4.0 lib/reek/source/source_repository.rb