<commit_before># Resource Kit

Resource Kit provides tools to aid in making API Clients. Such as URL resolving, Request / Response layer, and more.

## Installation

Add this line to your application's Gemfile:

    gem 'resource_kit'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install resource_kit

## Usage

This library recommends using [Kartograph](http://github.com/digitaloceancloud/kartograph) for representing and deserializing response bodies.
You'll see it in the examples provided below.

### Resource classes

Resource Kit provides a comprehensive but intuitive DSL where you describe the remote resources capabilities.
For example, where can I get a list of users? Where do I get a single user? How do I create a user?

When you're able to answer these questions, you can describe them in your resource class like this:

```ruby
class DropletResource < ResourceKit::Resource
  host 'https://api.blah'
  namespace 'v1'

  resources do
    default_handler(422) {|response| ErrorMapping.extract_single(response.body, :read) }
    default_handler(:ok, :created) {|response| DropletMapping.extract_single(response.body, :read) }

    # Defining actions will create instance methods on the resource class to call them.
    action :find do<commit_msg>Remove host and namespace in resource example. Provided by connection object.<commit_after># Resource Kit

Resource Kit provides tools to aid in making API Clients. Such as URL resolving, Request / Response layer, and more.

## Installation

Add this line to your application's Gemfile:

    gem 'resource_kit'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install resource_kit

## Usage

This library recommends using [Kartograph](http://github.com/digitaloceancloud/kartograph) for representing and deserializing response bodies.
You'll see it in the examples provided below.

### Resource classes

Resource Kit provides a comprehensive but intuitive DSL where you describe the remote resources capabilities.
For example, where can I get a list of users? Where do I get a single user? How do I create a user?

When you're able to answer these questions, you can describe them in your resource class like this:

```ruby
class DropletResource < ResourceKit::Resource
  resources do
    default_handler(422) {|response| ErrorMapping.extract_single(response.body, :read) }
    default_handler(:ok, :created) {|response| DropletMapping.extract_single(response.body, :read) }

    # Defining actions will create instance methods on the resource class to call them.
    action :find do
{'fraction_non_alphanumeric': 0.06635802469135803, 'fraction_numerical': 0.002700617283950617, 'mean_word_length': 4.528784648187633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '3884858', 'n_tokens_mistral': 694, 'n_tokens_neox': 654, 'n_words': 317}