StatHat::Json

StatHat JSON API Client.

Build Status Gem Version Dependency Status Code Climate Test Coverage

Installation

Add this line to your application's Gemfile:

gem 'stathat-json'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stathat-json

Usage

Batch post stats

require 'stathat/json'

StatHat::Json::Api.ez_key = 'YOUR_EZ_KEY' # will also be picked up from ENV['STATHAT_EZKEY']

stats = []
stats << {stat: 'count_stat1'} # implicit count and time
stats << {stat: 'count_stat2', count: 2, t: 1420428506} # explicit count and time
stats << {stat: 'value_stat1', value: 3.14159} # delicious Pi

StatHat::Json::Api.post_stats(stats)

Post individual stats

require 'stathat/json'

StatHat::Json::Api.ez_key = 'YOUR_EZ_KEY' # will also be picked up from ENV['STATHAT_EZKEY']

StatHat::Json::Api.post_count('count_stat1') # implicit count and time
StatHat::Json::Api.post_count('count_stat2', 2, 1420428506) # explicit count and time
StatHat::Json::Api.post_value('value_stat1', 3.14159) # delicious Pi

Short lived processes

StatHat::Json::Api uses Celluloid::IO for threading and async network IO for long runing processes.
Use StatHat::Json::SyncApi for short lived processes, the API is identical.

Tested with the following Rubies

  • 1.9.3
  • 2.0.0
  • 2.1.0
  • rbx-2.2.10
  • jruby-19mode
  • ruby-head
  • jruby-head

Contributing

  1. Fork it ( https://github.com/[my-github-username]/stathat-json/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request