Ruby wrapper for the RescueTime data API
Add this line to your application's Gemfile:
gem 'rescue_time_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rescue_time_api
You'll need a key from RescueTime's API Key Management page. Once you've got one, create a client instance like this:
client = RescueTimeApi::Client.new(key: 'notanactualkey123456')
Make requests using the parameters described in RescueTime's documentation. Pass parameters as a hash with either strings or symbols as keys.
client.request({
prespective: 'interval',
resolution_time: 'day'
})
The only transformations applied to the parameter hash is to add the format
value (json), the key
value, and to change any date type parameters into a correctly formatted day string (YYYY-MM-DD). So this will work:
client.request({
prespective: 'interval',
restrict_begin: DateTime.now
})
The #request
method returns a RescueTimeApi::Response
object. Use its #rows
method to access the returned data as an array of hashes with simplified keys:
RescueTimeApi::Client > request({}).rows
=> [
{"rank"=>1,
"seconds"=>5887,
"people"=>1,
"activity"=>"sublime text",
"categoty"=>"Editing & IDEs",
"productivity"=>2},
{"rank"=>2,
"seconds"=>5668,
"people"=>1,
"activity"=>"iTerm",
"categoty"=>"Systems Operations",
"productivity"=>2},
{"rank"=>3,
"seconds"=>4131,
"people"=>1,
"activity"=>"github.com",
"categoty"=>"General Software Development",
"productivity"=>1},
<...>
]
date
keys are returned as DateTime
s.
You can launch a Pry REPL to play with the client interactively:
$ rescue_time_api notanactualkey123456
RescueTimeApi::Client >
RescueTimeApi::Client > request({prespective: 'interval'})
=> #<RescueTimeApi::Response:0x007f976b143e58...
They're in RSpec.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request