Sha256: f1aa7b9cd4ec32994ae2960082373509880094c8fdaff6693d3aabeda67a9d63

Contents?: true

Size: 890 Bytes

Versions: 4

Compression:

Stored size: 890 Bytes

Contents

require 'ruby_parser'
require 'reek/source/config_file'
require 'reek/source/tree_dresser'

module Reek
  module Source

    #
    # A +Source+ object represents a chunk of Ruby source code.
    #
    class SourceCode

      @@err_io = $stderr

      class << self
        def err_io=(io)
          original = @@err_io
          @@err_io = io
          original
        end
      end

      attr_reader :desc

      def initialize(code, desc, parser = RubyParser.new)
        @source = code
        @desc = desc
        @parser = parser
      end

      def configure(sniffer) end

      def syntax_tree
        begin
          ast = @parser.parse(@source, @desc)
        rescue Racc::ParseError, RubyParser::SyntaxError => error
          @@err_io.puts "#{desc}: #{error.class.name}: #{error}"
        end
        ast ||= s()
        TreeDresser.new.dress(ast)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reek-1.3.8 lib/reek/source/source_code.rb
reek-1.3.7 lib/reek/source/source_code.rb
reek-1.3.6 lib/reek/source/source_code.rb
reek-1.3.5 lib/reek/source/source_code.rb