Skip to content

Instantly share code, notes, and snippets.

@presidentbeef
Created December 13, 2011 06:40
Show Gist options
  • Save presidentbeef/1470939 to your computer and use it in GitHub Desktop.
Save presidentbeef/1470939 to your computer and use it in GitHub Desktop.
Using Brakeman::AliasProcessor
require 'ruby_parser'
require 'ruby2ruby'
require 'brakeman'
require 'brakeman/processors/alias_processor'
#Local variables for clarity
def process code
sexp = RubyParser.new.parse code
processed_sexp = Brakeman::AliasProcessor.new.process_safely sexp
pretty_code = Ruby2Ruby.new.process processed_sexp
end
puts process <<RUBY
x = [1, 2, 3]
y = 1
y = y + 1
x[y]
RUBY
=begin output
x = [1, 2, 3]
y = 1
y = 2
3
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment