TweetStream: Use the Twitter Streaming API from Ruby
A couple of weeks ago, popular micro-blogging service Twitter unveiled a beta "streaming API." Twitter's nature means they get hammered with polling requests so they've begun to experiment with the concept of streaming relevant data within a single HTTP request (in a Comet style). TweetStream (or GitHub repo) is a new Ruby library by Michael Bleigh to handle interacting with Twitter streams from Ruby.
TweetStream is available as a gem from both GitHub and Gemcutter (which, incidentally, got a fresh design today) and installation instructions are given in Michael's blog post about TweetStream. Once you're all installed, though, reading the live stream becomes as simple as:
require 'tweetstream' TweetStream::Client.new(TWITTER_USERNAME, TWITTER_PASSWORD).sample do |status| puts "[#{status.user.screen_name}] #{status.text}" end
Beyond basic functions, though, TweetStream also include daemonization features that allow you to create scripts that run in the background "out of the box." You could add these features yourself with the daemons library, sure, but having this at hand to quickly throw together Twitter scripts is pretty cool.
Other related stuff: If you're more interested in using Twitter from Ruby generally, check out John Nunemaker's Twitter library. If you want to build a Twitter bot in Ruby, check out Twibot. And, lastly, if you just want to follow some Rubyists on Twitter, check out Satish Talim's list of 50+ Rubyists to Follow on Twitter.
[ad] Time Tracking without Timers: Lapsus runs in the background and knows what project you're working on. Find out how long that last project took without the hassle of updating a timer. Watch the screencast or sign up for the Beta.