Class: TweetStream::Daemon
Overview
A daemonized TweetStream client that will allow you to create backgroundable scripts for application specific processes. For instance, if you create a script called tracker.rb and fill it with this:
require 'rubygems'
require 'tweetstream'
TweetStream.configure do |config|
config.consumer_key = 'abcdefghijklmnopqrstuvwxyz'
config.consumer_secret = '0123456789'
config.oauth_token = 'abcdefghijklmnopqrstuvwxyz'
config.oauth_token_secret = '0123456789'
config.auth_method = :oauth
end
TweetStream::Daemon.new('tracker').track('intridea') do |status|
# do something here
end
And then you call this from the shell:
ruby tracker.rb start
A daemon process will spawn that will automatically run the code in the passed block whenever a new tweet matching your search term ('intridea' in this case) is posted.
Constant Summary
- DEFAULT_NAME =
'tweetstream'.freeze
- DEFAULT_OPTIONS =
{ :multiple => true }
Instance Attribute Summary (collapse)
-
- (Object) app_name
Returns the value of attribute app_name.
-
- (Object) daemon_options
Returns the value of attribute daemon_options.
Attributes inherited from Client
Instance Method Summary (collapse)
-
- (Daemon) initialize(name = DEFAULT_NAME, options = DEFAULT_OPTIONS)
constructor
The daemon has an optional process name for use when querying running processes.
-
- (Object) start(path, query_parameters = {}, &block)
:nodoc:.
Methods inherited from Client
#close_connection, #connect, #filter, #firehose, #follow, #links, #locations, #on_anything, #on_delete, #on_direct_message, #on_error, #on_inited, #on_limit, #on_reconnect, #on_scrub_geo, #on_timeline_status, #retweet, #sample, #sitestream, #stop, #stop_stream, #track, #userstream
Constructor Details
- (Daemon) initialize(name = DEFAULT_NAME, options = DEFAULT_OPTIONS)
The daemon has an optional process name for use when querying running processes. You can also pass daemon options.
41 42 43 44 45 |
# File 'lib/tweetstream/daemon.rb', line 41 def initialize(name = DEFAULT_NAME, = DEFAULT_OPTIONS) @app_name = name @daemon_options = super({}) end |
Instance Attribute Details
- (Object) app_name
Returns the value of attribute app_name
37 38 39 |
# File 'lib/tweetstream/daemon.rb', line 37 def app_name @app_name end |
- (Object) daemon_options
Returns the value of attribute daemon_options
37 38 39 |
# File 'lib/tweetstream/daemon.rb', line 37 def @daemon_options end |
Instance Method Details
- (Object) start(path, query_parameters = {}, &block)
:nodoc:
47 48 49 50 51 |
# File 'lib/tweetstream/daemon.rb', line 47 def start(path, query_parameters = {}, &block) #:nodoc: Daemons.run_proc(@app_name, @daemon_options) do super(path, query_parameters, &block) end end |