Class: Reek::SourceFile

Inherits:
Source show all
Defined in:
lib/reek/adapters/source.rb

Overview

Represents a file of Ruby source, whose contents will be examined for code smells.

Instance Attribute Summary

Attributes inherited from Source

#desc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Source

#syntax_tree

Constructor Details

#initialize(file) ⇒ SourceFile

Returns a new instance of SourceFile.



34
35
36
37
# File 'lib/reek/adapters/source.rb', line 34

def initialize(file)
  @file = file
  super(SourceFile.lines(@file).join, @file.path)
end

Class Method Details

.lines(file) ⇒ Object



30
31
32
# File 'lib/reek/adapters/source.rb', line 30

def self.lines(file)
  IO.readlines(file.path)
end

Instance Method Details

#configure(sniffer) ⇒ Object



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

def configure(sniffer)
  path = File.expand_path(File.dirname(@file.path))
  all_config_files(path).each { |cf| ConfigFile.new(cf).configure(sniffer) }
end