Sha256: acd6e70c75ba51e4f9fe94df1812f2a5920f3f8e2fee377b1136008c262043a5

Contents?: true

Size: 1014 Bytes

Versions: 2

Compression:

Stored size: 1014 Bytes

Contents

$:.unshift File.dirname(__FILE__)

require 'rubygems'
require 'parse_tree'
require 'sexp_processor'

module Reek

  class Printer < SexpProcessor
    def self.print(sexp)
      new.print(sexp)
    end

    def initialize
      super
      @require_empty = false
      @report = ''
    end

    def print(sexp)
      @report = sexp.inspect
      begin
        process(sexp)
      rescue
        raise "Error in print, parsing:\n #{sexp.inspect}"
      end
      @report
    end

    def process_lvar(exp)
      @report = exp[1].inspect
      s(exp)
    end

    def process_dvar(exp)
      @report = exp[1].inspect
      s(exp)
    end

    def process_gvar(exp)
      @report = exp[1].inspect
      s(exp)
    end

    def process_const(exp)
      @report = exp[1].inspect
      s(exp)
    end

    def process_iter(exp)
      @report = 'block'
      s(exp)
    end

    def process_call(exp)
      @report = "#{exp[1]}.#{exp[2]}"
      @report += "(#{exp[3]})" if exp.length > 3
      s(exp)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-0.1.1 lib/reek/printer.rb
reek-0.2.0 lib/reek/printer.rb