Sorry this page looks weird. It was automatically migrated from my old blog, which had a different layout and different CSS.

The Rails Toolbox

The Goal

Inspired by The Ruby Toolbox, I wanted to construct a Rails Toolbox. The Ruby Toolbox mines GitHub, rating the tools by the number of watchers and forks; how to do something similar for Rails?

The Method

First of all we need to define what counts as a Rails tool. I’m saying plugins and gems.

Second, we need to find out which plugins and gems people have installed in their Rails apps. Here we make use of a handy feature introduced in Rails 2.3: Rails Application Templates. These templates are scripts which let you customise a new Rails application, and crucially they have these three attributes:

So all we need to do is mine GitHub for these templates, hammer through them, and tot up the plugins and gems they use.

The Code

I wrote some code to do this. It uses John Nunemaker’s HTTParty to wrap GitHub’s API, or at least the parts I needed.

This was the first time I’ve used HTTParty and I liked it a lot. I haven’t got up and running with someone else’s code so quickly for ages. As an aside, I think it’s supposed to be “HTTP-party” but I prefer “HTTP-arty”.

The Results

I would love to build a website for you as shiny as The Ruby Toolbox’s. But not quite enough to actually do it. You’ll have to settle for two lists.

There’s also one small caveat to bear in mind but I’ll come to that later.

Top 33 Gems

Top 40 Plugins

Caveat

These results are based on the first 30 repositories returned by GitHub’s API; The GUI returns 243 results. If anyone know hows to get the next 30 (and the 30 after, etc), please let me know in the comments. Thanks ;)

Update: this is a known shortcoming. There’s not much we can do until it’s fixed.

Discussion

We can’t reach any statistically significant conclusions about the popularity of Rails plugins and gems: with only 30 repositories out of 243 we do not have a sufficiently powerful sample. Also none of mine are showing up in the results so the data must be incomplete.

We can mine all the data we need to build a complete recommendation system. Rails' plugin installer and gem-installing Rake task could be beefed up like this:

  $ script/plugin install git://github.com/technoweenie/restful-authentication.git
  [...Git stuff...]
  People who installed restful-authentication were also interested in authlogic.
  Would you like to try authlogic instead (y/n)?
  $ y
  Uninstalling restful-authentication...
  Installing authlogic...
  [...Git stuff...]

Of course not all Rails app template creators are going to choose the same plugins and gems as you. The recommendation system could incorporate some Bayesian mathematics or a neural network to learn your predilections and adapt. I see a great future for this. Somebody should get right on it.

Conclusion

The mining method seems sound, though, and the code works. All we need now is a shiny website!

Andrew Stewart • 5 June 2009 • Rails
You can reach me by email or on Twitter.