Generates ruby code from ruby_parser sexps
ruby2ruby provides a means of generating pure ruby code easily from RubyParser compatible Sexps. This makes making dynamic language processors in ruby easier than ever!
ruby = "def a\n puts 'A'\nend\n\ndef b\n a\nend" parser = RubyParser.new ruby2ruby = Ruby2Ruby.new sexp = parser.process(ruby) pp sexp p ruby2ruby.process(sexp) ## outputs: s(:block, s(:defn, :a, s(:args), s(:scope, s(:block, s(:call, nil, :puts, s(:arglist, s(:str, "A")))))), s(:defn, :b, s(:args), s(:scope, s(:block, s(:call, nil, :a, s(:arglist)))))) "def a\n puts(\"A\")\nend\ndef b\n a\nend\n"
Get The CodeIf you just want to use ruby2ruby, you can install it via RubyGems:
gem install ruby2rubyIf you want to hack on ruby2ruby, clone it from GitHub:
git clone git://github.com/seattlerb/ruby2ruby