<commit_before>twitter-with-auto-pagination
============================

[![Gem Version](https://badge.fury.io/rb/ex_twitter.png)](https://badge.fury.io/rb/twitter_with_auto_pagination)
[![Build Status](https://travis-ci.org/ts-3156/ex-twitter.svg?branch=master)](https://travis-ci.org/ts-3156/twitter-with-auto-pagination)

Add auto paginate feature to Twitter gem.

## Installation

### Gem

```
gem install twitter_with_auto_pagination
```

### Rails

Add `twitter_with_auto_pagination` to your Gemfile, and bundle.

## Features

* Auto paginate feature

## Configuration

You can pass configuration options as a block to `TwitterWithAutoPagination::Client.new` just like `Twitter::REST::Client.new`.

```
client = TwitterWithAutoPagination::Client.new do |config|
  config.consumer_key        = "YOUR_CONSUMER_KEY"
  config.consumer_secret     = "YOUR_CONSUMER_SECRET"
  config.access_token        = "YOUR_ACCESS_TOKEN"
  config.access_token_secret = "YOUR_ACCESS_SECRET"
  config.log_level           = :debug             # optional
  config.logger              = Logger.new(STDOUT) # optional
end
```

## Usage Examples

### Existing API

```
tweets = client.user_timeline

tweets.size
# => 588

tweet = tweets.first
tweet.text
# => "Your Tweet..."

tweet.user.screen_name
# => "your_screen_name"
```

```
tweets = client.home_timeline
tweets.size
# => 475
```

```
tweets = client.mentions_timeline
tweets.size
# => xxx
```

```
friend_ids = client.friend_ids
friend_ids.size
# => 350
```

```
follower_ids = client.follower_ids
follower_ids.size
# => 928
```

```
friends = client.friends
friends.size
# => 350
```

```
followers = client.followers
followers.size
# => 928
```

```
tweets = client.favorites
favorites.size
# => xxx
```

```
tweets = client.search('twitter')
tweets.size
# => xxx
```

```
users = client.users(['screen_name_1', 'sn_2', 'sn_3'])
users.size
# => 3
```

### New API

```
mutual_friends = client.mutual_friends
mutual_friends.size
# => xxx
```

```
one_sided_friends = client.one_sided_friends
one_sided_friends.size
# => xxx
```

```
one_sided_followers = client.one_sided_followers
one_sided_followers.size
# => xxx
```

Users which authorized user removed.

```
users = client.removed(pre_me, cur_me)
users.size
# => xxx
```

Users which authorized user is removed by.

```
users = client.removed_by(pre_me, cur_me)
users.size
# => xxx
```<commit_msg>modify README<commit_after>twitter-with-auto-pagination
============================

[![Gem Version](https://badge.fury.io/rb/ex_twitter.png)](https://badge.fury.io/rb/twitter_with_auto_pagination)
[![Build Status](https://travis-ci.org/ts-3156/ex-twitter.svg?branch=master)](https://travis-ci.org/ts-3156/twitter-with-auto-pagination)

Add auto pagination, auto caching and parallelly fetching features to Twitter gem.

## Installation

### Gem

```
gem install twitter_with_auto_pagination
```

### Rails

Add `twitter_with_auto_pagination` to your Gemfile, and bundle.

## Features

* Auto pagination
* Auto caching
* Parallelly fetching

## Configuration

You can pass configuration options as a block to `TwitterWithAutoPagination::Client.new` just like `Twitter::REST::Client.new`.

```
client = TwitterWithAutoPagination::Client.new do |config|
  config.consumer_key        = "YOUR_CONSUMER_KEY"
  config.consumer_secret     = "YOUR_CONSUMER_SECRET"
  config.access_token        = "YOUR_ACCESS_TOKEN"
  config.access_token_secret = "YOUR_ACCESS_SECRET"
  config.log_level           = :debug             # optional
  config.logger              = Logger.new(STDOUT) # optional
end
```

## Usage Examples

After configuring a `client`, you can do the following things.

### Pre-existing and enhanced APIs

Fetch the timeline of Tweets (by screen name or user ID, or by implicit authenticated user)

```
client.user_timeline('gem')
client.user_timeline(213747670)
client.user_timeline

result.size
# => 588

result.first.text
# => "Your tweet text..."

result.first.user.screen_name
# => "your_screen_name"
```

Fetch the timeline of Tweets from the authenticated user's home page

```
client.home_timeline
```

Fetch the timeline of Tweets mentioning the authenticated user

```
client.mentions_timeline
```

Fetch all friends's user IDs (by screen name or user ID, or by implicit authenticated user)

```
client.friend_ids('gem')
client.friend_ids(213747670)
client.friend_ids
```

Fetch all followers's user IDs (by screen name or user ID, or by implicit authenticated user)

```
client.follower_ids('gem')
client.follower_ids(213747670)
client.follower_ids
```

Fetch all friends with profile details (by screen name or user ID, or by implicit authenticated user)

```
client.friends('gem')
client.friends(213747670)
client.friends
```

Fetch all followers with profile details (by screen name or user ID, or by implicit authenticated user)

```
client.followers('gem')
client.followers(213747670)
client.followers
```

Other APIs(e.g. `favorites`, `search`) also have auto pagination feature. 

### New APIs

```
client.mutual_friends
```

```
client.one_sided_friends
```

```
client.one_sided_followers
```

```
client.common_friends(me, you)
```

```
client.common_followers(me, you)
```

```
client.close_friends
```

```
client.removed(pre_me, cur_me)
```

```
client.removed_by(pre_me, cur_me)
```

```
client.replied
```

```
client.replied_by
```
{'fraction_non_alphanumeric': 0.14886066492342173, 'fraction_numerical': 0.016062756817332834, 'mean_word_length': 4.678685047720043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 8, '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': '2783678', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1820, 'n_words': 390}