Ripper2Ruby: modify and recompile your Ruby code

posted: July 5th, 2009 · by: Sven

in: Programming · tagged as: , ·  16 comments »

Ripper is a Ruby parser that ships with Ruby 1.9. Ripper2Ruby is a library that generates a representation of Ruby code which you can modify and/or compile back to Ruby.

So, the combination Ripper/Ripper2Ruby lets you do similar things as you can do with ParseTree or RubyParser and Ruby2Ruby. The differences are:

  • Ripper requires Ruby 1.9 (I was told it possibly could be compiled to work with Ruby 1.8.x but I don’t know anything further. Please drop me a note if you know how to do this.)
  • Ripper2Ruby builds a full object-oriented representation of Ruby code. That means you can modify the representation much more easily compared to the rough sexp tree that you get from the parsers. It also provides complete information about the node’s original source position, whitespace, comments etc.
  • Therefor with Ripper2Ruby you can recompile the exact copy of the original source code, character by character (that’s not possible with Ruby2Ruby). Ripper2Ruby has been tested with 225 Ruby libraries including Rails, Merb, Ruby Stdlib etc.
  • Ripper2Ruby does more but it’s slower, too.

For example:

src = "I18n.t(:foo)"
code =
code.to_ruby # => "I18n.t(:foo)"

foo =
foo.identifier.token = 'bar'
code.to_ruby # => "I18n.t(:bar)"

Ripper2Ruby was build to make it easier to create refactoring tools for Ruby/Rails I18n support (see i18n-tools). Huge thanks go (again) to Torsten Becker, Bestgroup Software & Consulting for making this possible.

