HTTP wrappers with ease

httparty looks really cool. It’s a little library for making writing tiny REST clients easier. From the examples (edited for length):

class Twitter
  include HTTParty
  base_uri ''

  def initialize(user, pass)
    self.class.basic_auth user, pass

  # which can be :friends, :user or :public
  # options[:query] can be things like since, since_id, count, etc.
  def timeline(which=:friends, options={})
    self.class.get("/statuses/#{which}_timeline.xml", options)['statuses'].map { |s| s.to_struct }

twitter ='', 'bobtime')

twitter.timeline.each do |s|
  puts, s.text, "#{s.created_at} #{}", ''

Great job, John!

One response to “HTTP wrappers with ease”

  1. Thanks! I thought it was cool but I’m amazed by the community response. Evidentally everyone was feeling the pain I was. :)