From b6170127365b3074922940fef2cdc6d8ebd72d30 Mon Sep 17 00:00:00 2001 From: Philip Poots Date: Tue, 29 Jan 2013 13:46:21 +0000 Subject: [PATCH] Extract TweetStream configuration --- config/tweetstream.rb | 20 ++++++++++++++++++++ sentinel.rb | 20 +------------------- 2 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 config/tweetstream.rb diff --git a/config/tweetstream.rb b/config/tweetstream.rb new file mode 100644 index 0000000..f24472f --- /dev/null +++ b/config/tweetstream.rb @@ -0,0 +1,20 @@ +require 'tweetstream' + +# Patch TweetStream Daemon for Heroku +# See https://github.com/heroku-examples/tweetstream-example +class TweetStream::Daemon + def start(path, query_parameters = {}, &block) + startmethod = super.start + Daemons.run_proc(@app_name || 'tweetstream', :multiple => true, :no_pidfiles => true) do + startmethod(path, query_parameters, &block) + end + end +end + +TweetStream.configure do |config| + config.consumer_key = ENV['CONSUMER_KEY'] + config.consumer_secret = ENV['CONSUMER_SECRET'] + config.oauth_token = ENV['OAUTH_TOKEN'] + config.oauth_token_secret = ENV['OAUTH_TOKEN_SECRET'] + config.auth_method = :oauth +end diff --git a/sentinel.rb b/sentinel.rb index 3e3aab8..5deeac2 100644 --- a/sentinel.rb +++ b/sentinel.rb @@ -1,26 +1,8 @@ require 'rubygems' require 'bundler/setup' -require 'tweetstream' require File.dirname(__FILE__) + '/models/tweet' -# Patch TweetStream Daemon for Heroku -# See https://github.com/heroku-examples/tweetstream-example -class TweetStream::Daemon - def start(path, query_parameters = {}, &block) - startmethod = super.start - Daemons.run_proc(@app_name || 'tweetstream', :multiple => true, :no_pidfiles => true) do - startmethod(path, query_parameters, &block) - end - end -end - -TweetStream.configure do |config| - config.consumer_key = ENV['CONSUMER_KEY'] - config.consumer_secret = ENV['CONSUMER_SECRET'] - config.oauth_token = ENV['OAUTH_TOKEN'] - config.oauth_token_secret = ENV['OAUTH_TOKEN_SECRET'] - config.auth_method = :oauth -end +require File.dirname(__FILE__) + '/config/tweetstream' TweetStream::Daemon.new.track('#emberjs', "ember.js") do |status| status.urls.each do |url|