rescuetime 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +310 -0
- data/README.md +16 -1
- data/lib/rescuetime/version.rb +1 -1
- data/rescuetime.gemspec +1 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48104dc18af880729a3ff3c7cfb9ecda7a777368
|
4
|
+
data.tar.gz: d3f44a16cfc18c5b9ea035f1640d087df479b2d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9cf53762f2ca0aea6f56fecdf4a922a8e81d5e731c74e9474f99b3e7d137b1ef56131d228d7a4f0bd01286091a10162e079ffceb8871f570b27afe606dd7e12
|
7
|
+
data.tar.gz: 811ff42704eea5596939a678f4a0c1667226ed0bd01ae598a85fe4f67cf76f4024af7bc042d4c5bcd2a9548194c901c27d0c7ed0d9ba8999571322b856ce58f8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,310 @@
|
|
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.0] - 2016-08-26
|
16
|
+
|
17
|
+
Bump Version and Misc Updates
|
18
|
+
|
19
|
+
### Updates
|
20
|
+
|
21
|
+
The only update (aside from the version bump) is specifying that executables
|
22
|
+
are kept in the `bin` directory, not the `exe` directory. This version bump
|
23
|
+
is mainly to signify that the API is stable.
|
24
|
+
|
25
|
+
## [v0.4.0] - 2016-04-26
|
26
|
+
|
27
|
+
Add Custom Formatters and Misc Updates
|
28
|
+
|
29
|
+
### Breaking Changes
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
### Updates
|
34
|
+
|
35
|
+
#### Allow Frozen String Literals
|
36
|
+
|
37
|
+
If you're using ruby 2.3, rescuetime will now work with the `# frozen_string_literals: true` option set.
|
38
|
+
|
39
|
+
#### Custom Formatters
|
40
|
+
|
41
|
+
The big change in this update is that users can now add/configure custom formatters.
|
42
|
+
|
43
|
+
Rescuetime ships with two report formats: CSV and Array. If you would like your
|
44
|
+
report in a different format, don't worry–it's easy to add a custom formatter.
|
45
|
+
|
46
|
+
Three things are required to add a custom formatter:
|
47
|
+
|
48
|
+
- Write a class within the module `Rescuetime::Formatters` that inherits from `Rescuetime::Formatters::BaseFormatter` or one of its descendants
|
49
|
+
- Define the class methods `.name` and `.format`
|
50
|
+
- Register your formatters using `Rescuetime.configure`
|
51
|
+
|
52
|
+
##### Writing a Formatter
|
53
|
+
|
54
|
+
First, the formatters themselves. Here is a basic formatter:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
# config/formatters/nil_formatter.rb
|
58
|
+
module Rescuetime::Formatters
|
59
|
+
# Turns a productivity report into nothing useful.
|
60
|
+
class NilFormatter < BaseFormatter
|
61
|
+
# @return [String] name of this report format
|
62
|
+
def self.name
|
63
|
+
'nil'
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param [CSV] _report the raw CSV report from Rescuetime
|
67
|
+
# @return [nil] the formatted output (in this case, nil)
|
68
|
+
def self.format(_report)
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
You can even inherit from an existing formatter:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
# config/formatters/shouty_array_formatter.rb
|
79
|
+
module Rescuetime::Formatters
|
80
|
+
# Formats a rescuetime report as an array of hashes, except shouting.
|
81
|
+
class ShoutyArrayFormatter < ArrayFormatter
|
82
|
+
# @return [String] name of this report format
|
83
|
+
def self.name
|
84
|
+
'shouty_array'
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param [CSV] report the raw CSV report from Rescuetime
|
88
|
+
# @return [Array<Hash>] the formatted output (in this case, a shouty
|
89
|
+
# array of hashes)
|
90
|
+
def self.format(report)
|
91
|
+
array = super(report)
|
92
|
+
array.map do |hash|
|
93
|
+
terms = hash.map { |key, value| [key.to_s.upcase, value.to_s.upcase] }
|
94
|
+
Hash[terms]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
##### Registering your Formatters
|
102
|
+
|
103
|
+
Before setting your report format, add the path to your formatter(s) to the
|
104
|
+
Rescuetime configuration using the Rescuetime.configure method. You will be
|
105
|
+
able to set, append to, or manipulate the formatter_paths setting.
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
Rescuetime.configure do |config|
|
109
|
+
path = File.expand_path('../my_custom_formatter.rb', __FILE__)
|
110
|
+
config.formatter_paths = [path]
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
Now Rescuetime will look for the my_custom_formatter.rb file. Multiple paths
|
115
|
+
may be added as well.
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Rescuetime.configure do |config|
|
119
|
+
config.formatter_paths = [
|
120
|
+
'config/formatters/*_formatter.rb',
|
121
|
+
'lib/formatters/**/*_formatter.rb',
|
122
|
+
]
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
### Documentation
|
127
|
+
|
128
|
+
Increased documentation coverage/quality
|
129
|
+
|
130
|
+
### Test Coverage
|
131
|
+
|
132
|
+
Increased
|
133
|
+
|
134
|
+
## [v0.3.3] - 2016-05-21
|
135
|
+
|
136
|
+
Remove the dependency to Faraday
|
137
|
+
|
138
|
+
### Refactoring
|
139
|
+
|
140
|
+
Switch from using Faraday to Net::HTTP in order to reduce production dependencies.
|
141
|
+
|
142
|
+
---
|
143
|
+
|
144
|
+
## [v0.3.2] - 2016-05-21
|
145
|
+
|
146
|
+
Documentation Comments and Refactoring
|
147
|
+
|
148
|
+
### Documentation
|
149
|
+
|
150
|
+
Public methods and classes now have 100% documentation coverage, and the documentation was expanded to include descriptions, examples, links, and more.
|
151
|
+
|
152
|
+
###Refactoring
|
153
|
+
|
154
|
+
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.
|
155
|
+
|
156
|
+
This release shouldn't affect the behavior or interface of the gem, and it adds no new features.
|
157
|
+
|
158
|
+
---
|
159
|
+
|
160
|
+
## [v0.3.1] - 2015-05-04
|
161
|
+
|
162
|
+
Fix gemspec description
|
163
|
+
|
164
|
+
### Minor fix:
|
165
|
+
|
166
|
+
gemspec description used `%w(...)`, changed to string
|
167
|
+
|
168
|
+
---
|
169
|
+
|
170
|
+
## [v0.3.0] - 2015-05-04
|
171
|
+
|
172
|
+
### Focus
|
173
|
+
|
174
|
+
Method Chaining and Lazy Evaluation
|
175
|
+
|
176
|
+
### Updates
|
177
|
+
|
178
|
+
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.
|
179
|
+
|
180
|
+
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,.
|
181
|
+
|
182
|
+
Queries can now be formed with the following syntax:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
client = Rescuetime::Client.new RESCUETIME_API_KEY
|
186
|
+
#=> <#Rescuetime::Client:...>
|
187
|
+
|
188
|
+
# Build the query
|
189
|
+
activities = client.activities.from(1.week.ago).where(name: 'github.com').format('csv')
|
190
|
+
#=> <#Rescuetime::Collection:...>
|
191
|
+
|
192
|
+
# Perform the query with #all or an enumerable method (#each, #map, #any?, etc.)
|
193
|
+
activities.all
|
194
|
+
#=> <#CSV:...>
|
195
|
+
```
|
196
|
+
|
197
|
+
---
|
198
|
+
|
199
|
+
## [v0.2.0] - 2015-04-23
|
200
|
+
|
201
|
+
### Scope
|
202
|
+
|
203
|
+
Provides nearly-full coverage of the RescueTime Analytic Data API.
|
204
|
+
|
205
|
+
### Features
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
# Basics
|
209
|
+
@client = Rescuetime::Client.new
|
210
|
+
|
211
|
+
@client.api_key? #=> false
|
212
|
+
@client.valid_credentials? #=> false
|
213
|
+
@client.activities #=> Rescuetime::MissingCredentials
|
214
|
+
|
215
|
+
@client.api_key='invalid'
|
216
|
+
@client.api_key? #=> true
|
217
|
+
@client.valid_credentials? #=> false
|
218
|
+
@client.activities #=> Rescuetime::InvalidCredentials
|
219
|
+
|
220
|
+
@client.api_key= VALID_KEY
|
221
|
+
@client.valid_credentials? #=> true
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
# #productivity_levels
|
227
|
+
@client.productivity_levels #=> Hash
|
228
|
+
@client.productivity_levels[-2] #=> 'Very Unproductive'
|
229
|
+
@client.productivity_levels[0] #=> 'Neutral'
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
# #activities
|
235
|
+
@client.activities #=> Array<Hash>
|
236
|
+
@client.activities.first #=> Hash
|
237
|
+
|
238
|
+
# :by (report order/perspective)
|
239
|
+
@client.activities(by: 'rank') # returns ranked report by time spent per activity/category
|
240
|
+
@client.activities(by: 'time') # returns chronological report
|
241
|
+
@client.activities(by: 'member') # returns report grouped by member
|
242
|
+
|
243
|
+
# :detail (detail level of report)
|
244
|
+
@client.activities(detail: 'overview') # returns report at the 'overview' level (ie. Entertainment)
|
245
|
+
@client.activities(detail: 'category') # returns report at the 'category' level (ie. News and Opionion)
|
246
|
+
@client.activities(detail: 'activity') # returns report at the 'activity' level (ie. reddit.com)
|
247
|
+
# note: 'productivity' and 'efficiency' are options as well, but
|
248
|
+
# #productivity and #efficiency are the preferred way to
|
249
|
+
# get that information.
|
250
|
+
|
251
|
+
# :date, :from, and :to (date range of report)
|
252
|
+
@client.activities(date: '2015-04-02') # returns report for selected date
|
253
|
+
@client.activities(from: '2015-04-18') # returns report between selected and current date
|
254
|
+
@client.activities(from: Time.new(2015,04,19)) # time objects work too
|
255
|
+
@client.activities(from: '2015-04-02', to: '2015-04-02') # returns report between start and end date
|
256
|
+
|
257
|
+
# :interval (time interval of the report)
|
258
|
+
@client.activities(by: 'time', interval: 'minute') # returns report in 5-minute intervals
|
259
|
+
@client.activities(by: 'time', interval: 'hour') # returns report in 1-hour intervals
|
260
|
+
@client.activities(by: 'time', interval: 'day') # returns report in 1-day intervals
|
261
|
+
@client.activities(by: 'time', interval: 'week') # returns report in 1-week intervals
|
262
|
+
@client.activities(by: 'time', interval: 'month') # returns report in 1-month intervals
|
263
|
+
|
264
|
+
# :format (output format)
|
265
|
+
@client.activities #=> Array<Hash>
|
266
|
+
@client.activities(format: 'csv') #=> CSV
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
# #productivity
|
272
|
+
@client.productivity(...) # productivity takes the same options as #activities except :detail
|
273
|
+
# returns a productivity report with the given options
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
# #efficiency
|
278
|
+
@client.efficiency(...) # efficiency takes the same options as #activities except :detail
|
279
|
+
# returns an efficiency report with the given options
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
# All of this can be used together
|
284
|
+
@client.efficiency( from: '2015-03-20', # returns weekly efficiency report between March 20th and
|
285
|
+
to: '2015-04-20' , # April 20th of 2015 by member in csv format
|
286
|
+
interval: 'week',
|
287
|
+
format: 'csv' )
|
288
|
+
```
|
289
|
+
|
290
|
+
---
|
291
|
+
|
292
|
+
## [v0.1.0] - 2015-04-15
|
293
|
+
|
294
|
+
Initial gem release
|
295
|
+
|
296
|
+
### Features
|
297
|
+
- Rescuetime has a version number
|
298
|
+
- `Rescuetime::Client` exists
|
299
|
+
- `Rescuetime::Client#api_key?` returns existence of api key
|
300
|
+
- `Rescuetime::Client#api_key=` overwrites api key
|
301
|
+
- `Rescuetime::Client#activities` returns list of activities
|
302
|
+
|
303
|
+
[Unreleased]: https://github.com/leesharma/rescuetime/compare/v0.4.0...HEAD
|
304
|
+
[v0.4.0]: https://github.com/leesharma/rescuetime/compare/v0.3.3...v0.4.0
|
305
|
+
[v0.3.3]: https://github.com/leesharma/rescuetime/compare/v0.3.2...v0.3.3
|
306
|
+
[v0.3.2]: https://github.com/leesharma/rescuetime/compare/v0.3.1...v0.3.2
|
307
|
+
[v0.3.1]: https://github.com/leesharma/rescuetime/compare/v0.3.0...v0.3.1
|
308
|
+
[v0.3.0]: https://github.com/leesharma/rescuetime/compare/v0.2.0...v0.3.0
|
309
|
+
[v0.2.0]: https://github.com/leesharma/rescuetime/compare/v0.1.0...v0.2.0
|
310
|
+
[v0.1.0]: https://github.com/leesharma/rescuetime/commits/v0.1.0
|
data/README.md
CHANGED
@@ -152,7 +152,7 @@ require 'rescuetime'
|
|
152
152
|
Rescuetime ships with two report formats: CSV and Array. If you would like your
|
153
153
|
report in a different format, don't worry–it's easy to add a custom formatter.
|
154
154
|
|
155
|
-
|
155
|
+
Three things are required to add a custom formatter:
|
156
156
|
|
157
157
|
1. [Write a class](#writing-a-formatter) within the module
|
158
158
|
`Rescuetime::Formatters` that inherits from `Rescuetime::Formatters::BaseFormatter`
|
@@ -234,6 +234,21 @@ Rescuetime.configure do |config|
|
|
234
234
|
end
|
235
235
|
```
|
236
236
|
|
237
|
+
##### Rails Example
|
238
|
+
|
239
|
+
For example, in a Rails app, you could add the configuration file to `config/initializers`:
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
# config/initializers/rescuetime.rb
|
243
|
+
Rescuetime.configure do |config|
|
244
|
+
path = File.expand_path('../../formatters/*_formatter.rb', __FILE__)
|
245
|
+
config.formatter_paths += [path]
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
249
|
+
Rails can now find any formatters ending in `_formatter.rb` in the folder `config/formatters`
|
250
|
+
(ex. `config/formatters/xml_formatter.rb`).
|
251
|
+
|
237
252
|
### Finding Answers (Documentation)
|
238
253
|
|
239
254
|
For more details, please see [official gem documentation](http://www.rubydoc.info/gems/rescuetime) or [read the wiki](https://github.com/leesharma/rescuetime/wiki).
|
data/lib/rescuetime/version.rb
CHANGED
data/rescuetime.gemspec
CHANGED
@@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
19
19
|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
spec.bindir = '
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.bindir = 'bin'
|
22
21
|
spec.require_paths = ['lib']
|
23
22
|
|
24
23
|
spec.required_ruby_version = '>= 2.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rescuetime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Sharma
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- ".rubocop.yml"
|
145
145
|
- ".rubocop_todo.yml"
|
146
146
|
- ".travis.yml"
|
147
|
+
- CHANGELOG.md
|
147
148
|
- CODE_OF_CONDUCT.md
|
148
149
|
- CONTRIBUTING.md
|
149
150
|
- Gemfile
|