Sha256: bd4b1345f77d6505dfad6de5b0ab17d762c423586f61fedf93491b13288188bd

Contents?: true

Size: 702 Bytes

Versions: 3

Compression:

Stored size: 702 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 relevant_config_files
        path = File.expand_path(File.dirname(@path))
        all_config_files(path)
      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

3 entries across 3 versions & 1 rubygems

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