class Codeshift::Transformer

Transformer Class

Public Class Methods

new(code, transform) click to toggle source
# File lib/codeshift/transformer.rb, line 8
def initialize(code, transform)
  @code = code
  @transform = transform
end

Public Instance Methods

transform() click to toggle source
# File lib/codeshift/transformer.rb, line 13
def transform
  eval(@transform)

  buffer        = Parser::Source::Buffer.new('(example)')
  buffer.source = @code
  begin
    temp = Parser::CurrentRuby.parse(@code)
    rewriter = Transform.new

    # Rewrite the AST, returns a String with the new form.
    output = rewriter.rewrite(buffer, temp)
  rescue
    puts "Unknown parsing error"
    @code
  end

end