rescuetime 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcdae1ea4dddeba37ec5b2027feba33786eb5b5f
4
+ data.tar.gz: 79122e47a28bb64d6ee4a9a8bb431ff66901c293
5
+ SHA512:
6
+ metadata.gz: 7b5b956cc324db478d65b7b6a4d6436195f13d3f8f84ea8249eed426f9fc3f163fb259bf10df2757e5204f0ce430b22f9e57f155786ac0312a333c5dce6907c4
7
+ data.tar.gz: a45987af9db957b2e9001e1856d1ea5cd1313520715564f91642030367017902aed14eb8474b52b73eb10c66d858fe090e3cc702eb92260b86b31d3a2c2426b3
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # Ignore secret variables for VCR recording
12
+ secret.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ cache: bundler
2
+
3
+ language: ruby
4
+ rvm:
5
+ - 2.0.0
6
+ - 2.1
7
+ - 2.2
8
+ - ruby-head
9
+
10
+ addons:
11
+ code_climate:
12
+ repo_token: d79142f932dcf6759554757b9a2451b6f8a342b5602a64aef4bf87751ab0de7f
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rescuetime.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ rescuetime (under development)
2
+ ==========
3
+
4
+ [![Coverage](http://img.shields.io/codeclimate/coverage/github/leesharma/rescuetime.svg?style=flat-square)](https://codeclimate.com/github/leesharma/rescuetime)
5
+ [![Quality](http://img.shields.io/codeclimate/github/leesharma/rescuetime.svg?style=flat-square)](https://codeclimate.com/github/leesharma/rescuetime)
6
+ [![Build](https://img.shields.io/travis/leesharma/rescuetime.svg?style=flat-square)](https://travis-ci.org/leesharma/rescuetime)
7
+ [![Dependencies](https://img.shields.io/gemnasium/leesharma/rescuetime.svg?style=flat-square)](https://gemnasium.com/leesharma/rescuetime)
8
+ [![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](http://opensource.org/licenses/MIT)
9
+
10
+ **Warning: This code is under active development and is not yet stable. Use at your own risk.**
11
+
12
+ A Ruby interface to the RescueTime APIs. Rescuetime provides a simple DSL for interacting
13
+ with your personal or team RescueTime data.
14
+
15
+ Currently, this gem only supports the Data Analytics API with API key authorization.
16
+
17
+ For more information about RescueTime, visit [the RescueTime homepage](https://www.rescuetime.com).
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'rescuetime'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install rescuetime
34
+
35
+ ## Usage
36
+
37
+ ### Getting Started
38
+
39
+ In order to use access your RescueTime data, you will need an API key. If you do not already have a key, , visit the [API key management page](https://www.rescuetime.com/anapi/manage).
40
+
41
+ Using the rescuetime gem is simple. Here is some example code using the rescuetime gem:
42
+
43
+ ```ruby
44
+ require 'rescuetime'
45
+
46
+ @client = Rescuetime::Client.new(api_key: <YOUR_API_KEY>)
47
+
48
+ @client.activities
49
+ # => Returns a list of activities
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it ( https://github.com/[my-github-username]/rescuetime/fork )
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Run all the tests in spec'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ task test: :spec
9
+
10
+ desc 'Default: run specs'
11
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'rescuetime'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/rescuetime.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rescuetime/version'
2
+ require 'rescuetime/client'
3
+
4
+ module Rescuetime
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,32 @@
1
+ module Rescuetime
2
+ module Activities
3
+
4
+ BASE_URL = 'https://www.rescuetime.com/anapi/data'
5
+ # Returns array of all activities.
6
+ #
7
+ # @return [Array<Hash>]
8
+ def activities
9
+ connection = Faraday.new(Rescuetime::Activities::BASE_URL)
10
+ options = { key: @api_key,
11
+ format: 'csv' }
12
+ response = connection.get '', options
13
+
14
+ activities_from_csv response.body
15
+ end
16
+
17
+ private
18
+
19
+ # Takes a CSV with headers and returns an array of hashes
20
+ #
21
+ # @param body[CSV]
22
+ # @return [Array]
23
+ def activities_from_csv(body)
24
+ activities = CSV.new(body,
25
+ headers: true,
26
+ header_converters: :symbol,
27
+ converters: :all)
28
+
29
+ activities.to_a.map(&:to_hash)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'rescuetime/activities'
2
+
3
+ module Rescuetime
4
+ module Api
5
+ # @note All methods have been separated into modules
6
+ include Rescuetime::Activities
7
+ end
8
+ end
@@ -0,0 +1,27 @@
1
+ require 'faraday'
2
+ require 'csv'
3
+
4
+ require 'rescuetime/api'
5
+
6
+ module Rescuetime
7
+ class Client
8
+ include Rescuetime::Api
9
+
10
+ attr_writer :api_key
11
+
12
+ # Initializes a new Client object
13
+ #
14
+ # @param options [Hash]
15
+ # @return [Rescuetime::Client]
16
+ def initialize(options={})
17
+ @api_key = options[:api_key]
18
+ end
19
+
20
+ # Checks whether an api key is set
21
+ #
22
+ # @return [Boolean]
23
+ def api_key?
24
+ !!@api_key
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Rescuetime
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rescuetime/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rescuetime'
8
+ spec.version = Rescuetime::VERSION
9
+ spec.authors = ['Lee Sharma']
10
+ spec.email = ['lee@leesharma.com']
11
+
12
+ spec.summary = %q{Ruby interface for RescueTime}
13
+ spec.description = %q{rescuetime is a simple ruby interface for the RescueTime Data Analytics API.}
14
+ spec.homepage = 'https://github.com/leesharma/rescuetime'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'faraday'
23
+
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
+
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'vcr'
29
+ spec.add_development_dependency 'webmock'
30
+ spec.add_development_dependency 'codeclimate-test-reporter'
31
+ spec.add_development_dependency 'simplecov'
32
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rescuetime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lee Sharma
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+
12
+ date: 2015-04-15 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - &id002
20
+ - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :runtime
24
+ version_requirements: *id001
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ prerelease: false
28
+ requirement: &id003 !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - *id002
31
+ type: :development
32
+ version_requirements: *id003
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ prerelease: false
36
+ requirement: &id004 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - *id002
39
+ type: :development
40
+ version_requirements: *id004
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ prerelease: false
44
+ requirement: &id005 !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - *id002
47
+ type: :development
48
+ version_requirements: *id005
49
+ - !ruby/object:Gem::Dependency
50
+ name: vcr
51
+ prerelease: false
52
+ requirement: &id006 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - *id002
55
+ type: :development
56
+ version_requirements: *id006
57
+ - !ruby/object:Gem::Dependency
58
+ name: webmock
59
+ prerelease: false
60
+ requirement: &id007 !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - *id002
63
+ type: :development
64
+ version_requirements: *id007
65
+ - !ruby/object:Gem::Dependency
66
+ name: codeclimate-test-reporter
67
+ prerelease: false
68
+ requirement: &id008 !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - *id002
71
+ type: :development
72
+ version_requirements: *id008
73
+ - !ruby/object:Gem::Dependency
74
+ name: simplecov
75
+ prerelease: false
76
+ requirement: &id009 !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - *id002
79
+ type: :development
80
+ version_requirements: *id009
81
+ description: rescuetime is a simple ruby interface for the RescueTime Data Analytics API.
82
+ email:
83
+ - lee@leesharma.com
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - .travis.yml
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/rescuetime.rb
102
+ - lib/rescuetime/activities.rb
103
+ - lib/rescuetime/api.rb
104
+ - lib/rescuetime/client.rb
105
+ - lib/rescuetime/version.rb
106
+ - rescuetime.gemspec
107
+ homepage: https://github.com/leesharma/rescuetime
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+
112
+ post_install_message:
113
+ rdoc_options: []
114
+
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - *id002
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - *id002
123
+ requirements: []
124
+
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.6
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Ruby interface for RescueTime
130
+ test_files: []
131
+