Skip to content

Commit

Permalink
Merge pull request jefflinwood#1 from kristiankristensen/master
Browse files Browse the repository at this point in the history
Updated to use newest version of TwitterStream
  • Loading branch information
jefflinwood committed Oct 13, 2011
2 parents 384bfa8 + 66538e3 commit 1652c48
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source :gemcutter
gem 'tweetstream'
gem 'tweetstream', '>1.1'
gem 'mongo'
gem 'twitter'
gem 'bson_ext'
gem 'yajl-ruby'
13 changes: 8 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ GEM
faraday_middleware (0.6.5)
faraday (~> 0.6.0)
hashie (1.0.0)
http_parser.rb (0.5.1)
http_parser.rb (0.5.3)
mongo (1.3.1)
bson (>= 1.3.1)
multi_json (1.0.3)
multi_xml (0.2.2)
multipart-post (1.1.3)
rack (1.3.2)
simple_oauth (0.1.5)
tweetstream (1.0.4)
daemons
twitter-stream
tweetstream (1.1.1)
daemons (~> 1.1.2)
multi_json (~> 1.0.3)
twitter-stream (~> 0.1.14)
twitter (1.6.0)
faraday (~> 0.6.1)
faraday_middleware (~> 0.6.3)
Expand All @@ -35,12 +36,14 @@ GEM
eventmachine (>= 0.12.8)
http_parser.rb (~> 0.5.1)
simple_oauth (~> 0.1.4)
yajl-ruby (1.0.0)

PLATFORMS
ruby

DEPENDENCIES
bson_ext
mongo
tweetstream
tweetstream (> 1.1)
twitter
yajl-ruby
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Mongo gem - Use the Mongo Ruby Driver directly, instead of an abstraction librar

Yaml gem - Used for basic configuration tasks

Install
# Install
=============

Environment - requires Ruby and MongoDB.
Expand All @@ -19,7 +19,7 @@ gem install bundle
bundle install


Usage
# Usage
==============

To run, open up config.yaml and change the USERNAME and PASSWORD to your Twitter account's username and password.
Expand All @@ -37,7 +37,7 @@ Open up a mongo shell and take a look at all the tweets you've collected! For sa
> db.tweets.count();
2156

Future Plans
# Future Plans
================
Get keywords directly from a MongoDB collection
Follow users from a MongoDB collection
Expand Down
16 changes: 13 additions & 3 deletions tweeter-keeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require 'date'
require 'time'


config = YAML.load_file('config.yaml')

#set up a connection to a local MongoDB or MongoLab from Heroku
Expand All @@ -22,16 +21,27 @@
#all tweets will be stored in a collection
tweets = db.collection("tweets")

tracking_keywords = Array['aplusk'];
tracking_keywords = Array['bieber'];
follow_users = Twitter.friend_ids("jefflinwood").ids;

client = TweetStream::Client.new(config['username'],config['password'])
TweetStream.configure do |c|
c.username = config['username']
c.password = config['password']
c.auth_method = :basic
c.parser = :yajl
end

client = TweetStream::Client.new()

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

client.on_error do |message|
puts "Error received #{message}"
end

params = Hash.new;
params[:follow] = follow_users;
params[:track] = tracking_keywords;
Expand Down

0 comments on commit 1652c48

Please sign in to comment.