Leave a comment


  1. jack said January 23rd, 2011 at 10:31 AM  

    I must admit that today is my first time I visit here. However, I have found so many interesting thing in your blog and I really love that. Keep up the good work! cheap vps

  2. sherzad said February 1st, 2011 at 01:27 AM  

    src = “I18n.t(:foo)”code = # => “I18n.t(:foo)”foo = = ‘bar’code.toruby # => “I18n.t(:bar)”

  3. QQQ said February 7th, 2011 at 06:33 PM  

    Finally we kissed and the passion scale went sky high and I knew I was onto a good thing - sex was a certainty free porn videos. She never hesitated when I began to fondle her breasts and she willingly exposed them for me mobile porn. They were firm and I suspected a breast enhancement but said nothing - they still felt good and I was enjoying them and gradually working my way further south free porn tube. She was a step ahead of me and before I could completely undress her she moved on me atk hairy and I was suddenly having my pants pulled down and I was enjoying one of he best cock sucking hairy pussy experiences I had ever had. ABB728019394

  4. ddsgd said March 21st, 2011 at 06:29 AM  

    How to Convert AVCHD films to AVI

    URL? Troubles we may possibly have encountered to take satisfaction in and reveal AVCHD films with friends:

    1. You have shot lots of films utilizing AVCHD camcorder, and you also need to upload these films to internet that consist of Youtube to reveal with friends, but you can’t determine the right way to create it.
    2. you could possibly also uncover which you would not possess the ability to available your AVCHD camcorder films on house windows film maker or advertising player.

    That’s true, the AVCHD structure is not accepted by lots of players, and also this kind of structure cannot be uploaded to internet which prevents film sharing. I’ve searched near to some great offer and uncover an simplest alternative finally. The simplest way can be to convert avchd to avi or other standard formats.

    The alternative we are able to consider to solve them: An AVCHD to AVI Converter is needed. Please click to obtain avchd to avi converter, set up and run it. Step one Get AVCHD films from AVCHD Camcorder to PC

    Connect the AVCHD Camcorder for the PC using a USB cable. when attached and powered on, the camcorder should seek out the desktop like a brand brand new disk. It is desirable which you duplicate the films for the PC’s hard-drive earlier to converting avchd to avi or editing it. Step 2. fill AVCHD camcorder videos

    Click “Add Video” or just drag & squirrel away your AVCHD camcorder films using the document checklist directly, you can very easily include AVCHD camcorder videos.

    Load AVCHD camcorder videos Step 3. find AVI as output format

    Select AVI as output structure away from your categorized output formats checklist in “Profile” drop-down checklist and specify the output list to preserve your converted records in “Output” drop-down list.

    Select Convert AVCHD films to AVI output format Step 4. start to convert avchd to avi

    After every little thing is done, strike “Start” key to convert avchd to avi. And all the things can be achieved at quickly demand and higher quality. The conversion demand often is dependent for the genuine film sizing as well as your PC configuration. as well as the output best quality is great.

    After converting avchd to avi, now you can upload these AVI films to internet or view them with house windows advertising Player/Movie Maker to reveal them jointly with your friends. The complete method is easy, and you also can possess a try of the AVCHD to AVI Converter to how to convert avchd to avi and reveal your delighted instant easily.

    Tips: Why we choose AVI format? As we realize that AVI structure is among the probably the most standard formats, that is broadly accepted by the majority of players. as well as the best quality of AVI film is great. using the sake of reputation and compatibility, AVI is regarded as probably the most advantageous choice. Therefore, you only should convert AVCHD to AVI, after which you can very easily reveal your AVCHD camcorder videos.

  5. Brazilian Butt Lift Workout said March 30th, 2011 at 04:53 PM  

    Sounds interesting, one thing I really like about it are the full information being provided. Keep it up! Thanks for sharing your informative article.

  6. Cams said March 30th, 2011 at 07:46 PM  

    I used the following code that worked well as a fix:

    src = “I18n.t(:foo)” code = code.to_ruby # => “I18n.t(:foo)”

    foo = foo.identifier.token = ‘bar’ code.to_ruby # => “I18n.t(:bar)”

  7. Vasomotor Rhinitis said April 1st, 2011 at 06:33 AM  

    Your post are nicely written, and it contains many useful facts. I am glad I found your site, you make me easily understand your post because it written clearly. Thanks for sharing this informative article.

  8. Stop Oily Skin said April 4th, 2011 at 07:27 AM  

    Nicely written article, Knowledgeable and informative post. I’m really glad I came my way along your site. Keep posting, I really like the whole topic. Thanks for sharing.

  9. side sleeper pillow said April 22nd, 2011 at 06:58 AM  

    Nicely written article, Knowledgeable and informative post. I’m really glad I came my way along your site. Keep posting, I really like the whole topic. Thanks for sharing.

  10. lilies flowers said April 28th, 2011 at 02:05 PM  

    Very informative post thanks for share this with us i highly appreciate you for this information thanks once again for sharing information like this!

  11. Kankakee IL said April 29th, 2011 at 08:58 AM  

    This is a nice blog and very informative. Keep up the good work and Thanks for sharing

  12. Kent Jobs said May 11th, 2011 at 07:51 AM  

    This is useful post, I can use this for my future use. Thanks for sharing

  13. Okey oyunu said May 12th, 2011 at 03:34 PM  

    Tüm dünya artik okey oyunu oynuyor. Yillardir bir çok oyun programi olmasina ragmen, içlerinden en güzeli olarak nitelendirebilecegimiz tek bir site göze çarpmaktadir. Diger tüm okey oyunu programlarinin aksine ücretsiz olmasi ve 3 boyutlu olarak hizmet vermesi mükemmel bir gelismedir. Sizlerde www. adresinden bu essiz okey oyununu indirebilirsiniz. Kullanimi çok basit ve Türkçe dil seçenegi ile kolaylikla oyuna baslayabilirsiniz. Ister kendi ülkenizden, isterseniz dünyanin tüm farkli bölgelerinden dilediginiz oyun odalarini seçerek, oyuna hemen baslayabilirsiniz. Okey oyunu oynamak için artik arkadas bile aramaniza gerek kalmadan, bilgisayarinizdan 100 binlerce üye ile online olarak okey oyununu oynamanin zevkine varabilirsiniz.

  14. p said May 21st, 2011 at 05:05 PM  

    chaussures nike lunarhaze+ white black red [cn3340] - €49.99 : nike tn,requin tn,tn nike,tn requin,nike requin,basket tn,chaussures tn
    nike tn,requin tn,tn nike,tn requin,nike bw,basket tn,chaussures tn : nike free 3.0 3 - Kvinner sko Menn sk
    Nous avons une satisfaction garantie à 100%. Si vous n’êtes pas satisfait avec votre produit dans les 365 jours suivant la réception vous pouvez l’envoyer de nouveau à nous pour un remboursement complet.

    Il est 24 heures période de traitement une fois le paiement re?u. Une fois que les chaussures sont expédiée, vous recevrez un email de notre part avec numéro de suivi afin que vous mai suivre votre commande. Vous aurez vos produits dans 3-5 jours d’affaires (sans compter les week-ends ou jours fériés). La plupart des commandes sont traitées et re?ues par les clients dans les 3 jours.

  15. porno said May 23rd, 2011 at 10:52 AM  

    I do agree with all of the ideas you have presented in your post. They’re really convincing and will definitely work. Still, the posts are too short for newbies. Could you please extend them a bit from next time? Thanks for the post.

  16. porno said May 23rd, 2011 at 10:53 AM  

    good comment. thanks you friends.

    I’ve surfed the net more than three hours today, however, I haven’t found such useful information. Thanks a lot, it is really useful to me

Sorry, comments are closed for this article.

artweb design
Sven Fuchs
Grünberger Str. 65
10245 Berlin, Germany

Fon +49 (30) 47 98 69 96
Fax +49 (30) 47 98 69 97