Sha256: 15a01042863a2d0438509ad60db0de0657b1dd6afa4db312bad4663b98c85bef
Contents?: true
Size: 1.63 KB
Versions: 9
Compression:
Stored size: 1.63 KB
Contents
require 'reek/adapters/source' require 'reek/sniffer' class Object # # Creates a new +Sniffer+ that assumes this object contains Ruby source # code and examines that code for smells. Calls +to_reek_source+ on self # to obtain the +Source+ object wrapper. # def sniff Reek::Sniffer.new(self.to_reek_source) end # # Constructs a Sniffer which examines this object for code smells. # (This feature is only enabled if you have the ParseTree gem installed.) # def to_reek_source ObjectSource.new(self, self.to_s) end end class File # # Creates a new +Source+ that assumes this File contains Ruby source # code and prepares it to be examined for code smells. # def to_reek_source Reek::SourceFile.new(self) end end class IO # # Creates a new +Source+ that assumes this IO stream contains Ruby source # code and prepares it to be examined for code smells. # def to_reek_source(description = 'io') Reek::Source.new(self.readlines.join, description) end end class String # # Creates a new +Source+ that assumes this string contains Ruby source # code and prepares it to be examined for code smells. # def to_reek_source Reek::Source.new(self, 'string') end end class Array def paths self.map do |path| if test 'd', path Dir["#{path}/**/*.rb"].paths else path end end.flatten.sort end # # Creates a new +Sniffer+ that assumes this Array contains the names # of Ruby source files and examines those files for smells. # def sniff sniffers = paths.map {|path| File.new(path).sniff} Reek::SnifferSet.new(sniffers, 'dir') end end
Version data entries
9 entries across 9 versions & 2 rubygems