rescuetime 0.3.2 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.rubocop.yml +4 -1
- data/.rubocop_todo.yml +32 -54
- data/.travis.yml +3 -1
- data/CHANGELOG.md +320 -0
- data/CODE_OF_CONDUCT.md +67 -6
- data/Gemfile +1 -3
- data/README.md +184 -41
- data/Rakefile +1 -1
- data/lib/rescuetime.rb +68 -3
- data/lib/rescuetime/client.rb +6 -13
- data/lib/rescuetime/collection.rb +32 -11
- data/lib/rescuetime/configuration.rb +22 -0
- data/lib/rescuetime/core_extensions.rb +8 -0
- data/lib/rescuetime/core_extensions/object.rb +8 -0
- data/lib/rescuetime/core_extensions/object/blank.rb +49 -0
- data/lib/rescuetime/core_extensions/string.rb +10 -0
- data/lib/rescuetime/date_parser.rb +12 -10
- data/lib/rescuetime/errors.rb +79 -73
- data/lib/rescuetime/formatters.rb +48 -0
- data/lib/rescuetime/formatters/array_formatter.rb +23 -0
- data/lib/rescuetime/formatters/base_formatter.rb +46 -0
- data/lib/rescuetime/formatters/csv_formatter.rb +23 -0
- data/lib/rescuetime/query_buildable.rb +18 -16
- data/lib/rescuetime/report_formatters.rb +83 -0
- data/lib/rescuetime/requester.rb +56 -27
- data/lib/rescuetime/version.rb +3 -2
- data/rescuetime.gemspec +7 -9
- metadata +30 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a432c96ac3df86019ae962948bdddacfcb74d6d
|
4
|
+
data.tar.gz: 34d4785182403bc262e017592e4f911700e39768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b584353be255e265d40f93e80c04cb6a8542b20f12c37520ac2dead84d1caad627493755f3bd1e267da155e6e5c38fe212a5975acc38fef58bc0af15a582ca0
|
7
|
+
data.tar.gz: 7758b44a45ee0fef13e367a85bbf84ea18576ff226234adc4e68abaaa7b3d2b0c3b00d421ab0024fae0d8755ef38e004ac56e5017372b94a5bc545470af8e3ae
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,80 +1,58 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-05-
|
3
|
+
# on 2016-05-26 15:32:03 -0400 using RuboCop version 0.40.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# Offense count: 23
|
10
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
11
|
+
# URISchemes: http, https
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 91
|
13
14
|
|
14
15
|
# Offense count: 1
|
15
16
|
# Configuration parameters: CountComments.
|
16
17
|
Metrics/MethodLength:
|
17
18
|
Max: 13
|
18
19
|
|
19
|
-
# Offense count:
|
20
|
+
# Offense count: 8
|
20
21
|
# Cop supports --auto-correct.
|
21
|
-
|
22
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
23
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
24
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
25
|
+
# FunctionalMethods: let, let!, subject, watch
|
26
|
+
# IgnoredMethods: lambda, proc, it
|
27
|
+
Style/BlockDelimiters:
|
22
28
|
Exclude:
|
23
|
-
- '
|
29
|
+
- 'spec/rescuetime/core_extensions/object/blank_spec.rb'
|
30
|
+
- 'spec/rescuetime/date_parser_spec.rb'
|
31
|
+
- 'spec/rescuetime/formatters/array_formatter_spec.rb'
|
32
|
+
- 'spec/rescuetime/formatters/csv_formatter_spec.rb'
|
33
|
+
- 'spec/rescuetime/report_formatters_spec.rb'
|
34
|
+
- 'spec/rescuetime/requester_spec.rb'
|
24
35
|
|
25
|
-
# Offense count:
|
26
|
-
# Cop supports --auto-correct.
|
36
|
+
# Offense count: 7
|
27
37
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
28
|
-
# SupportedStyles:
|
29
|
-
Style/
|
38
|
+
# SupportedStyles: nested, compact
|
39
|
+
Style/ClassAndModuleChildren:
|
30
40
|
Exclude:
|
31
|
-
- 'lib/rescuetime/
|
41
|
+
- 'lib/rescuetime/core_extensions/object.rb'
|
42
|
+
- 'lib/rescuetime/core_extensions/object/blank.rb'
|
43
|
+
- 'lib/rescuetime/core_extensions/string.rb'
|
44
|
+
- 'lib/rescuetime/formatters/array_formatter.rb'
|
45
|
+
- 'lib/rescuetime/formatters/base_formatter.rb'
|
46
|
+
- 'lib/rescuetime/formatters/csv_formatter.rb'
|
47
|
+
- 'spec/fixtures/formatters/fake_formatter.rb'
|
32
48
|
|
33
|
-
# Offense count:
|
34
|
-
|
35
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
36
|
-
# SupportedStyles: aligned, indented
|
37
|
-
Style/MultilineMethodCallIndentation:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
# Offense count: 9
|
41
|
-
# Cop supports --auto-correct.
|
42
|
-
Style/MutableConstant:
|
43
|
-
Exclude:
|
44
|
-
- 'lib/rescuetime/collection.rb'
|
45
|
-
- 'lib/rescuetime/date_parser.rb'
|
46
|
-
- 'lib/rescuetime/errors.rb'
|
47
|
-
- 'lib/rescuetime/query_buildable.rb'
|
48
|
-
- 'lib/rescuetime/requester.rb'
|
49
|
-
- 'lib/rescuetime/version.rb'
|
50
|
-
- 'spec/sample_secret.rb'
|
51
|
-
- 'spec/secret.rb'
|
52
|
-
|
53
|
-
# Offense count: 3
|
54
|
-
# Cop supports --auto-correct.
|
55
|
-
Style/NestedParenthesizedCalls:
|
49
|
+
# Offense count: 1
|
50
|
+
Style/DoubleNegation:
|
56
51
|
Exclude:
|
57
|
-
- '
|
52
|
+
- 'lib/rescuetime/core_extensions/object/blank.rb'
|
58
53
|
|
59
54
|
# Offense count: 1
|
60
55
|
# Cop supports --auto-correct.
|
61
56
|
Style/ParallelAssignment:
|
62
57
|
Exclude:
|
63
58
|
- 'spec/rescuetime/query_buildable_spec.rb'
|
64
|
-
|
65
|
-
# Offense count: 1
|
66
|
-
# Cop supports --auto-correct.
|
67
|
-
Style/RedundantSelf:
|
68
|
-
Exclude:
|
69
|
-
- 'lib/rescuetime/query_buildable.rb'
|
70
|
-
|
71
|
-
# Offense count: 10
|
72
|
-
# Cop supports --auto-correct.
|
73
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
74
|
-
# SupportedStyles: only_raise, only_fail, semantic
|
75
|
-
Style/SignalException:
|
76
|
-
Exclude:
|
77
|
-
- 'lib/rescuetime/collection.rb'
|
78
|
-
- 'lib/rescuetime/date_parser.rb'
|
79
|
-
- 'lib/rescuetime/query_buildable.rb'
|
80
|
-
- 'lib/rescuetime/requester.rb'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,320 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
|
+
|
6
|
+
See also
|
7
|
+
- [GitHub releases](https://github.com/leesharma/rescuetime/releases)
|
8
|
+
|
9
|
+
## [Unreleased] - current
|
10
|
+
|
11
|
+
...
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
## [v1.0.1] - 2019-02-16
|
16
|
+
|
17
|
+
Mention max ruby version in gemspec
|
18
|
+
|
19
|
+
### Updates
|
20
|
+
|
21
|
+
No code updates. It looks like some functionality breaks under ruby 2.4+, so
|
22
|
+
this change updates the gemspec to reflect this. A future update will probably
|
23
|
+
resolve the bug.
|
24
|
+
|
25
|
+
## [v1.0.0] - 2016-08-26
|
26
|
+
|
27
|
+
Bump Version and Misc Updates
|
28
|
+
|
29
|
+
### Updates
|
30
|
+
|
31
|
+
The only update (aside from the version bump) is specifying that executables
|
32
|
+
are kept in the `bin` directory, not the `exe` directory. This version bump
|
33
|
+
is mainly to signify that the API is stable.
|
34
|
+
|
35
|
+
## [v0.4.0] - 2016-04-26
|
36
|
+
|
37
|
+
Add Custom Formatters and Misc Updates
|
38
|
+
|
39
|
+
### Breaking Changes
|
40
|
+
|
41
|
+
Exception classes, which were previously in the top-level Rescuetime (ex. Rescuetime::InvalidQueryError) are now under the Rescuetime::Errors module. This change was made for better code organization.
|
42
|
+
|
43
|
+
### Updates
|
44
|
+
|
45
|
+
#### Allow Frozen String Literals
|
46
|
+
|
47
|
+
If you're using ruby 2.3, rescuetime will now work with the `# frozen_string_literals: true` option set.
|
48
|
+
|
49
|
+
#### Custom Formatters
|
50
|
+
|
51
|
+
The big change in this update is that users can now add/configure custom formatters.
|
52
|
+
|
53
|
+
Rescuetime ships with two report formats: CSV and Array. If you would like your
|
54
|
+
report in a different format, don't worry–it's easy to add a custom formatter.
|
55
|
+
|
56
|
+
Three things are required to add a custom formatter:
|
57
|
+
|
58
|
+
- Write a class within the module `Rescuetime::Formatters` that inherits from `Rescuetime::Formatters::BaseFormatter` or one of its descendants
|
59
|
+
- Define the class methods `.name` and `.format`
|
60
|
+
- Register your formatters using `Rescuetime.configure`
|
61
|
+
|
62
|
+
##### Writing a Formatter
|
63
|
+
|
64
|
+
First, the formatters themselves. Here is a basic formatter:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# config/formatters/nil_formatter.rb
|
68
|
+
module Rescuetime::Formatters
|
69
|
+
# Turns a productivity report into nothing useful.
|
70
|
+
class NilFormatter < BaseFormatter
|
71
|
+
# @return [String] name of this report format
|
72
|
+
def self.name
|
73
|
+
'nil'
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param [CSV] _report the raw CSV report from Rescuetime
|
77
|
+
# @return [nil] the formatted output (in this case, nil)
|
78
|
+
def self.format(_report)
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
You can even inherit from an existing formatter:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
# config/formatters/shouty_array_formatter.rb
|
89
|
+
module Rescuetime::Formatters
|
90
|
+
# Formats a rescuetime report as an array of hashes, except shouting.
|
91
|
+
class ShoutyArrayFormatter < ArrayFormatter
|
92
|
+
# @return [String] name of this report format
|
93
|
+
def self.name
|
94
|
+
'shouty_array'
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param [CSV] report the raw CSV report from Rescuetime
|
98
|
+
# @return [Array<Hash>] the formatted output (in this case, a shouty
|
99
|
+
# array of hashes)
|
100
|
+
def self.format(report)
|
101
|
+
array = super(report)
|
102
|
+
array.map do |hash|
|
103
|
+
terms = hash.map { |key, value| [key.to_s.upcase, value.to_s.upcase] }
|
104
|
+
Hash[terms]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
##### Registering your Formatters
|
112
|
+
|
113
|
+
Before setting your report format, add the path to your formatter(s) to the
|
114
|
+
Rescuetime configuration using the Rescuetime.configure method. You will be
|
115
|
+
able to set, append to, or manipulate the formatter_paths setting.
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Rescuetime.configure do |config|
|
119
|
+
path = File.expand_path('../my_custom_formatter.rb', __FILE__)
|
120
|
+
config.formatter_paths = [path]
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
Now Rescuetime will look for the my_custom_formatter.rb file. Multiple paths
|
125
|
+
may be added as well.
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
Rescuetime.configure do |config|
|
129
|
+
config.formatter_paths = [
|
130
|
+
'config/formatters/*_formatter.rb',
|
131
|
+
'lib/formatters/**/*_formatter.rb',
|
132
|
+
]
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
### Documentation
|
137
|
+
|
138
|
+
Increased documentation coverage/quality
|
139
|
+
|
140
|
+
### Test Coverage
|
141
|
+
|
142
|
+
Increased
|
143
|
+
|
144
|
+
## [v0.3.3] - 2016-05-21
|
145
|
+
|
146
|
+
Remove the dependency to Faraday
|
147
|
+
|
148
|
+
### Refactoring
|
149
|
+
|
150
|
+
Switch from using Faraday to Net::HTTP in order to reduce production dependencies.
|
151
|
+
|
152
|
+
---
|
153
|
+
|
154
|
+
## [v0.3.2] - 2016-05-21
|
155
|
+
|
156
|
+
Documentation Comments and Refactoring
|
157
|
+
|
158
|
+
### Documentation
|
159
|
+
|
160
|
+
Public methods and classes now have 100% documentation coverage, and the documentation was expanded to include descriptions, examples, links, and more.
|
161
|
+
|
162
|
+
###Refactoring
|
163
|
+
|
164
|
+
The `Rescuetime::DateParser` class was extracted from the `Rescuetime::QueryBuilder`, keyword arguments were added in preference to the options hash, and other code readability/maintainability changes were made.
|
165
|
+
|
166
|
+
This release shouldn't affect the behavior or interface of the gem, and it adds no new features.
|
167
|
+
|
168
|
+
---
|
169
|
+
|
170
|
+
## [v0.3.1] - 2015-05-04
|
171
|
+
|
172
|
+
Fix gemspec description
|
173
|
+
|
174
|
+
### Minor fix:
|
175
|
+
|
176
|
+
gemspec description used `%w(...)`, changed to string
|
177
|
+
|
178
|
+
---
|
179
|
+
|
180
|
+
## [v0.3.0] - 2015-05-04
|
181
|
+
|
182
|
+
### Focus
|
183
|
+
|
184
|
+
Method Chaining and Lazy Evaluation
|
185
|
+
|
186
|
+
### Updates
|
187
|
+
|
188
|
+
This release introduces many breaking changes to the codebase. Since the gem is still in development (v0.x.x), the major version has not increased.
|
189
|
+
|
190
|
+
The major goal of this release was refactoring and adding method chaining and lazy evaluation. Additionally, results can now be limited by overview/category/activity name as well as document name,.
|
191
|
+
|
192
|
+
Queries can now be formed with the following syntax:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
client = Rescuetime::Client.new RESCUETIME_API_KEY
|
196
|
+
#=> <#Rescuetime::Client:...>
|
197
|
+
|
198
|
+
# Build the query
|
199
|
+
activities = client.activities.from(1.week.ago).where(name: 'github.com').format('csv')
|
200
|
+
#=> <#Rescuetime::Collection:...>
|
201
|
+
|
202
|
+
# Perform the query with #all or an enumerable method (#each, #map, #any?, etc.)
|
203
|
+
activities.all
|
204
|
+
#=> <#CSV:...>
|
205
|
+
```
|
206
|
+
|
207
|
+
---
|
208
|
+
|
209
|
+
## [v0.2.0] - 2015-04-23
|
210
|
+
|
211
|
+
### Scope
|
212
|
+
|
213
|
+
Provides nearly-full coverage of the RescueTime Analytic Data API.
|
214
|
+
|
215
|
+
### Features
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
# Basics
|
219
|
+
@client = Rescuetime::Client.new
|
220
|
+
|
221
|
+
@client.api_key? #=> false
|
222
|
+
@client.valid_credentials? #=> false
|
223
|
+
@client.activities #=> Rescuetime::MissingCredentials
|
224
|
+
|
225
|
+
@client.api_key='invalid'
|
226
|
+
@client.api_key? #=> true
|
227
|
+
@client.valid_credentials? #=> false
|
228
|
+
@client.activities #=> Rescuetime::InvalidCredentials
|
229
|
+
|
230
|
+
@client.api_key= VALID_KEY
|
231
|
+
@client.valid_credentials? #=> true
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
# #productivity_levels
|
237
|
+
@client.productivity_levels #=> Hash
|
238
|
+
@client.productivity_levels[-2] #=> 'Very Unproductive'
|
239
|
+
@client.productivity_levels[0] #=> 'Neutral'
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
# #activities
|
245
|
+
@client.activities #=> Array<Hash>
|
246
|
+
@client.activities.first #=> Hash
|
247
|
+
|
248
|
+
# :by (report order/perspective)
|
249
|
+
@client.activities(by: 'rank') # returns ranked report by time spent per activity/category
|
250
|
+
@client.activities(by: 'time') # returns chronological report
|
251
|
+
@client.activities(by: 'member') # returns report grouped by member
|
252
|
+
|
253
|
+
# :detail (detail level of report)
|
254
|
+
@client.activities(detail: 'overview') # returns report at the 'overview' level (ie. Entertainment)
|
255
|
+
@client.activities(detail: 'category') # returns report at the 'category' level (ie. News and Opionion)
|
256
|
+
@client.activities(detail: 'activity') # returns report at the 'activity' level (ie. reddit.com)
|
257
|
+
# note: 'productivity' and 'efficiency' are options as well, but
|
258
|
+
# #productivity and #efficiency are the preferred way to
|
259
|
+
# get that information.
|
260
|
+
|
261
|
+
# :date, :from, and :to (date range of report)
|
262
|
+
@client.activities(date: '2015-04-02') # returns report for selected date
|
263
|
+
@client.activities(from: '2015-04-18') # returns report between selected and current date
|
264
|
+
@client.activities(from: Time.new(2015,04,19)) # time objects work too
|
265
|
+
@client.activities(from: '2015-04-02', to: '2015-04-02') # returns report between start and end date
|
266
|
+
|
267
|
+
# :interval (time interval of the report)
|
268
|
+
@client.activities(by: 'time', interval: 'minute') # returns report in 5-minute intervals
|
269
|
+
@client.activities(by: 'time', interval: 'hour') # returns report in 1-hour intervals
|
270
|
+
@client.activities(by: 'time', interval: 'day') # returns report in 1-day intervals
|
271
|
+
@client.activities(by: 'time', interval: 'week') # returns report in 1-week intervals
|
272
|
+
@client.activities(by: 'time', interval: 'month') # returns report in 1-month intervals
|
273
|
+
|
274
|
+
# :format (output format)
|
275
|
+
@client.activities #=> Array<Hash>
|
276
|
+
@client.activities(format: 'csv') #=> CSV
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
# #productivity
|
282
|
+
@client.productivity(...) # productivity takes the same options as #activities except :detail
|
283
|
+
# returns a productivity report with the given options
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
# #efficiency
|
288
|
+
@client.efficiency(...) # efficiency takes the same options as #activities except :detail
|
289
|
+
# returns an efficiency report with the given options
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
# All of this can be used together
|
294
|
+
@client.efficiency( from: '2015-03-20', # returns weekly efficiency report between March 20th and
|
295
|
+
to: '2015-04-20' , # April 20th of 2015 by member in csv format
|
296
|
+
interval: 'week',
|
297
|
+
format: 'csv' )
|
298
|
+
```
|
299
|
+
|
300
|
+
---
|
301
|
+
|
302
|
+
## [v0.1.0] - 2015-04-15
|
303
|
+
|
304
|
+
Initial gem release
|
305
|
+
|
306
|
+
### Features
|
307
|
+
- Rescuetime has a version number
|
308
|
+
- `Rescuetime::Client` exists
|
309
|
+
- `Rescuetime::Client#api_key?` returns existence of api key
|
310
|
+
- `Rescuetime::Client#api_key=` overwrites api key
|
311
|
+
- `Rescuetime::Client#activities` returns list of activities
|
312
|
+
|
313
|
+
[Unreleased]: https://github.com/leesharma/rescuetime/compare/v0.4.0...HEAD
|
314
|
+
[v0.4.0]: https://github.com/leesharma/rescuetime/compare/v0.3.3...v0.4.0
|
315
|
+
[v0.3.3]: https://github.com/leesharma/rescuetime/compare/v0.3.2...v0.3.3
|
316
|
+
[v0.3.2]: https://github.com/leesharma/rescuetime/compare/v0.3.1...v0.3.2
|
317
|
+
[v0.3.1]: https://github.com/leesharma/rescuetime/compare/v0.3.0...v0.3.1
|
318
|
+
[v0.3.0]: https://github.com/leesharma/rescuetime/compare/v0.2.0...v0.3.0
|
319
|
+
[v0.2.0]: https://github.com/leesharma/rescuetime/compare/v0.1.0...v0.2.0
|
320
|
+
[v0.1.0]: https://github.com/leesharma/rescuetime/commits/v0.1.0
|