<commit_before>:warning: :warning: Databox Push API has significally changed. This wrapper is outdated and is beeing rewritten! -[Oto](https://twitter.com/otobrglez)

# Databox

[![Gem Version][fury-badge]][fury] [![Build Status][travis-badge]][travis]

Ruby Gem for [Databox](http://databox.com/) - Mobile Executive Dashboard.

## Installation

Add this line to your application's Gemfile:

    gem 'databox'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install databox

## Usage

Before using Databox gem you have to initialize it with key and token. There are 3 ways how you can do initialization.

- Within simple initializer

  ```ruby
  Databox.configure do |c|
    c.token   = "YOUR_TOKEN"
    c.key     = "YOUR_KEY"
  end
  ```

- By setting system ```ENV``` variables ```DATABOX_KEY``` and ```DATABOX_TOKEN```

- If your are using custom integration with different key please use ```id```.

  ```ruby
  chart = Databox::LineChart.new "my_line", id: "OTHER_KEY"
  ```

## Using client directly

You can also use Databox::Client directly to insert raw KPIs. This is done by invoking Databox::Client and pushing Hash or Array of Hashes to it.

```ruby
client = Databox.client

client.push([{
  key: "name",
  date: "2014-01-22T12:00:00",
  value: 1
}])

puts client.logs
```

## Resources

- [Databox Web App](https://app.databox.com/)<commit_msg>Updating README.md<commit_after># Databox bindings for Ruby

[![Build Status][travis-badge]][travis]

Ruby Gem for [Databox](http://databox.com/) - Mobile Executive Dashboard.

## Installation

Add this line to your application's Gemfile:

    gem 'databox'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install databox

## Initialisation

Before push data to Databox you have to initialize it with token.

- Within simple initializer

  ```ruby
  Databox.configure do |c|
    c.push_token   = "<PASSWORD>"
  end
  ```

## Usage 

Pushing data directly to Databox with help of `push` method:

```ruby
client = Databox::Client.new

client.push('sales.total', 3000)
client.push('temp.boston', 52.0)
client.push('temp.boston', 52.0, '2015-01-01 17:00:00')
```

Inserting multiple matrices with one `insert_all`:

```ruby
client = Databox::Client.new

client.insert_all [
    {key: 'temp.boston', value: 52},
    {key: 'temp.boston', value: 50, date: '2015-01-01 17:00:00'},
    {key: 'temp.ny', value: 49}
]
```

Retrieving information from last push with `last_push`:

```ruby
client.last_push
# => [{"push"=>"{\"data\":[{\"$sales.total\":2000}]}",
       "err"=>"[]",
       "no_err"=>0,
       "datetime"=>"2015-06-05T10:21:23.861Z",
       "keys"=>"[\"132|sales.total\"]"}]
```

## Resources

- [Databox Web App](https://app.databox.com/)
{'fraction_non_alphanumeric': 0.1533697632058288, 'fraction_numerical': 0.030965391621129327, 'mean_word_length': 3.851590106007067, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 3, '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': '1707378', 'n_tokens_mistral': 1060, 'n_tokens_neox': 952, 'n_words': 280}