README.md in tweetstream-2.5.0 vs README.md in tweetstream-2.6.0

- old
+ new

@@ -1,18 +1,18 @@ # TweetStream [![Gem Version](https://badge.fury.io/rb/tweetstream.png)][gem] -[![Build Status](https://secure.travis-ci.org/intridea/tweetstream.png?branch=master)][travis] -[![Dependency Status](https://gemnasium.com/intridea/tweetstream.png?travis)][gemnasium] -[![Code Climate](https://codeclimate.com/github/intridea/tweetstream.png)][codeclimate] -[![Coverage Status](https://coveralls.io/repos/intridea/tweetstream/badge.png?branch=master)][coveralls] +[![Build Status](https://secure.travis-ci.org/tweetstream/tweetstream.png?branch=master)][travis] +[![Dependency Status](https://gemnasium.com/tweetstream/tweetstream.png?travis)][gemnasium] +[![Code Climate](https://codeclimate.com/github/tweetstream/tweetstream.png)][codeclimate] +[![Coverage Status](https://coveralls.io/repos/tweetstream/tweetstream/badge.png?branch=master)][coveralls] [gem]: https://rubygems.org/gems/tweetstream -[travis]: http://travis-ci.org/intridea/tweetstream -[gemnasium]: https://gemnasium.com/intridea/tweetstream -[codeclimate]: https://codeclimate.com/github/intridea/tweetstream -[coveralls]: https://coveralls.io/r/intridea/tweetstream +[travis]: http://travis-ci.org/tweetstream/tweetstream +[gemnasium]: https://gemnasium.com/tweetstream/tweetstream +[codeclimate]: https://codeclimate.com/github/tweetstream/tweetstream +[coveralls]: https://coveralls.io/r/tweetstream/tweetstream TweetStream provides simple Ruby access to [Twitter's Streaming API](https://dev.twitter.com/docs/streaming-api). ## Installation @@ -75,11 +75,11 @@ ### Site Stream Support Site Streams are now fully supported, including the connection management functionality. -### Compatablity with the Twitter gem +### Compatability with the Twitter gem TweetStream now emits objects from the [Twitter gem](https://github.com/sferik/twitter) instead of custom hashes. These objects are already defined in the `twitter` gem and are superior to the custom objects in the following ways: 1. Object equivalence (`#==` returns true if `#id`s are the same). 2. The `#created_at` method returns a `Date` instead of a `String`. @@ -335,9 +335,30 @@ end ``` If you put the above into a script and run the script with `ruby scriptname.rb`, you will see a list of daemonization commands such as start, stop, and run. + +A frequent use case is to use TweetStream along with ActiveRecord to insert new +statuses to a database. The library TweetStream uses the `daemons` gem for +daemonization which forks a new process when the daemon is created. After forking, +you'll need to reconnect to the database: + +```ruby +ENV["RAILS_ENV"] ||= "production" + +root = File.expand_path(File.join(File.dirname(__FILE__), '..')) +require File.join(root, "config", "environment") + +daemon = TweetStream::Daemon.new('tracker', :log_output => true) +daemon.on_inited do + ActiveRecord::Base.connection.reconnect! + ActiveRecord::Base.logger = Logger.new(File.open('log/stream.log', 'w+')) +end +daemon.track('term1') do |tweet| + Status.create_from_tweet(tweet) +end +``` ## Proxy Support TweetStream supports a configurable proxy: