Created
December 13, 2011 06:40
-
-
Save presidentbeef/1470939 to your computer and use it in GitHub Desktop.
Using Brakeman::AliasProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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