TokiCLI 0.3.0 → 0.3.1
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/.ruby-version +1 -0
- data/.travis.yml +17 -1
- data/CHANGELOG.md +4 -0
- data/README.md +18 -4
- data/TokiCLI.gemspec +2 -1
- data/lib/TokiCLI/fileops.rb +1 -1
- data/lib/TokiCLI/version.rb +1 -1
- data/lib/TokiCLI/view.rb +2 -2
- data/spec/TokiCLI_spec.rb +101 -19
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1db92272981801ffe206b7deb7b686bd194ceded
|
4
|
+
data.tar.gz: 0b556e5a4319091462a8eda7b8602e4a9d2779ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ca756456fc395d8e76fab04291802be0665183b50c2fb7e752690cff6c2f0f6268fd3e28e7eeb59f9933d39a5fa12ba93b2f4e68186a330c773ac4f0186c277
|
7
|
+
data.tar.gz: ebf7afa8a4f1fd14e66015050095c58854a8ff3c8e7f7c2dc96b73aaa888559de042f746c8f16590adaee68b7a868570b334ae7bcfcd9518b2612e87f6598d96
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/.travis.yml
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
2
4
|
rvm:
|
3
|
-
- 2.1.
|
5
|
+
- "2.1.0"
|
6
|
+
- "2.0.0"
|
7
|
+
|
8
|
+
script: 'bundle exec rake spec'
|
9
|
+
|
10
|
+
branches:
|
11
|
+
only:
|
12
|
+
- master
|
13
|
+
|
14
|
+
notifications:
|
15
|
+
email:
|
16
|
+
- ericdejonckheere@gmail.com
|
17
|
+
|
18
|
+
before_install:
|
19
|
+
- gem install CFPropertyList -v '2.2.8'
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[](http://badge.fury.io/rb/TokiCLI)
|
2
|
+
|
3
|
+
[](https://github.com/ericdke/TokiCLI)
|
4
|
+
|
5
|
+
|
1
6
|
# TokiCLI
|
2
7
|
|
3
8
|
Toki.app command-line client and API server.
|
@@ -6,6 +11,17 @@ Access your Toki data from the local database or from the App.net backup channel
|
|
6
11
|
|
7
12
|

|
8
13
|
|
14
|
+
---
|
15
|
+
|
16
|
+
**UPDATE**
|
17
|
+
|
18
|
+
Toki.app will cease to function when App.net will shut down their servers on 2017/03/14.
|
19
|
+
|
20
|
+
TokiCLI will continue to function but will then be irrelevant as there will not be anything to track anymore via Toki.app (and TokiCLI's App.net-related will also cease to function, of course).
|
21
|
+
|
22
|
+
You will still be able to read and analyse your existing data with TokiCLI.
|
23
|
+
|
24
|
+
---
|
9
25
|
|
10
26
|
## Installation
|
11
27
|
|
@@ -222,11 +238,9 @@ You can also use the TokiCLI API in another app:
|
|
222
238
|
|
223
239
|
### Basic
|
224
240
|
|
225
|
-
Create a basic TokiCLI API instance:
|
226
|
-
|
227
|
-
`toki = TokiCLI::TokiAPI.new("#{~/Library/path/to/tokiapp/db}")`
|
241
|
+
Create a basic TokiCLI API instance without referencing bundles:
|
228
242
|
|
229
|
-
|
243
|
+
`toki = TokiCLI::TokiAPI.new("#{~/Library/path/to/tokiapp/db}", {})`
|
230
244
|
|
231
245
|
### With apps names
|
232
246
|
|
data/TokiCLI.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
+
spec.required_ruby_version = '< 2.2.0'
|
20
21
|
|
21
22
|
spec.add_dependency "thor", "~> 0.18"
|
22
23
|
spec.add_dependency "rest-client", "~> 1.6"
|
@@ -28,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.add_dependency 'sinatra-assetpack', "~> 0.3", '>= 0.3.2'
|
29
30
|
spec.add_dependency "sinatra-contrib", '~> 1.4', '>= 1.4.2'
|
30
31
|
|
31
|
-
spec.add_development_dependency "bundler", "~> 1.
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
32
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
33
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
34
35
|
spec.add_development_dependency "coveralls"
|
data/lib/TokiCLI/fileops.rb
CHANGED
@@ -3,7 +3,7 @@ module TokiCLI
|
|
3
3
|
class FileOps
|
4
4
|
|
5
5
|
require 'fileutils'
|
6
|
-
require '
|
6
|
+
require 'cfpropertylist'
|
7
7
|
require 'yaml'
|
8
8
|
|
9
9
|
attr_accessor :home_path, :toki_path, :db_path, :db_file, :bundles_file, :bundles, :config_file, :config_path, :config, :data_path, :files_path, :user_file, :log_path
|
data/lib/TokiCLI/version.rb
CHANGED
data/lib/TokiCLI/view.rb
CHANGED
@@ -8,7 +8,7 @@ module TokiCLI
|
|
8
8
|
|
9
9
|
def initialize settings = {}
|
10
10
|
@settings = if settings.empty?
|
11
|
-
{"table"=>{"width"=>
|
11
|
+
{"table"=>{"width"=>120}} # force default if no initialization
|
12
12
|
else
|
13
13
|
settings
|
14
14
|
end
|
@@ -146,7 +146,7 @@ module TokiCLI
|
|
146
146
|
|
147
147
|
def app_row_with_name(obj)
|
148
148
|
max = @settings['table']['width'] / 3
|
149
|
-
[width(max + 5, obj['bundle']), width(max -
|
149
|
+
[width(max + 5, obj['bundle']), width(max - 10, obj['name']), readable_time(obj['total']['time'])]
|
150
150
|
end
|
151
151
|
|
152
152
|
def app_row(obj)
|
data/spec/TokiCLI_spec.rb
CHANGED
@@ -2,9 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe TokiCLI do
|
4
4
|
|
5
|
+
class Fake
|
6
|
+
attr_accessor :home_path, :toki_path, :db_path, :db_file, :bundles_file, :bundles, :config_file, :config_path, :config, :data_path, :files_path, :user_file, :log_path
|
7
|
+
def db_file
|
8
|
+
'spec/mock/mock.sqlite3'
|
9
|
+
end
|
10
|
+
def config
|
11
|
+
{}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
before do
|
6
|
-
TokiCLI::FileOps.
|
7
|
-
TokiCLI::FileOps.any_instance.stub(:bundles).and_return(nil)
|
16
|
+
TokiCLI::FileOps.stub(:new).and_return(Fake.new)
|
8
17
|
end
|
9
18
|
|
10
19
|
describe "#version" do
|
@@ -92,7 +101,7 @@ describe TokiCLI do
|
|
92
101
|
printed = capture_stdout do
|
93
102
|
TokiCLI::App.start(['activity', '--day', '2014-09-14'])
|
94
103
|
end
|
95
|
-
expect(printed).to include *['
|
104
|
+
expect(printed).to include *['3009986780794979448', '279578532860092796', '5321635596015812810']
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
@@ -101,7 +110,7 @@ describe TokiCLI do
|
|
101
110
|
printed = capture_stdout do
|
102
111
|
TokiCLI::App.start(['activity', '--since', '2014-09-14'])
|
103
112
|
end
|
104
|
-
expect(printed).to include *['
|
113
|
+
expect(printed).to include *['3009986780794979448', '279578532860092796', '5321635596015812810', '2450616761580369798', '7557789946794681026']
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
@@ -110,7 +119,7 @@ describe TokiCLI do
|
|
110
119
|
printed = capture_stdout do
|
111
120
|
TokiCLI::App.start(['bundle', 'com.apple.iTunes'])
|
112
121
|
end
|
113
|
-
expect(printed).to include *['
|
122
|
+
expect(printed).to include *['93837223385103975', '9048025340952260608', '8045504996000693405']
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
@@ -265,8 +274,8 @@ describe TokiCLI::TokiAPI do
|
|
265
274
|
expect(resp['meta']['code']).to eq 200
|
266
275
|
expect(resp['meta']['request']['command']).to eq 'bundle_log'
|
267
276
|
expect(resp['data'].size).to eq 1397
|
268
|
-
expect(resp['data']['6853206097451538432'].to_a).to
|
269
|
-
expect(resp['data']['8223841650221385607'].to_a).to
|
277
|
+
expect(resp['data']['6853206097451538432'].to_a).to include *[["bundle", "com.apple.finder"], ["name", nil], ["duration", {"seconds"=>10, "time"=>{"hours"=>0, "minutes"=>0, "seconds"=>10}}]]
|
278
|
+
expect(resp['data']['8223841650221385607'].to_a).to include *[["bundle", "com.apple.finder"], ["name", nil], ["duration", {"seconds"=>70, "time"=>{"hours"=>0, "minutes"=>1, "seconds"=>10}}]]
|
270
279
|
end
|
271
280
|
end
|
272
281
|
|
@@ -277,8 +286,8 @@ describe TokiCLI::TokiAPI do
|
|
277
286
|
expect(resp['meta']['code']).to eq 200
|
278
287
|
expect(resp['meta']['request']['command']).to eq 'bundle_log_since'
|
279
288
|
expect(resp['data'].size).to eq 131
|
280
|
-
expect(resp['data']['3343489613556420396'].to_a).to
|
281
|
-
expect(resp['data']['8223841650221385607'].to_a).to
|
289
|
+
expect(resp['data']['3343489613556420396'].to_a).to include *[["bundle", "com.apple.finder"], ["name", nil], ["duration", {"seconds"=>15, "time"=>{"hours"=>0, "minutes"=>0, "seconds"=>15}}]]
|
290
|
+
expect(resp['data']['8223841650221385607'].to_a).to include *[["bundle", "com.apple.finder"], ["name", nil], ["duration", {"seconds"=>70, "time"=>{"hours"=>0, "minutes"=>1, "seconds"=>10}}]]
|
282
291
|
end
|
283
292
|
end
|
284
293
|
|
@@ -290,8 +299,8 @@ describe TokiCLI::TokiAPI do
|
|
290
299
|
expect(resp['meta']['request']['command']).to eq 'bundle_log_before'
|
291
300
|
expect(resp['data'].size).to eq 1266
|
292
301
|
arr = resp['data'].to_a
|
293
|
-
expect(arr.first).to
|
294
|
-
expect(arr.last).to
|
302
|
+
expect(arr.first).to include "6853206097451538432"
|
303
|
+
expect(arr.last).to include "3110227595022506229"
|
295
304
|
end
|
296
305
|
end
|
297
306
|
|
@@ -303,8 +312,8 @@ describe TokiCLI::TokiAPI do
|
|
303
312
|
expect(resp['meta']['request']['command']).to eq 'bundle_log_range'
|
304
313
|
expect(resp['data'].size).to eq 26
|
305
314
|
arr = resp['data'].to_a
|
306
|
-
expect(arr.first).to
|
307
|
-
expect(arr.last).to
|
315
|
+
expect(arr.first).to include "3343489613556420396"
|
316
|
+
expect(arr.last).to include "249678006045203865"
|
308
317
|
end
|
309
318
|
end
|
310
319
|
|
@@ -317,8 +326,8 @@ describe TokiCLI::TokiAPI do
|
|
317
326
|
expect(resp['meta']['request']['args']).to eq ["com.apple.finder", "2014-09-01", "2014-09-02"]
|
318
327
|
expect(resp['data'].size).to eq 13
|
319
328
|
arr = resp['data'].to_a
|
320
|
-
expect(arr.first).to
|
321
|
-
expect(arr.last).to
|
329
|
+
expect(arr.first).to include "3343489613556420396"
|
330
|
+
expect(arr.last).to include "8777542996540152763"
|
322
331
|
end
|
323
332
|
end
|
324
333
|
|
@@ -331,8 +340,8 @@ describe TokiCLI::TokiAPI do
|
|
331
340
|
expect(resp['meta']['request']['args']).to eq ["2014-09-13"]
|
332
341
|
expect(resp['data'].size).to eq 87
|
333
342
|
arr = resp['data'].to_a
|
334
|
-
expect(arr.first).to
|
335
|
-
expect(arr.last).to
|
343
|
+
expect(arr.first).to include "1226267152535471391"
|
344
|
+
expect(arr.last).to include "7557789946794681026"
|
336
345
|
end
|
337
346
|
end
|
338
347
|
|
@@ -345,10 +354,83 @@ describe TokiCLI::TokiAPI do
|
|
345
354
|
expect(resp['meta']['request']['args']).to eq ["2014-09-13"]
|
346
355
|
expect(resp['data'].size).to eq 17
|
347
356
|
arr = resp['data'].to_a
|
348
|
-
expect(arr.first).to
|
349
|
-
expect(arr.last).to
|
357
|
+
expect(arr.first).to include "6362298701774470696"
|
358
|
+
expect(arr.last).to include "2496889557830869773"
|
350
359
|
end
|
351
360
|
end
|
352
361
|
|
362
|
+
end
|
363
|
+
|
364
|
+
describe TokiCLI::Helpers do
|
365
|
+
|
366
|
+
let(:helpers) { TokiCLI::Helpers.new }
|
367
|
+
|
368
|
+
describe "#sec_to_time" do
|
369
|
+
it "converts unix time in a hash of hours/minutes/seconds" do
|
370
|
+
result = helpers.sec_to_time(12345)
|
371
|
+
expect(result['hours']).to eq 3
|
372
|
+
expect(result['minutes']).to eq 25
|
373
|
+
expect(result['seconds']).to eq 45
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
describe "#epoch_to_date" do
|
378
|
+
it "converts unix date to iso time" do
|
379
|
+
result = helpers.epoch_to_date(1411075048)
|
380
|
+
expect(result.to_s).to include '2014-09-18'
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
describe "#check_date_validity" do
|
385
|
+
it "converts a string to a date object" do
|
386
|
+
result = helpers.check_date_validity('2014-09-18')
|
387
|
+
expect(result.iso8601[0..9]).to eq '2014-09-18'
|
388
|
+
end
|
389
|
+
it "returns false if string is incorrect" do
|
390
|
+
result = helpers.check_date_validity('yolo')
|
391
|
+
expect(result).to be false
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
describe "#readable_time" do
|
396
|
+
it "converts a hash of hours/minutes/seconds to a string" do
|
397
|
+
result = helpers.readable_time({'hours' => 12, 'minutes' => 33, 'seconds' => 7})
|
398
|
+
expect(result).to eq '12h 33m 07s'
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
describe "#readable_time_log" do
|
403
|
+
it "converts a hash of hours/minutes/seconds to a string" do
|
404
|
+
result = helpers.readable_time_log({'hours' => 12, 'minutes' => 33, 'seconds' => 7})
|
405
|
+
expect(result).to eq '33m 07s'
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe "#calc_apps_total" do
|
410
|
+
it "sums the number of seconds in each object" do
|
411
|
+
result = helpers.calc_apps_total([{'total' => {'seconds' => 7}}, {'total' => {'seconds' => 10}}])
|
412
|
+
expect(result).to eq 17
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
describe "#calc_logs_total" do
|
417
|
+
it "sums the number of seconds in each object" do
|
418
|
+
result = helpers.calc_logs_total(
|
419
|
+
{
|
420
|
+
1 => {
|
421
|
+
'duration' => {
|
422
|
+
'seconds' => 7
|
423
|
+
}
|
424
|
+
},
|
425
|
+
2 => {
|
426
|
+
'duration' => {
|
427
|
+
'seconds' => 10
|
428
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
)
|
432
|
+
expect(result).to eq 17
|
433
|
+
end
|
434
|
+
end
|
353
435
|
|
354
436
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: TokiCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -160,14 +160,14 @@ dependencies:
|
|
160
160
|
requirements:
|
161
161
|
- - "~>"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '1.
|
163
|
+
version: '1.5'
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
168
|
- - "~>"
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version: '1.
|
170
|
+
version: '1.5'
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: rake
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- ".coveralls.yml"
|
225
225
|
- ".gitignore"
|
226
226
|
- ".rspec"
|
227
|
+
- ".ruby-version"
|
227
228
|
- ".travis.yml"
|
228
229
|
- CHANGELOG.md
|
229
230
|
- Gemfile
|
@@ -614,9 +615,9 @@ require_paths:
|
|
614
615
|
- lib
|
615
616
|
required_ruby_version: !ruby/object:Gem::Requirement
|
616
617
|
requirements:
|
617
|
-
- - "
|
618
|
+
- - "<"
|
618
619
|
- !ruby/object:Gem::Version
|
619
|
-
version:
|
620
|
+
version: 2.2.0
|
620
621
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
621
622
|
requirements:
|
622
623
|
- - ">="
|
@@ -624,7 +625,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
624
625
|
version: '0'
|
625
626
|
requirements: []
|
626
627
|
rubyforge_project:
|
627
|
-
rubygems_version: 2.4.
|
628
|
+
rubygems_version: 2.4.5
|
628
629
|
signing_key:
|
629
630
|
specification_version: 4
|
630
631
|
summary: Toki.app command-line client and API server
|