<commit_before>Storify Ruby Gem
================
This is a Ruby interface to the Storify REST-API.

Status
------
* Work-in-progress (expect updates)

Prerequisites
-------------
* Ruby 2.0
* Storify.gemspec dependencies
* Storify developer account and API key

TODO
----
* Continue with wrapping API calls
* Formatters for Story Content
* De-couple specs from actual API (i.e. WebMock)


Usage and documentation
-----------------------
To run the tests please ensure you have created a `.userkey.rb` file in the spec directory.
See the `.userkey.rb.sample` file for details.

Note: The Storify API currently requires a password to be entered for
authentication. Please ensure you perform this securely (as you do not want it
to appear in plaintext within your shell profile history or within your script).
The included specs demonstrate masking a password from shell history.


### Setup

Install the gem:
```bash
$ gem install storify
```

Include the `storify` gem in your script:
```ruby
require 'storify'
```


### Configuration

Pass the `Storify::Client` a configuration block when initialized:
```ruby
client = Storify::Client.new do |config|
  config.username = 'YOUR_USERNAME'
  config.api_key  = 'YOUR_API_KEY'
  config.token    = 'YOUR_AUTH_TOKEN (optional)'
end
```

Authenticate your `Storify::Client` to receive your `token` (password required):
```ruby
client.auth('<password>')
```

### Operations

The following operations have currently been implemented:

| Verb    | Operation                           | Paging  | Options | Method               |
| ------- | ----------------------------------- | :-----: | :-----: | -------------------- |
| `POST`  | `/auth`                             | `N/A`   | `YES`   | `client.auth`        |
| `POST`  | `/stories/:username/:slug/editslug` | `N/A`   | `YES`   | `client.edit_slug`   |
| `GET`   | `/stories`                          | `YES`   | `YES`   | `client.stories`     |
| `GET`   | `/stories/:username`                | `YES`   | `YES`   | `client.userstories` |
| `GET`   | `/stories/:username/:slug`          | `YES`   | `YES`   | `client.story`       |
| `GET`   | `/stories/browse/latest`            | `YES`   | `YES`   | `client.latest`      |
| `GET`   | `/stories/browse/featured`          | `YES`   | `YES`   | `client.featured`    |
| `GET`   | `/stories/browse/popular`           | `YES`   | `YES`   | `client.popular`     |
| `GET`   | `/stories/browse/topic/:topic`      | `YES`   | `YES`   | `client.topic`       |
| `GET`   | `/stories/search`                   | `YES`   | `YES`   | `client.search`      |
| `GET`   | `/users`                            | `YES`   | `YES`   | `client.users`       |
| `GET`   | `/users/:username`                  | `YES`   | `YES`   | `client.profile`     |


Example: Get a list of stories for a user
```ruby
stories = client.userstories('<any username>')
```

Example: Get an entire story for a user
```ruby
story = client.story('<story slug>','<any username>')
```

Example: Change a story slug and print new slug name
```ruby
puts client.edit_slug('<username>', '<old slug>', '<new slug>')
```

Example: Search for stories about startups (i.e. #startup)
```ruby
stories = client.search('<criteria>')
```

Example: Get a list of Storify Users
```ruby
users = client.users
```

Example: Get a user's profile
```ruby
user = client.profile('<any username>')
```<commit_msg>corrected paging setting for /users/:username<commit_after>Storify Ruby Gem
================
This is a Ruby interface to the Storify REST-API.

Status
------
* Work-in-progress (expect updates)

Prerequisites
-------------
* Ruby 2.0
* Storify.gemspec dependencies
* Storify developer account and API key

TODO
----
* Continue with wrapping API calls
* Formatters for Story Content
* De-couple specs from actual API (i.e. WebMock)


Usage and documentation
-----------------------
To run the tests please ensure you have created a `.userkey.rb` file in the spec directory.
See the `.userkey.rb.sample` file for details.

Note: The Storify API currently requires a password to be entered for
authentication. Please ensure you perform this securely (as you do not want it
to appear in plaintext within your shell profile history or within your script).
The included specs demonstrate masking a password from shell history.


### Setup

Install the gem:
```bash
$ gem install storify
```

Include the `storify` gem in your script:
```ruby
require 'storify'
```


### Configuration

Pass the `Storify::Client` a configuration block when initialized:
```ruby
client = Storify::Client.new do |config|
  config.username = 'YOUR_USERNAME'
  config.api_key  = 'YOUR_API_KEY'
  config.token    = 'YOUR_AUTH_TOKEN (optional)'
end
```

Authenticate your `Storify::Client` to receive your `token` (password required):
```ruby
client.auth('<password>')
```

### Operations

The following operations have currently been implemented:

| Verb    | Operation                           | Paging  | Options | Method               |
| ------- | ----------------------------------- | :-----: | :-----: | -------------------- |
| `POST`  | `/auth`                             | `N/A`   | `YES`   | `client.auth`        |
| `POST`  | `/stories/:username/:slug/editslug` | `N/A`   | `YES`   | `client.edit_slug`   |
| `GET`   | `/stories`                          | `YES`   | `YES`   | `client.stories`     |
| `GET`   | `/stories/:username`                | `YES`   | `YES`   | `client.userstories` |
| `GET`   | `/stories/:username/:slug`          | `YES`   | `YES`   | `client.story`       |
| `GET`   | `/stories/browse/latest`            | `YES`   | `YES`   | `client.latest`      |
| `GET`   | `/stories/browse/featured`          | `YES`   | `YES`   | `client.featured`    |
| `GET`   | `/stories/browse/popular`           | `YES`   | `YES`   | `client.popular`     |
| `GET`   | `/stories/browse/topic/:topic`      | `YES`   | `YES`   | `client.topic`       |
| `GET`   | `/stories/search`                   | `YES`   | `YES`   | `client.search`      |
| `GET`   | `/users`                            | `YES`   | `YES`   | `client.users`       |
| `GET`   | `/users/:username`                  | `N/A`   | `YES`   | `client.profile`     |


Example: Get a list of stories for a user
```ruby
stories = client.userstories('<any username>')
```

Example: Get an entire story for a user
```ruby
story = client.story('<story slug>','<any username>')
```

Example: Change a story slug and print new slug name
```ruby
puts client.edit_slug('<username>', '<old slug>', '<new slug>')
```

Example: Search for stories about startups (i.e. #startup)
```ruby
stories = client.search('<criteria>')
```

Example: Get a list of Storify Users
```ruby
users = client.users
```

Example: Get a user's profile
```ruby
user = client.profile('<any username>')
```
{'fraction_non_alphanumeric': 0.18192488262910797, 'fraction_numerical': 0.0005868544600938967, 'mean_word_length': 2.3814484126984126, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, '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': '1904681', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2145, 'n_words': 632}