Class: TweetStream::Daemon

Inherits:
Client
  • Object
show all
Defined in:
lib/tweetstream/daemon.rb

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::Daemon.new('user','pass', '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.

Instance Attribute Summary

Attributes inherited from Client

#access_key, #access_secret, #consumer_key, #consumer_secret, #parser

Instance Method Summary collapse

Methods inherited from Client

#filter, #firehose, #follow, #locations, #on_delete, #on_error, #on_limit, #retweet, #sample, #site_follow, #stop, #track

Constructor Details

#initialize(consumer_key, consumer_secret, access_key, access_secret, app_name = nil, parser = :json_gem) ⇒ Daemon

Initialize a Daemon with the credentials of the Twitter account you wish to use. The daemon has an optional process name for use when querying running processes.



29
30
31
32
# File 'lib/tweetstream/daemon.rb', line 29

def initialize(consumer_key, consumer_secret, access_key, access_secret, app_name=nil, parser=:json_gem)
  @app_name = app_name
  super(consumer_key, consumer_secret, access_key, access_secret, parser)
end

Instance Method Details

#start(path, query_parameters = {}, &block) ⇒ Object

:nodoc:



34
35
36
37
38
# File 'lib/tweetstream/daemon.rb', line 34

def start(path, query_parameters = {}, &block) #:nodoc:
  Daemons.run_proc(@app_name || 'tweetstream', :multiple => true) do
    super(path, query_parameters, &block)
  end
end