🕷 software projects

by ryan davis



sitemap

ruby2ruby

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 Code

If you just want to use ruby2ruby, you can install it via RubyGems:
gem install ruby2ruby
Fork me on GitHub If you want to hack on ruby2ruby, clone it from GitHub:
git clone git://github.com/seattlerb/ruby2ruby

Latest Activity