Sha256: c21562040639f17a2503ba52436bdb2e80b8998bd48ab21c61379483c2d82af2

Contents?: true

Size: 1011 Bytes

Versions: 7

Compression:

Stored size: 1011 Bytes

Contents

require 'reek/source/source_code'

#
# Extensions to +File+ needed by Reek.
#
class File
  #
  # Creates a new +Source+ that assumes this File contains Ruby source
  # code and prepares it to be examined for code smells.
  #
  # @return [Reek::Source::SourceFile]
  #
  def to_reek_source
    Reek::Source::SourceFile.new(path)
  end
end

#
# Extensions to +IO+ needed by Reek.
#
class IO
  #
  # Creates a new +Source+ that assumes this IO stream contains Ruby source
  # code and prepares it to be examined for code smells.
  #
  # @return [Reek::Source::SourceCode]
  #
  def to_reek_source(description = 'io')
    Reek::Source::SourceCode.new(self.readlines.join, description)
  end
end

#
# Extensions to +String+ needed by Reek.
#
class String
  #
  # Creates a new +Source+ that assumes this string contains Ruby source
  # code and prepares it to be examined for code smells.
  #
  # @return [Reek::Source::SourceCode]
  #
  def to_reek_source
    Reek::Source::SourceCode.new(self, 'string')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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