Sha256: 6626ed59bc7385925a6d0204e60b6895bd2b2ef915e9eb62efb9e4aeaeaa1e36

Contents?: true

Size: 1.16 KB

Versions: 11

Compression:

Stored size: 1.16 KB

Contents

require 'daemons'

# A daemonized TweetStream client that will allow you to
# create backgroundable scripts for application specific
# processes. For instance, if you create a script called
# <tt>tracker.rb</tt> 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.
#
class TweetStream::Daemon < TweetStream::Client
  # 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.
  def initialize(user, pass, app_name=nil)
    @app_name = app_name
    super(user, pass)
  end
  
  def start(path, query_parameters = {}, &block) #:nodoc:
    Daemons.run_proc(@app_name || 'tweetstream', :multiple => true) do
      super(path, query_parameters, &block)
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
intridea-tweetstream-0.1.3 lib/tweetstream/daemon.rb
intridea-tweetstream-0.1.4 lib/tweetstream/daemon.rb
intridea-tweetstream-0.1.5 lib/tweetstream/daemon.rb
tweetstream-0.3.0 lib/tweetstream/daemon.rb
tweetstream-0.1.9 lib/tweetstream/daemon.rb
tweetstream-0.1.8 lib/tweetstream/daemon.rb
tweetstream-0.1.7 lib/tweetstream/daemon.rb
tweetstream-0.1.5 lib/tweetstream/daemon.rb
tweetstream-0.1.4 lib/tweetstream/daemon.rb
tweetstream-0.1.3 lib/tweetstream/daemon.rb
tweetstream-0.1.2 lib/tweetstream/daemon.rb