Class: Reek::Source::SourceRepository

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/reek/source/source_repository.rb

Overview

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, sources) ⇒ SourceRepository

Returns a new instance of SourceRepository


35
36
37
38
# File 'lib/reek/source/source_repository.rb', line 35

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

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description


33
34
35
# File 'lib/reek/source/source_repository.rb', line 33

def description
  @description
end

Class Method Details

.parse(source) ⇒ Object

TODO: This method is a least partially broken. Regardless of how you call reek, be it:

reek lib/
reek lib/file_one.rb lib/file_two.rb
echo "def m; end" | reek

we always end up in the “when Source::SourceCode” branch. So it seems like 80% of this method is never used.


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/reek/source/source_repository.rb', line 20

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

Instance Method Details

#each(&block) ⇒ Object


40
41
42
# File 'lib/reek/source/source_repository.rb', line 40

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