The rubyforge gem and the RubyForge REST API

22 Sep 2009

Yesterday Ryan Davis and I released v2.0.0 of the "rubyforge" gem. The big change for this version is that it no longer interacts with RubyForge by scraping HTML; instead, it uses the new RubyForge REST API. So instead of POST'ing a form to login and fetch your project list, it uses HTTP Basic authentication and hits /users/zenspider/groups.js.

If you're using the new gem, you may see this when you run rubyforge config:

$ rubyforge config
/Library/Ruby/Gems/1.8/gems/json-1.1.7/lib/json/common.rb:122:in `parse': 
618: unexpected token at '<?xml version="1.0" encoding="UTF-8"?> (JSON::ParserError)
<!DOCTYPE html
[ ... lots more ... ]

That's happening because your ~/.rubyforge/user-config.yml file is telling the rubyforge gem to hit https://rubyforge.org, and it needs to hit http://api.rubyforge.org instead. To fix that, either run rubyforge setup, or just edit your ~/.rubyforge/user-config.yml and change the uri setting.

I'm happy to have a REST API for RubyForge available; this has been in the works for a few months and I hope folks come up with some interesting ways to use it. It's certainly much easier (and much more efficient) than the old way of using Mechanize or whatever to parse the HTML. Not all the RubyForge resources are available yet, so if you want to access something and don't see it in the API please let me know and I'll add it. The code is here and feedback is of course welcome. Enjoy!