time_log_robot 0.1.2.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -17
- data/Rakefile +5 -3
- data/lib/time_log_robot/toggl/report.rb +23 -1
- data/lib/time_log_robot/version.rb +1 -1
- data/test/test_helper.rb +0 -1
- data/time_log_robot.gemspec +2 -4
- metadata +9 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0437011ed9ab0e3431a24088f3c80d3335afb95b
|
4
|
+
data.tar.gz: 4af3210d01a89d4edd79e9a702f321b34446cb47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd0f6e19e8bd804d5f9d369785bf2f55a9b8eb1a905deaaae0f7b628fdf54f7a186d60e270f0da826c519523662501ccea9925e454b5a798579321fba4a41ed
|
7
|
+
data.tar.gz: ab8b0d0de4d4332abbe2e15ef5360fdcf18881d15d66ab8a5b8568d32bffdee2c7b8760d8bc8cf4c78866ec08a32cfe25e88b507294129af683f1914cb002cea
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
time_log_robot (0.1.
|
4
|
+
time_log_robot (0.1.3)
|
5
5
|
activesupport (~> 4.2, >= 4.2.6)
|
6
6
|
commander (~> 4.1, >= 4.1.6)
|
7
7
|
httparty (~> 0.13, >= 0.13.0)
|
@@ -18,7 +18,6 @@ GEM
|
|
18
18
|
tzinfo (~> 1.1)
|
19
19
|
ansi (1.5.0)
|
20
20
|
builder (3.2.2)
|
21
|
-
coderay (1.1.1)
|
22
21
|
commander (4.1.6)
|
23
22
|
highline (~> 1.6.11)
|
24
23
|
highline (1.6.21)
|
@@ -26,27 +25,16 @@ GEM
|
|
26
25
|
json (~> 1.8)
|
27
26
|
multi_xml (>= 0.5.2)
|
28
27
|
i18n (0.7.0)
|
29
|
-
interception (0.5)
|
30
28
|
json (1.8.3)
|
31
|
-
method_source (0.8.2)
|
32
29
|
minitest (5.8.4)
|
33
|
-
minitest-emoji (2.0.0)
|
34
30
|
minitest-reporters (1.1.9)
|
35
31
|
ansi
|
36
32
|
builder
|
37
33
|
minitest (>= 5.0)
|
38
34
|
ruby-progressbar
|
39
35
|
multi_xml (0.5.5)
|
40
|
-
pry (0.10.3)
|
41
|
-
coderay (~> 1.1.0)
|
42
|
-
method_source (~> 0.8.1)
|
43
|
-
slop (~> 3.4)
|
44
|
-
pry-rescue (1.4.4)
|
45
|
-
interception (>= 0.5)
|
46
|
-
pry
|
47
36
|
rake (10.5.0)
|
48
37
|
ruby-progressbar (1.8.1)
|
49
|
-
slop (3.6.0)
|
50
38
|
thread_safe (0.3.5)
|
51
39
|
tzinfo (1.2.2)
|
52
40
|
thread_safe (~> 0.1)
|
@@ -56,10 +44,8 @@ PLATFORMS
|
|
56
44
|
|
57
45
|
DEPENDENCIES
|
58
46
|
bundler (~> 1.3)
|
59
|
-
minitest
|
60
|
-
minitest-
|
61
|
-
minitest-reporters
|
62
|
-
pry-rescue
|
47
|
+
minitest (~> 5.8)
|
48
|
+
minitest-reporters (~> 1.1)
|
63
49
|
rake (~> 10.5)
|
64
50
|
time_log_robot!
|
65
51
|
|
data/Rakefile
CHANGED
@@ -5,13 +5,15 @@ desc 'Run in IRB for debugging'
|
|
5
5
|
task :console do
|
6
6
|
require 'irb'
|
7
7
|
require 'irb/completion'
|
8
|
-
require '
|
8
|
+
require 'pp'
|
9
|
+
require 'yaml'
|
10
|
+
require 'active_support'
|
11
|
+
require 'httparty'
|
12
|
+
Dir[File.expand_path "lib/**/*.rb"].each{|file| require_relative file }
|
9
13
|
ARGV.clear
|
10
14
|
IRB.start
|
11
15
|
end
|
12
16
|
|
13
|
-
# @TODO Uncomment when it works! - `rake test`
|
14
|
-
|
15
17
|
Rake::TestTask.new do |t|
|
16
18
|
t.libs << 'test'
|
17
19
|
t.test_files = FileList['test/**/*_test.rb']
|
@@ -7,12 +7,14 @@ module TimeLogRobot
|
|
7
7
|
|
8
8
|
base_uri 'https://toggl.com/reports/api/v2'
|
9
9
|
|
10
|
+
# TODO Refactor to avoid having to pass around `since` so much
|
10
11
|
class << self
|
11
12
|
def fetch(since: nil)
|
12
13
|
since ||= Date.today.beginning_of_week(:saturday).to_time
|
13
14
|
response = get('/details', basic_auth: auth, query: query(since))
|
14
15
|
if response.success?
|
15
|
-
response['
|
16
|
+
pages = number_of_pages(response['total_count'])
|
17
|
+
aggregate_entries(response['data'], pages, since)
|
16
18
|
else
|
17
19
|
raise FetchError, response['error']
|
18
20
|
end
|
@@ -21,6 +23,26 @@ module TimeLogRobot
|
|
21
23
|
|
22
24
|
private
|
23
25
|
|
26
|
+
def aggregate_entries(entries, pages, since)
|
27
|
+
2.upto(pages) do |page|
|
28
|
+
entries += get_entries_from_next_page(since, page)
|
29
|
+
end
|
30
|
+
entries
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_entries_from_next_page(since, page)
|
34
|
+
built_query = query(since).merge(page: page)
|
35
|
+
response = get('/details', basic_auth: auth, query: built_query)
|
36
|
+
response['data']
|
37
|
+
end
|
38
|
+
|
39
|
+
def number_of_pages(count)
|
40
|
+
remaining_entries = count % 50
|
41
|
+
pages = count / 50
|
42
|
+
pages += 1 if remaining_entries > 0
|
43
|
+
return pages
|
44
|
+
end
|
45
|
+
|
24
46
|
def auth
|
25
47
|
{
|
26
48
|
username: token,
|
data/test/test_helper.rb
CHANGED
data/time_log_robot.gemspec
CHANGED
@@ -21,10 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = '>= 2.0'
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.5'
|
24
|
-
spec.add_development_dependency 'minitest'
|
25
|
-
spec.add_development_dependency 'minitest-
|
26
|
-
spec.add_development_dependency 'minitest-reporters'
|
27
|
-
spec.add_development_dependency 'pry-rescue'
|
24
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
25
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
28
26
|
|
29
27
|
spec.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.6'
|
30
28
|
spec.add_runtime_dependency 'commander', '~> 4.1', '>= 4.1.6'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_log_robot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark J. Lehman
|
@@ -42,58 +42,30 @@ dependencies:
|
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest-emoji
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '5.8'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '5.8'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: minitest-reporters
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-rescue
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
59
|
+
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
61
|
+
version: '1.1'
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
|
-
- - "
|
66
|
+
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
68
|
+
version: '1.1'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: activesupport
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|