coderrr

January 4, 2009

Where the hell did .to_ruby go?

Filed under: ruby — Tags: — coderrr @ 5:33 pm

Back in the day, all I had to do was require 'rubygems'; require 'ruby2ruby' and then all my Method and Proc objects would have a nice .to_ruby method to convert them into a string representation of the code.

At some point (I’m told this happened quite a while ago) ParseTree and ruby2ruby got modified so it’s not that simple anymore. When I reinstalled my gems and got the latest version of both libraries some of my old code no longer worked.

To get your .to_ruby methods you now must do:

require 'rubygems'
require 'parse_tree'
require 'parse_tree_extensions'
require 'ruby2ruby'

Note the versions I am using are:

ParseTree (3.0.2)
ruby2ruby (1.2.1)

Hope this saves someone some time.

3 Comments »

  1. Found the same thing, however, .to_ruby shows an incorrect string representation:

    >> eval lambda { |v| v * 2 }.to_ruby
    SyntaxError: (eval):1:in `irb_binding’: compile error
    (eval):1: syntax error, unexpected ‘|’, expecting tCOLON2 or ‘[‘ or ‘.’
    proc { |(v)| (v * 2) }
    ^
    (eval):1: syntax error, unexpected ‘}’, expecting $end
    proc { |(v)| (v * 2) }
    ^
    from (irb):7
    from (irb):7
    >>

    Comment by Lawrence Pit — January 10, 2009 @ 7:00 am

  2. Appears to be a known bug since a couple of months:

    http://rubyforge.org/tracker/index.php?func=detail&aid=22645&group_id=439&atid=1778

    Comment by Lawrence Pit — January 10, 2009 @ 7:18 am

  3. thanks for this, I updated the Ruby2Ruby gems and also couldn’t figure out where the the hell the #to_ruby method went which was used a lot in our system.

    Comment by yawningman — October 28, 2009 @ 8:00 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.