togglv8 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -9
- data/lib/togglv8/projects.rb +2 -2
- data/lib/togglv8/tags.rb +2 -2
- data/lib/togglv8/tasks.rb +1 -1
- data/lib/togglv8/version.rb +1 -1
- data/lib/togglv8.rb +3 -3
- data/spec/lib/togglv8/tasks_spec.rb +1 -1
- data/spec/lib/togglv8/time_entries_spec.rb +73 -3
- data/spec/togglv8_spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22bb1bdda3a22f278bdf76e48502f61e7d912a33
|
4
|
+
data.tar.gz: 0491588afd3dafa669ec03a96e2e67c06123c5ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0d1955a24393a0dd861c06f3f3721630610569fa9a1c9eb376fc24d045929914b6fe042260b13443be2d6622843da21b82a1ba9a1fb0b4e5ad64a1a1a92037
|
7
|
+
data.tar.gz: d2d0b75801710403184d2ac07e99faa407ce38bd3db5f37ee8a4406ac60bba8eb8b6895f1c30847d503a1a1b02e59075848169c1f05fbf6152128d75f139d351
|
data/README.md
CHANGED
@@ -77,14 +77,6 @@ Run `rdoc` to generate documentation. Open `doc/index.html` in your browser.
|
|
77
77
|
|
78
78
|
Also available on [DocumentUp](https://documentup.com/kanet77/togglv8)
|
79
79
|
|
80
|
-
## Test Coverage
|
81
|
-
|
82
|
-
Open `coverage/index.html` to see test coverage.
|
83
|
-
|
84
|
-
As of 2015-12-10, coverage is "98.04% covered at 9.5 hits/line" according to [SimpleCov](https://rubygems.org/gems/simplecov).
|
85
|
-
|
86
|
-
**Note:** Coverage is 91.2% when Pro account features are not tested.
|
87
|
-
|
88
80
|
## Acknowledgements
|
89
81
|
|
90
82
|
- Thanks to [Koen Van der Auwera](https://github.com/atog) for the [Ruby Wrapper for Toggl API v6](https://github.com/atog/toggl)
|
@@ -102,4 +94,4 @@ Pull Requests that include tests are **much** more likely to be accepted and mer
|
|
102
94
|
|
103
95
|
## License
|
104
96
|
|
105
|
-
Copyright (c) 2013-
|
97
|
+
Copyright (c) 2013-2016 Tom Kane. Released under the [MIT License](http://opensource.org/licenses/mit-license.php). See [LICENSE.txt](LICENSE.txt) for details.
|
data/lib/togglv8/projects.rb
CHANGED
@@ -56,7 +56,7 @@ module TogglV8
|
|
56
56
|
#
|
57
57
|
# Examples
|
58
58
|
#
|
59
|
-
# toggl.create_project({ name
|
59
|
+
# toggl.create_project({ :name => 'My project', :wid => 1060392 })
|
60
60
|
# => {"id"=>10918774,
|
61
61
|
# "wid"=>1060392,
|
62
62
|
# "name"=>"project5",
|
@@ -73,7 +73,7 @@ module TogglV8
|
|
73
73
|
# See Toggl {Create Project}[https://github.com/toggl/toggl_api_docs/blob/master/chapters/projects.md#create-project]
|
74
74
|
def create_project(params)
|
75
75
|
requireParams(params, ['name', 'wid'])
|
76
|
-
post "projects", {project
|
76
|
+
post "projects", { 'project' => params }
|
77
77
|
end
|
78
78
|
|
79
79
|
# [Get project data](https://github.com/toggl/toggl_api_docs/blob/master/chapters/projects.md#get-project-data)
|
data/lib/togglv8/tags.rb
CHANGED
@@ -10,10 +10,10 @@ module TogglV8
|
|
10
10
|
|
11
11
|
def create_tag(params)
|
12
12
|
requireParams(params, ['name', 'wid'])
|
13
|
-
post "tags", {tag
|
13
|
+
post "tags", { 'tag' => params }
|
14
14
|
end
|
15
15
|
|
16
|
-
# ex: update_tag(12345, {name
|
16
|
+
# ex: update_tag(12345, { :name => "same tame game" })
|
17
17
|
def update_tag(tag_id, params)
|
18
18
|
put "tags/#{tag_id}", { 'tag' => params }
|
19
19
|
end
|
data/lib/togglv8/tasks.rb
CHANGED
@@ -28,7 +28,7 @@ module TogglV8
|
|
28
28
|
get "tasks/#{task_id}"
|
29
29
|
end
|
30
30
|
|
31
|
-
# ex: update_task(1894675, {active
|
31
|
+
# ex: update_task(1894675, { :active => true, :estimated_seconds => 4500, :fields => "done_seconds,uname"})
|
32
32
|
def update_task(task_id, params)
|
33
33
|
put "tasks/#{task_id}", { 'task' => params }
|
34
34
|
end
|
data/lib/togglv8/version.rb
CHANGED
data/lib/togglv8.rb
CHANGED
@@ -15,8 +15,8 @@ require_relative 'togglv8/users'
|
|
15
15
|
require_relative 'togglv8/version'
|
16
16
|
require_relative 'togglv8/workspaces'
|
17
17
|
|
18
|
-
# mode
|
19
|
-
Oj.default_options = { mode
|
18
|
+
# :mode => :compat will convert symbols to strings
|
19
|
+
Oj.default_options = { :mode => :compat }
|
20
20
|
|
21
21
|
module TogglV8
|
22
22
|
TOGGL_API_URL = 'https://www.toggl.com/api/'
|
@@ -67,7 +67,7 @@ module TogglV8
|
|
67
67
|
attr_writer :conn
|
68
68
|
|
69
69
|
def self.connection(username, password, opts={})
|
70
|
-
Faraday.new(url
|
70
|
+
Faraday.new(:url => TOGGL_API_V8_URL, :ssl => {:verify => true}) do |faraday|
|
71
71
|
faraday.request :url_encoded
|
72
72
|
faraday.response :logger, Logger.new('faraday.log') if opts[:log]
|
73
73
|
faraday.adapter Faraday.default_adapter
|
@@ -78,7 +78,7 @@ describe 'Tasks', :pro_account do
|
|
78
78
|
expect(active_flags).to match_array([true, true, true])
|
79
79
|
|
80
80
|
t_ids = [@task1, @task2, @task3].map { |t| t['id'] }
|
81
|
-
params = { 'active'
|
81
|
+
params = { 'active' => false }
|
82
82
|
@toggl.update_tasks(t_ids, params)
|
83
83
|
|
84
84
|
# end with no active tasks
|
@@ -75,6 +75,76 @@ describe 'Time Entries' do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
context '+ UTC offset' do
|
79
|
+
# ISO8601 times with positive '+' UTC offsets must be properly encoded
|
80
|
+
|
81
|
+
before :each do
|
82
|
+
time_entry_info = {
|
83
|
+
'wid' => @workspace_id,
|
84
|
+
'start' => '2016-01-22T12:08:14+02:00',
|
85
|
+
'duration' => 77
|
86
|
+
}
|
87
|
+
|
88
|
+
@expected = time_entry_info.clone
|
89
|
+
|
90
|
+
@time_entry = @toggl.create_time_entry(time_entry_info)
|
91
|
+
end
|
92
|
+
|
93
|
+
after :each do
|
94
|
+
@toggl.delete_time_entry(@time_entry['id'])
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'creates a time entry' do
|
98
|
+
expect(@time_entry).to include(@expected)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'requires a workspace, project, or task to create' do
|
102
|
+
time_entry_info = {
|
103
|
+
'start' => '2016-01-22T12:08:14+02:00',
|
104
|
+
'duration' => 77
|
105
|
+
}
|
106
|
+
|
107
|
+
expect {
|
108
|
+
@toggl.create_time_entry(time_entry_info)
|
109
|
+
}.to raise_error(ArgumentError)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'gets a time entry' do
|
113
|
+
retrieved_time_entry = @toggl.get_time_entry(@time_entry['id'])
|
114
|
+
|
115
|
+
['start', 'stop'].each do |key|
|
116
|
+
expect(retrieved_time_entry[key]).to eq_ts @time_entry[key]
|
117
|
+
retrieved_time_entry.delete(key)
|
118
|
+
@time_entry.delete(key)
|
119
|
+
end
|
120
|
+
|
121
|
+
expect(retrieved_time_entry).to eq @time_entry
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'updates a time entry' do
|
125
|
+
time_entry_info = {
|
126
|
+
'start' => '2010-02-13T23:31:30+07:00',
|
127
|
+
'duration' => 42
|
128
|
+
}
|
129
|
+
|
130
|
+
expected = time_entry_info.clone
|
131
|
+
|
132
|
+
time_entry_updated = @toggl.update_time_entry(@time_entry['id'], time_entry_info)
|
133
|
+
expect(time_entry_updated).to include(expected)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'deletes a time entry' do
|
137
|
+
existing_time_entry = @toggl.get_time_entry(@time_entry['id'])
|
138
|
+
expect(existing_time_entry.has_key?('server_deleted_at')).to eq false
|
139
|
+
|
140
|
+
deleted_time_entry = @toggl.delete_time_entry(@time_entry['id'])
|
141
|
+
expect(deleted_time_entry).to eq "[#{ @time_entry['id'] }]"
|
142
|
+
|
143
|
+
zombie_time_entry = @toggl.get_time_entry(@time_entry['id'])
|
144
|
+
expect(zombie_time_entry.has_key?('server_deleted_at')).to eq true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
78
148
|
context 'multiple time entries' do
|
79
149
|
before :all do
|
80
150
|
time_entry_info = {
|
@@ -110,17 +180,17 @@ describe 'Time Entries' do
|
|
110
180
|
end
|
111
181
|
|
112
182
|
it 'gets time entries after start_date (up till now)' do
|
113
|
-
ids = @toggl.get_time_entries({start_date
|
183
|
+
ids = @toggl.get_time_entries({:start_date => @now - 1}).map { |t| t['id']}
|
114
184
|
expect(ids).to eq [ @now_id ]
|
115
185
|
end
|
116
186
|
|
117
187
|
it 'gets time entries between start_date and end_date' do
|
118
|
-
ids = @toggl.get_time_entries({start_date
|
188
|
+
ids = @toggl.get_time_entries({:start_date => @now - 1, :end_date => @now + 1}).map { |t| t['id']}
|
119
189
|
expect(ids).to eq [ @now_id ]
|
120
190
|
end
|
121
191
|
|
122
192
|
it 'gets time entries in the future' do
|
123
|
-
ids = @toggl.get_time_entries({start_date
|
193
|
+
ids = @toggl.get_time_entries({:start_date => @now - 1, :end_date => @now + 8}).map { |t| t['id']}
|
124
194
|
expect(ids).to eq [ @now_id, @next_week_id ]
|
125
195
|
end
|
126
196
|
end
|
data/spec/togglv8_spec_helper.rb
CHANGED
@@ -50,7 +50,7 @@ class TogglV8SpecHelper
|
|
50
50
|
|
51
51
|
def self.delete_all_time_entries(toggl)
|
52
52
|
time_entries = toggl.get_time_entries(
|
53
|
-
{ start_date
|
53
|
+
{ :start_date => DateTime.now - 30, :end_date => DateTime.now + 30 } )
|
54
54
|
unless time_entries.nil?
|
55
55
|
time_entry_ids ||= time_entries.map { |t| t['id'] }
|
56
56
|
@logger.debug("Deleting #{time_entry_ids.length} time_entries")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: togglv8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|