Sha256: 882eb4b406faa213feca7d97e5f3523af8ae291a9dd1b1e8bb8aa80ce5ed8f07

Contents?: true

Size: 751 Bytes

Versions: 7

Compression:

Stored size: 751 Bytes

Contents

require 'reek/source/source_code'

module Reek
  module Source

    #
    # Represents a file of Ruby source, whose contents will be examined
    # for code smells.
    #
    class SourceFile < SourceCode

      def initialize(path)
        @path = path
        super(IO.readlines(@path).join, @path)
      end

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

    private

      def all_config_files(path)
        return [] unless File.exist?(path)
        parent = File.dirname(path)
        return [] if path == parent
        all_config_files(parent) + Dir["#{path}/*.reek", "#{path}/.reek"]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-1.3.8 lib/reek/source/source_file.rb
reek-1.3.7 lib/reek/source/source_file.rb
reek-1.3.6 lib/reek/source/source_file.rb
reek-1.3.5 lib/reek/source/source_file.rb
reek-1.3.4 lib/reek/source/source_file.rb
reek-1.3.3 lib/reek/source/source_file.rb
reek-1.3.2 lib/reek/source/source_file.rb