wl 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wl.rb +1 -0
- data/lib/wl/cli.rb +6 -6
- data/lib/wl/client.rb +10 -2
- data/lib/wl/list.rb +16 -0
- data/lib/wl/version.rb +1 -1
- data/spec/cassettes/lists.yml +98 -0
- data/spec/wl/cli_spec.rb +14 -5
- data/spec/wl/client_spec.rb +26 -1
- data/spec/wl/list_spec.rb +7 -0
- metadata +9 -4
data/lib/wl.rb
CHANGED
data/lib/wl/cli.rb
CHANGED
@@ -11,7 +11,6 @@ module Wl
|
|
11
11
|
password = options[:password] || ui.ask('Wunderlist password: ') { |q| q.echo = '*' }
|
12
12
|
|
13
13
|
login = client.login(email, password)
|
14
|
-
dotwl.login(login)
|
15
14
|
|
16
15
|
say login.to_json
|
17
16
|
end
|
@@ -21,13 +20,14 @@ module Wl
|
|
21
20
|
say client.tasks.to_json
|
22
21
|
end
|
23
22
|
|
24
|
-
|
25
|
-
def
|
26
|
-
|
23
|
+
desc 'lists', 'Lists all your lists'
|
24
|
+
def lists
|
25
|
+
say client.lists.to_json
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
private
|
29
|
+
def client
|
30
|
+
@client ||= Wl::Client.new(dotwl: Dotwl.new)
|
31
31
|
end
|
32
32
|
|
33
33
|
def ui
|
data/lib/wl/client.rb
CHANGED
@@ -2,18 +2,26 @@ require 'shy'
|
|
2
2
|
require 'api_smith'
|
3
3
|
|
4
4
|
module Wl
|
5
|
-
class Client
|
5
|
+
class Client
|
6
|
+
include Shy
|
6
7
|
include APISmith::Client
|
7
8
|
base_uri 'https://api.wunderlist.com/'
|
9
|
+
shy :dotwl
|
8
10
|
|
9
11
|
def login(email, password)
|
10
|
-
post('login', extra_query: {email: email, password: password}, transformer: Login)
|
12
|
+
login = post('login', extra_query: {email: email, password: password}, transformer: Login)
|
13
|
+
dotwl.login(login)
|
14
|
+
login
|
11
15
|
end
|
12
16
|
|
13
17
|
def tasks
|
14
18
|
get('me/tasks', transformer: Task)
|
15
19
|
end
|
16
20
|
|
21
|
+
def lists
|
22
|
+
get('me/lists', transformer: List)
|
23
|
+
end
|
24
|
+
|
17
25
|
def base_request_options
|
18
26
|
if dotwl.token
|
19
27
|
{
|
data/lib/wl/list.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'api_smith'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
class List < APISmith::Smash
|
5
|
+
property :title
|
6
|
+
property :created_at
|
7
|
+
property :updated_at
|
8
|
+
property :version
|
9
|
+
property :local_identifier
|
10
|
+
property :position
|
11
|
+
property :type
|
12
|
+
property :id
|
13
|
+
property :owner_id
|
14
|
+
property :errors
|
15
|
+
end
|
16
|
+
end
|
data/lib/wl/version.rb
CHANGED
@@ -0,0 +1,98 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.wunderlist.com/me/lists?
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- Bearer 131378dbc2490bf87b6080ad6aeb758a46673270bbca9c7ea26f434473bbe741
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Cache-Control:
|
18
|
+
- must-revalidate, private, max-age=0
|
19
|
+
Content-Type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
Date:
|
22
|
+
- Mon, 25 Mar 2013 01:42:49 GMT
|
23
|
+
Etag:
|
24
|
+
- ! '"902626f7ad1045f6eda77cced7000115"'
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Status:
|
28
|
+
- 200 OK
|
29
|
+
Vary:
|
30
|
+
- Accept-Encoding
|
31
|
+
X-6w-Client-Status:
|
32
|
+
- unknown
|
33
|
+
X-6w-Timestamp:
|
34
|
+
- '1364175769'
|
35
|
+
X-Rack-Cache:
|
36
|
+
- miss
|
37
|
+
X-Ratelimit-Delay-Hard:
|
38
|
+
- '0'
|
39
|
+
X-Ratelimit-Delay-Soft:
|
40
|
+
- '840'
|
41
|
+
X-Request-Id:
|
42
|
+
- ce14d77649bb5889ee4638a164a3a824
|
43
|
+
X-Server:
|
44
|
+
- ip-10-226-39-240
|
45
|
+
Transfer-Encoding:
|
46
|
+
- chunked
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: US-ASCII
|
51
|
+
string: ! '[{"id":"ABIdAARgVkA","created_at":"2013-03-24T07:29:40Z","updated_at":"2013-03-24T07:29:40Z","title":"Private","local_identifier":"localId:prepopulated:AAIdAABMQ6I:List:private","version":1,"type":"List","owner_id":"AAIdAABMQ6I","position":8.0e-05},{"id":"ABIdAARgVkI","created_at":"2013-03-24T07:29:40Z","updated_at":"2013-03-24T07:29:40Z","title":"Work","local_identifier":"localId:prepopulated:AAIdAABMQ6I:List:work","version":1,"type":"List","owner_id":"AAIdAABMQ6I","position":10.0},{"id":"ABIdAARgVkM","created_at":"2013-03-24T07:29:40Z","updated_at":"2013-03-24T07:29:40Z","title":"Shopping","local_identifier":"localId:prepopulated:AAIdAABMQ6I:List:shopping","version":1,"type":"List","owner_id":"AAIdAABMQ6I","position":20.00002},{"id":"ABIdAARgVkQ","created_at":"2013-03-24T07:29:40Z","updated_at":"2013-03-24T07:29:40Z","title":"Movies
|
52
|
+
to Watch","local_identifier":"localId:prepopulated:AAIdAABMQ6I:List:movies","version":1,"type":"List","owner_id":"AAIdAABMQ6I","position":29.99998},{"id":"ABIdAARgVkU","created_at":"2013-03-24T07:29:40Z","updated_at":"2013-03-24T07:29:40Z","title":"Wishlist","local_identifier":"localId:prepopulated:AAIdAABMQ6I:List:wishlist","version":1,"type":"List","owner_id":"AAIdAABMQ6I","position":39.99992}]'
|
53
|
+
http_version:
|
54
|
+
recorded_at: Mon, 25 Mar 2013 01:42:53 GMT
|
55
|
+
- request:
|
56
|
+
method: get
|
57
|
+
uri: https://api.wunderlist.com/me/lists?
|
58
|
+
body:
|
59
|
+
encoding: US-ASCII
|
60
|
+
string: ''
|
61
|
+
headers: {}
|
62
|
+
response:
|
63
|
+
status:
|
64
|
+
code: 401
|
65
|
+
message: Unauthorized
|
66
|
+
headers:
|
67
|
+
Cache-Control:
|
68
|
+
- no-cache
|
69
|
+
Content-Type:
|
70
|
+
- application/json; charset=utf-8
|
71
|
+
Date:
|
72
|
+
- Mon, 25 Mar 2013 01:45:28 GMT
|
73
|
+
Server:
|
74
|
+
- nginx
|
75
|
+
Status:
|
76
|
+
- 401 Unauthorized
|
77
|
+
X-6w-Client-Status:
|
78
|
+
- unknown
|
79
|
+
X-6w-Timestamp:
|
80
|
+
- '1364175928'
|
81
|
+
X-Rack-Cache:
|
82
|
+
- miss
|
83
|
+
X-Ratelimit-Delay-Hard:
|
84
|
+
- '0'
|
85
|
+
X-Ratelimit-Delay-Soft:
|
86
|
+
- '893'
|
87
|
+
X-Request-Id:
|
88
|
+
- 91356407bc4e11c09b196c5665a3f43a
|
89
|
+
Content-Length:
|
90
|
+
- '85'
|
91
|
+
Connection:
|
92
|
+
- keep-alive
|
93
|
+
body:
|
94
|
+
encoding: US-ASCII
|
95
|
+
string: ! '{"errors":{"message":"You must be authenticated to continue.","type":"unauthorized"}}'
|
96
|
+
http_version:
|
97
|
+
recorded_at: Mon, 25 Mar 2013 01:45:31 GMT
|
98
|
+
recorded_with: VCR 2.4.0
|
data/spec/wl/cli_spec.rb
CHANGED
@@ -29,11 +29,6 @@ module Wl
|
|
29
29
|
output.should include('"name":"fake@example.com"')
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'stores the token' do
|
33
|
-
dotwl.should_receive(:login).with(an_instance_of(Login))
|
34
|
-
capture(:stdout) { subject }
|
35
|
-
end
|
36
|
-
|
37
32
|
context 'when an email and password are not provided' do
|
38
33
|
let(:args) { %w"login" }
|
39
34
|
|
@@ -65,5 +60,19 @@ module Wl
|
|
65
60
|
JSON.parse(output).should have(3).tasks
|
66
61
|
end
|
67
62
|
end
|
63
|
+
|
64
|
+
describe 'lists', vcr: {cassette_name: 'lists'} do
|
65
|
+
let(:args) { %w"lists" }
|
66
|
+
|
67
|
+
before do
|
68
|
+
dotwl.stub(token: '131378dbc2490bf87b6080ad6aeb758a46673270bbca9c7ea26f434473bbe741')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'prints all the tasks' do
|
72
|
+
output = capture(:stdout) { subject }
|
73
|
+
|
74
|
+
JSON.parse(output).should have(5).lists
|
75
|
+
end
|
76
|
+
end
|
68
77
|
end
|
69
78
|
end
|
data/spec/wl/client_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Wl
|
4
4
|
describe Client do
|
5
|
-
let(:dotwl) { double(Dotwl, token: nil) }
|
5
|
+
let(:dotwl) { double(Dotwl, token: nil).as_null_object }
|
6
6
|
|
7
7
|
subject do
|
8
8
|
Client.new(dotwl: dotwl)
|
@@ -16,6 +16,11 @@ module Wl
|
|
16
16
|
response.email.should == 'fake@example.com'
|
17
17
|
response.errors.should be_nil
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'stores the token' do
|
21
|
+
dotwl.should_receive(:login).with(an_instance_of(Login))
|
22
|
+
subject.login('fake@example.com', 'fakepass')
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
context 'when something goes wrong' do
|
@@ -51,5 +56,25 @@ module Wl
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
59
|
+
|
60
|
+
describe '#lists' do
|
61
|
+
context 'when the user has logged in', vcr: {cassette_name: 'lists'} do
|
62
|
+
before do
|
63
|
+
dotwl.stub(token: '131378dbc2490bf87b6080ad6aeb758a46673270bbca9c7ea26f434473bbe741')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'lists all lists' do
|
67
|
+
lists = subject.lists
|
68
|
+
lists.map(&:title).should eq ["Private", "Work", "Shopping", "Movies to Watch", "Wishlist"]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when the user has not logged in', vcr: {cassette_name: 'lists'} do
|
73
|
+
it 'fails gracefully' do
|
74
|
+
lists = subject.lists
|
75
|
+
lists.errors['type'].should eq('unauthorized')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
54
79
|
end
|
55
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -178,9 +178,11 @@ files:
|
|
178
178
|
- lib/wl/cli.rb
|
179
179
|
- lib/wl/client.rb
|
180
180
|
- lib/wl/dotwl.rb
|
181
|
+
- lib/wl/list.rb
|
181
182
|
- lib/wl/login.rb
|
182
183
|
- lib/wl/task.rb
|
183
184
|
- lib/wl/version.rb
|
185
|
+
- spec/cassettes/lists.yml
|
184
186
|
- spec/cassettes/login.yml
|
185
187
|
- spec/cassettes/tasks.yml
|
186
188
|
- spec/helpers/capture_output.rb
|
@@ -189,6 +191,7 @@ files:
|
|
189
191
|
- spec/wl/cli_spec.rb
|
190
192
|
- spec/wl/client_spec.rb
|
191
193
|
- spec/wl/dotwl_spec.rb
|
194
|
+
- spec/wl/list_spec.rb
|
192
195
|
- spec/wl/login_spec.rb
|
193
196
|
- spec/wl/task_spec.rb
|
194
197
|
- wl.gemspec
|
@@ -207,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
210
|
version: '0'
|
208
211
|
segments:
|
209
212
|
- 0
|
210
|
-
hash:
|
213
|
+
hash: 3677924530743277966
|
211
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
215
|
none: false
|
213
216
|
requirements:
|
@@ -216,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
219
|
version: '0'
|
217
220
|
segments:
|
218
221
|
- 0
|
219
|
-
hash:
|
222
|
+
hash: 3677924530743277966
|
220
223
|
requirements: []
|
221
224
|
rubyforge_project:
|
222
225
|
rubygems_version: 1.8.25
|
@@ -225,6 +228,7 @@ specification_version: 3
|
|
225
228
|
summary: ! '`wl` is an unofficial Ruby client and command line interface for the truly
|
226
229
|
awesome Wunderlist'
|
227
230
|
test_files:
|
231
|
+
- spec/cassettes/lists.yml
|
228
232
|
- spec/cassettes/login.yml
|
229
233
|
- spec/cassettes/tasks.yml
|
230
234
|
- spec/helpers/capture_output.rb
|
@@ -233,5 +237,6 @@ test_files:
|
|
233
237
|
- spec/wl/cli_spec.rb
|
234
238
|
- spec/wl/client_spec.rb
|
235
239
|
- spec/wl/dotwl_spec.rb
|
240
|
+
- spec/wl/list_spec.rb
|
236
241
|
- spec/wl/login_spec.rb
|
237
242
|
- spec/wl/task_spec.rb
|