<commit_before># 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]

[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

TweetStream provides simple Ruby access to [Twitter's Streaming API](https://dev.twitter.com/docs/streaming-api).

**Note:** TweetStream does not currently work with Ruby 2.0, this is a [known issue](https://github.com/intridea/tweetstream/issues/117).

## Installation

    gem install tweetstream

## Usage

Using TweetStream is quite simple:

```ruby
require 'tweetstream'

TweetStream.configure do |config|
  config.consumer_key       = '<KEY>'
  config.consumer_secret    = '0123456789'
  config.oauth_token        = '<KEY>'
  config.oauth_token_secret = '0123456789'
  config.auth_method        = :oauth
end

# This will pull a sample of all tweets based on
# your Twitter account's Streaming API role.
TweetStream::Client.new.sample do |status|
  # The status object is a special Hash with
  # method access to its keys.
  puts "#{status.text}"
end
```

You can also use it to track keywords or follow a given set of
user ids:

```ruby
# Use 'track' to track a list of single-word keywords
TweetStream::Client.new.track('term1', 'term2') do |status|
  puts "#{status.text}"
end

# Use 'follow' to follow a group of user ids (integers, not screen names)
TweetStream::Client.new.follow(14252, 53235) do |status|
  puts "#{status.text}"
end
```

The methods available to TweetStream::Client are kept in parity
with the methods available on the Streaming API wiki page.

## Changes in 2.0

TweetStream 2.0 introduces a number of requested features and bug fixes. For
the complete list refer to the [changelog](CHANGELOG.md#version-200). Notable
additions in 2.0 include:

### OAuth

OAuth is now the default authentication method.  Both userstreams and Site
Streams exclusively work with OAuth.  TweetStream still supports Basic Auth,
however it is no longer the default.  If you are still using Basic Auth, you
should plan to move to OAuth as soon as possible.

### Site Stream Support

Site Streams are now fully supported, including the connection management functionality.

### Compatablity 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`.
3. Allows boolean methods to be called with a question mark (e.g.
   `User#protected?`)

Additionally, any new features that are added to objects in the
`twitter` gem (e.g. identity map) will be automatically inherited by TweetStream.

### em-twitter<commit_msg>fix typo in README, fixes #130<commit_after># 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]

[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

TweetStream provides simple Ruby access to [Twitter's Streaming API](https://dev.twitter.com/docs/streaming-api).

**Note:** TweetStream does not currently work with Ruby 2.0, this is a [known issue](https://github.com/intridea/tweetstream/issues/117).

## Installation

    gem install tweetstream

## Usage

Using TweetStream is quite simple:

```ruby
require 'tweetstream'

TweetStream.configure do |config|
  config.consumer_key       = '<KEY>'
  config.consumer_secret    = '0123456789'
  config.oauth_token        = '<KEY>'
  config.oauth_token_secret = '0123456789'
  config.auth_method        = :oauth
end

# This will pull a sample of all tweets based on
# your Twitter account's Streaming API role.
TweetStream::Client.new.sample do |status|
  # The status object is a special Hash with
  # method access to its keys.
  puts "#{status.text}"
end
```

You can also use it to track keywords or follow a given set of
user ids:

```ruby
# Use 'track' to track a list of single-word keywords
TweetStream::Client.new.track('term1', 'term2') do |status|
  puts "#{status.text}"
end

# Use 'follow' to follow a group of user ids (integers, not screen names)
TweetStream::Client.new.follow(14252, 53235) do |status|
  puts "#{status.text}"
end
```

The methods available to TweetStream::Client are kept in parity
with the methods available on the Streaming API wiki page.

## Changes in 2.0

TweetStream 2.0 introduces a number of requested features and bug fixes. For
the complete list refer to the [changelog](CHANGELOG.md#version-200). Notable
additions in 2.0 include:

### OAuth

OAuth is now the default authentication method.  Both userstreams and Site
Streams exclusively work with OAuth.  TweetStream still supports Basic Auth,
however it is no longer the default.  If you are still using Basic Auth, you
should plan to move to OAuth as soon as possible.

### Site Stream Support

Site Streams are now fully supported, including the connection management functionality.

### 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`.
3. Allows boolean methods to be called with a question mark (e.g.
   `User#protected?`)

Additionally, any new features that are added to objects in the
`twitter` gem (e.g. identity map) will be automatically inherited by TweetStream.

### em-twitter
{'fraction_non_alphanumeric': 0.11091549295774648, 'fraction_numerical': 0.014818075117370893, 'mean_word_length': 4.757601351351352, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 24, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6996384', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2100, 'n_words': 726}