Sha256: 0e246c3c8c5f9539617d31153724bc833685ef9d7be87f14b0ade4e424031536

Contents?: true

Size: 940 Bytes

Versions: 10

Compression:

Stored size: 940 Bytes

Contents

require 'ruby_parser'
require File.join(File.dirname(File.expand_path(__FILE__)), 'config_file')
require File.join(File.dirname(File.expand_path(__FILE__)), '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 Exception => error
          @@err_io.puts "#{desc}: #{error.class.name}: #{error}"
        end
        ast ||= s()
        TreeDresser.new.dress(ast)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
reek-1.3.1 lib/reek/source/source_code.rb
reek-1.3 lib/reek/source/source_code.rb
reek-1.2.11 lib/reek/source/source_code.rb
reek-1.2.10 lib/reek/source/source_code.rb
reek-1.2.9 lib/reek/source/source_code.rb
reek-1.2.8 lib/reek/source/source_code.rb
reek-1.2.7.3 lib/reek/source/source_code.rb
reek-1.2.7.2 lib/reek/source/source_code.rb
reek-1.2.7.1 lib/reek/source/source_code.rb
reek-1.2.7 lib/reek/source/source_code.rb