sexp2ruby
sexp2ruby generates ruby from RubyParser S-expressions.
It is a fork of ruby2ruby with slightly different goals.
- Generates ruby that follows ruby-style-guide where possible
- Prefers OO design over performance
- Uses bundler instead of hoe
- Uses rspec instead of minitest
Example
require 'ruby_parser'
require 'sexp2ruby'
ruby = "def a\n puts 'A'\nend\n\ndef b\n a\nend"
sexp = RubyParser.new.process(ruby)
# => s(:block, s(:defn, .. etc.
Sexp2Ruby::Processor.new.process(sexp.deep_clone)
# => "def a\n puts(\"A\")\nend\ndef b\n a\nend\n"
As with all SexpProcessors, Sexp2Ruby#process destroys its input,
so deep_clone if you need to preserve it.