Ruby Tuesday #17 : Ain’t no party like an HTTParty

This week, I noticed on RubyInside that there’s a new gem called HTTParty that simplifies calling APIs over HTTP. Since this is exactly what I have been doing with Twitter and SSDS I thought I’d have a look at it. First port of call is the example on RubyForge. There’s some more examples on github – the Twitter example is here.

The next step is to take the Twitter client I wrote before and refactor it to use HTTParty. Here’s the resulting code:

And it all works – apart from a few of the usual timeouts and grumbles from Twitter. Less code and simpler code. This time around I’m using pp (pretty-printer) to format the output – this gives a good view of what HTTParty is returning. My next step with HTTParty is to use it for the SSDS code I wrote.