Skip to content

Commit

Permalink
Initial checkin of Tweeter Keeper ruby tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflinwood committed May 28, 2011
1 parent 2b2caec commit 2f0c19d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Tweeter Keeper is built on top of other people's work - I didn't see any reason to reinvent the wheel.

TweetStream gem - reads tweets off of Twitter's streaming API and provides a Ruby block with the tweets.

Twitter gem - for use with the other Twitter API's - use to get followers for a user, user's tweet timeline, etc. We can use this to backfill in the history for users we follow on the streaming side. Some methods on this will require OAuth authentication

MongoDB - NoSQL database that uses BSON (similar to JSON) for inserting and retrieving data, making it easy to dump data directly from Twitter without processing.

Mongo gem - Use the Mongo Ruby Driver directly, instead of an abstraction library

Install
=============

Environment - requires Ruby and MongoDB.

gem install tweetstream
gem install twitter
gem install mongo


23 changes: 23 additions & 0 deletions tweeter-keeper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rubygems'
require 'tweetstream'
require 'mongo'

#set up a connection to a local MongoDB
@db = Mongo::Connection.new.db("tweeterkeeper")

#all tweets will be stored in a collection called tweets
@tweets = @db.collection("tweets")

@tracking_keywords = Array['drupal','mongodb','three20'];

@client = TweetStream::Client.new('USERNAME','PASSWORD')

@client.on_delete do |status_id, user_id|
puts "Removing #{status_id} from storage"
@tweets.remove({"status" => status_id})
end

@client.track(*@tracking_keywords) do |status|
puts "#{status.text}"
@tweets.insert(status)
end

0 comments on commit 2f0c19d

Please sign in to comment.