wl 0.0.5 → 0.0.6
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.
- data/README.md +5 -0
- data/bin/wl +1 -1
- data/lib/wl.rb +1 -3
- data/lib/wl/cli.rb +5 -34
- data/lib/wl/cli/auth.rb +29 -0
- data/lib/wl/cli/lists.rb +19 -0
- data/lib/wl/cli/root.rb +11 -0
- data/lib/wl/cli/tasks.rb +19 -0
- data/lib/wl/client.rb +3 -3
- data/lib/wl/models.rb +7 -0
- data/lib/wl/{list.rb → models/list.rb} +3 -1
- data/lib/wl/models/login.rb +21 -0
- data/lib/wl/models/task.rb +32 -0
- data/lib/wl/version.rb +1 -1
- data/spec/wl/cli_spec.rb +4 -4
- data/spec/wl/client_spec.rb +3 -3
- data/spec/wl/dotwl_spec.rb +1 -1
- data/spec/wl/{list_spec.rb → models/list_spec.rb} +1 -1
- data/spec/wl/{login_spec.rb → models/login_spec.rb} +1 -1
- data/spec/wl/{task_spec.rb → models/task_spec.rb} +1 -1
- metadata +17 -12
- data/lib/wl/login.rb +0 -19
- data/lib/wl/task.rb +0 -30
data/README.md
CHANGED
@@ -29,3 +29,8 @@ Or install it yourself as:
|
|
29
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
31
31
|
5. Create new Pull Request
|
32
|
+
|
33
|
+
## Acknowledgements
|
34
|
+
|
35
|
+
This little side-project might not exist without bsmt's clever [reverse engineering of Wunderlist's API](http://bsmt.me/blog/2013/03/02/reverse-engineering-the-wunderlist-api/),
|
36
|
+
so thank you [@bsmt](https://github.com/bsmt). Of course this wouldn't be possible without Wunderlist itself, thanks [@6wunderkinder](https://github.com/6wunderkinder)!
|
data/bin/wl
CHANGED
data/lib/wl.rb
CHANGED
data/lib/wl/cli.rb
CHANGED
@@ -1,37 +1,8 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'highline'
|
3
|
-
|
4
1
|
module Wl
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
email = options[:email] || ui.ask('Wunderlist email: ')
|
11
|
-
password = options[:password] || ui.ask('Wunderlist password: ') { |q| q.echo = '*' }
|
12
|
-
|
13
|
-
login = client.login(email, password)
|
14
|
-
|
15
|
-
say login.to_json
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'tasks', 'Lists all your tasks'
|
19
|
-
def tasks
|
20
|
-
say client.tasks.to_json
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'lists', 'Lists all your lists'
|
24
|
-
def lists
|
25
|
-
say client.lists.to_json
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
def client
|
30
|
-
@client ||= Wl::Client.new(dotwl: Dotwl.new)
|
31
|
-
end
|
32
|
-
|
33
|
-
def ui
|
34
|
-
@ui ||= HighLine.new
|
35
|
-
end
|
2
|
+
module CLI
|
3
|
+
autoload :Auth, 'wl/cli/auth'
|
4
|
+
autoload :Lists, 'wl/cli/lists'
|
5
|
+
autoload :Tasks, 'wl/cli/tasks'
|
6
|
+
autoload :Root, 'wl/cli/root'
|
36
7
|
end
|
37
8
|
end
|
data/lib/wl/cli/auth.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module Wl
|
5
|
+
module CLI
|
6
|
+
class Auth < Thor
|
7
|
+
desc 'login', 'Log in to Wunderlist'
|
8
|
+
option :email, desc: 'Wunderlist email'
|
9
|
+
option :password, desc: 'Wunderlist password'
|
10
|
+
def login
|
11
|
+
email = options[:email] || ui.ask('Wunderlist email: ')
|
12
|
+
password = options[:password] || ui.ask('Wunderlist password: ') { |q| q.echo = '*' }
|
13
|
+
|
14
|
+
login = client.login(email, password)
|
15
|
+
|
16
|
+
say login.to_json
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def ui
|
21
|
+
HighLine.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def client
|
25
|
+
Client.new(dotwl: Dotwl.new)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/wl/cli/lists.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
module CLI
|
5
|
+
class Lists < Thor
|
6
|
+
desc 'index', 'Lists all your lists'
|
7
|
+
def index
|
8
|
+
say client.lists.to_json
|
9
|
+
end
|
10
|
+
|
11
|
+
default_task :index
|
12
|
+
|
13
|
+
private
|
14
|
+
def client
|
15
|
+
Client.new(dotwl: Dotwl.new)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wl/cli/root.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
module CLI
|
5
|
+
class Root < Thor
|
6
|
+
register Auth, :auth, 'auth', 'Manage your authentication credentials'
|
7
|
+
register Tasks, :tasks, 'tasks', 'Manage your tasks'
|
8
|
+
register Lists, :lists, 'lists', 'Manage your lists'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/wl/cli/tasks.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
module CLI
|
5
|
+
class Tasks < Thor
|
6
|
+
desc 'index', 'Lists all your tasks'
|
7
|
+
def index
|
8
|
+
say client.tasks.to_json
|
9
|
+
end
|
10
|
+
|
11
|
+
default_task :index
|
12
|
+
|
13
|
+
private
|
14
|
+
def client
|
15
|
+
Client.new(dotwl: Dotwl.new)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wl/client.rb
CHANGED
@@ -9,17 +9,17 @@ module Wl
|
|
9
9
|
shy :dotwl
|
10
10
|
|
11
11
|
def login(email, password)
|
12
|
-
login = post('login', extra_query: {email: email, password: password}, transformer: Login)
|
12
|
+
login = post('login', extra_query: {email: email, password: password}, transformer: Models::Login)
|
13
13
|
dotwl.login(login)
|
14
14
|
login
|
15
15
|
end
|
16
16
|
|
17
17
|
def tasks
|
18
|
-
get('me/tasks', transformer: Task)
|
18
|
+
get('me/tasks', transformer: Models::Task)
|
19
19
|
end
|
20
20
|
|
21
21
|
def lists
|
22
|
-
get('me/lists', transformer: List)
|
22
|
+
get('me/lists', transformer: Models::List)
|
23
23
|
end
|
24
24
|
|
25
25
|
def base_request_options
|
data/lib/wl/models.rb
ADDED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'api_smith'
|
2
2
|
|
3
3
|
module Wl
|
4
|
-
|
4
|
+
module Models
|
5
|
+
class List < APISmith::Smash
|
5
6
|
property :title
|
6
7
|
property :created_at
|
7
8
|
property :updated_at
|
@@ -12,5 +13,6 @@ module Wl
|
|
12
13
|
property :id
|
13
14
|
property :owner_id
|
14
15
|
property :errors
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'api_smith'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
module Models
|
5
|
+
class Login < APISmith::Smash
|
6
|
+
property :id
|
7
|
+
property :product
|
8
|
+
property :name
|
9
|
+
property :settings
|
10
|
+
property :created_at
|
11
|
+
property :updated_at
|
12
|
+
property :email
|
13
|
+
property :token
|
14
|
+
property :avatar
|
15
|
+
property :confirmation_state
|
16
|
+
property :type
|
17
|
+
property :email_confirmed
|
18
|
+
property :errors
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'api_smith'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
module Models
|
5
|
+
class Task < APISmith::Smash
|
6
|
+
property :id
|
7
|
+
property :assignee_id
|
8
|
+
property :completed_at
|
9
|
+
property :created_at
|
10
|
+
property :created_by_id
|
11
|
+
property :deleted_at
|
12
|
+
property :due_date
|
13
|
+
property :list_id
|
14
|
+
property :local_identifier
|
15
|
+
property :note
|
16
|
+
property :owner_id
|
17
|
+
property :parent_id
|
18
|
+
property :position
|
19
|
+
property :recurrence_count
|
20
|
+
property :recurrence_type
|
21
|
+
property :recurring_parent_id
|
22
|
+
property :starred
|
23
|
+
property :title
|
24
|
+
property :type
|
25
|
+
property :updated_at
|
26
|
+
property :updated_by_id
|
27
|
+
property :user_id
|
28
|
+
property :version
|
29
|
+
property :errors
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/wl/version.rb
CHANGED
data/spec/wl/cli_spec.rb
CHANGED
@@ -5,7 +5,7 @@ module Wl
|
|
5
5
|
let(:dotwl) { double(Dotwl, token: nil).as_null_object }
|
6
6
|
|
7
7
|
subject do
|
8
|
-
Wl::CLI.start(args)
|
8
|
+
Wl::CLI::Root.start(args)
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
@@ -21,8 +21,8 @@ module Wl
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe 'login', vcr: {cassette_name: 'login'} do
|
25
|
-
let(:args) { %w"login --email fake@example.com --password fakepass" }
|
24
|
+
describe 'auth login', vcr: {cassette_name: 'login'} do
|
25
|
+
let(:args) { %w"auth login --email fake@example.com --password fakepass" }
|
26
26
|
|
27
27
|
it 'retrieves a token on behalf of the user' do
|
28
28
|
output = capture(:stdout) { subject }
|
@@ -30,7 +30,7 @@ module Wl
|
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when an email and password are not provided' do
|
33
|
-
let(:args) { %w"login" }
|
33
|
+
let(:args) { %w"auth login" }
|
34
34
|
|
35
35
|
it 'asks the user for each' do
|
36
36
|
ui = mock(HighLine).as_null_object
|
data/spec/wl/client_spec.rb
CHANGED
@@ -12,13 +12,13 @@ module Wl
|
|
12
12
|
context 'when the email address and password are accepted', vcr: {cassette_name: 'login'} do
|
13
13
|
it 'packages the api response in a Login object' do
|
14
14
|
response = subject.login('fake@example.com', 'fakepass')
|
15
|
-
response.should be_a(Login)
|
15
|
+
response.should be_a(Models::Login)
|
16
16
|
response.email.should == 'fake@example.com'
|
17
17
|
response.errors.should be_nil
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'stores the token' do
|
21
|
-
dotwl.should_receive(:login).with(an_instance_of(Login))
|
21
|
+
dotwl.should_receive(:login).with(an_instance_of(Models::Login))
|
22
22
|
subject.login('fake@example.com', 'fakepass')
|
23
23
|
end
|
24
24
|
end
|
@@ -26,7 +26,7 @@ module Wl
|
|
26
26
|
context 'when something goes wrong' do
|
27
27
|
it 'inserts the errors into the Login object', vcr: {cassette_name: 'login'} do
|
28
28
|
response = subject.login('fake@example.com', 'badpassword')
|
29
|
-
response.should be_a(Login)
|
29
|
+
response.should be_a(Models::Login)
|
30
30
|
response.email.should be_nil
|
31
31
|
response.errors['type'].should eq('not_found.no_such_user')
|
32
32
|
end
|
data/spec/wl/dotwl_spec.rb
CHANGED
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -176,11 +176,16 @@ files:
|
|
176
176
|
- bin/wl
|
177
177
|
- lib/wl.rb
|
178
178
|
- lib/wl/cli.rb
|
179
|
+
- lib/wl/cli/auth.rb
|
180
|
+
- lib/wl/cli/lists.rb
|
181
|
+
- lib/wl/cli/root.rb
|
182
|
+
- lib/wl/cli/tasks.rb
|
179
183
|
- lib/wl/client.rb
|
180
184
|
- lib/wl/dotwl.rb
|
181
|
-
- lib/wl/
|
182
|
-
- lib/wl/
|
183
|
-
- lib/wl/
|
185
|
+
- lib/wl/models.rb
|
186
|
+
- lib/wl/models/list.rb
|
187
|
+
- lib/wl/models/login.rb
|
188
|
+
- lib/wl/models/task.rb
|
184
189
|
- lib/wl/version.rb
|
185
190
|
- spec/cassettes/lists.yml
|
186
191
|
- spec/cassettes/login.yml
|
@@ -191,9 +196,9 @@ files:
|
|
191
196
|
- spec/wl/cli_spec.rb
|
192
197
|
- spec/wl/client_spec.rb
|
193
198
|
- spec/wl/dotwl_spec.rb
|
194
|
-
- spec/wl/list_spec.rb
|
195
|
-
- spec/wl/login_spec.rb
|
196
|
-
- spec/wl/task_spec.rb
|
199
|
+
- spec/wl/models/list_spec.rb
|
200
|
+
- spec/wl/models/login_spec.rb
|
201
|
+
- spec/wl/models/task_spec.rb
|
197
202
|
- wl.gemspec
|
198
203
|
homepage: http://github.com/hiremaga/wl
|
199
204
|
licenses:
|
@@ -210,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
215
|
version: '0'
|
211
216
|
segments:
|
212
217
|
- 0
|
213
|
-
hash:
|
218
|
+
hash: 2853585498009773397
|
214
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
220
|
none: false
|
216
221
|
requirements:
|
@@ -219,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
224
|
version: '0'
|
220
225
|
segments:
|
221
226
|
- 0
|
222
|
-
hash:
|
227
|
+
hash: 2853585498009773397
|
223
228
|
requirements: []
|
224
229
|
rubyforge_project:
|
225
230
|
rubygems_version: 1.8.25
|
@@ -237,6 +242,6 @@ test_files:
|
|
237
242
|
- spec/wl/cli_spec.rb
|
238
243
|
- spec/wl/client_spec.rb
|
239
244
|
- spec/wl/dotwl_spec.rb
|
240
|
-
- spec/wl/list_spec.rb
|
241
|
-
- spec/wl/login_spec.rb
|
242
|
-
- spec/wl/task_spec.rb
|
245
|
+
- spec/wl/models/list_spec.rb
|
246
|
+
- spec/wl/models/login_spec.rb
|
247
|
+
- spec/wl/models/task_spec.rb
|
data/lib/wl/login.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'api_smith'
|
2
|
-
|
3
|
-
module Wl
|
4
|
-
class Login < APISmith::Smash
|
5
|
-
property :id
|
6
|
-
property :product
|
7
|
-
property :name
|
8
|
-
property :settings
|
9
|
-
property :created_at
|
10
|
-
property :updated_at
|
11
|
-
property :email
|
12
|
-
property :token
|
13
|
-
property :avatar
|
14
|
-
property :confirmation_state
|
15
|
-
property :type
|
16
|
-
property :email_confirmed
|
17
|
-
property :errors
|
18
|
-
end
|
19
|
-
end
|
data/lib/wl/task.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'api_smith'
|
2
|
-
|
3
|
-
module Wl
|
4
|
-
class Task < APISmith::Smash
|
5
|
-
property :id
|
6
|
-
property :assignee_id
|
7
|
-
property :completed_at
|
8
|
-
property :created_at
|
9
|
-
property :created_by_id
|
10
|
-
property :deleted_at
|
11
|
-
property :due_date
|
12
|
-
property :list_id
|
13
|
-
property :local_identifier
|
14
|
-
property :note
|
15
|
-
property :owner_id
|
16
|
-
property :parent_id
|
17
|
-
property :position
|
18
|
-
property :recurrence_count
|
19
|
-
property :recurrence_type
|
20
|
-
property :recurring_parent_id
|
21
|
-
property :starred
|
22
|
-
property :title
|
23
|
-
property :type
|
24
|
-
property :updated_at
|
25
|
-
property :updated_by_id
|
26
|
-
property :user_id
|
27
|
-
property :version
|
28
|
-
property :errors
|
29
|
-
end
|
30
|
-
end
|