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!

Published by Adam Keys

Telling a joke. Typing.

One reply on “HTTP wrappers with ease”

Comments are closed.