wl 0.0.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.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/bin/wl +5 -0
- data/lib/wl.rb +7 -0
- data/lib/wl/cli.rb +18 -0
- data/lib/wl/client.rb +16 -0
- data/lib/wl/login.rb +18 -0
- data/lib/wl/version.rb +3 -0
- data/spec/cassettes/login.yml +109 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/wl/cli_spec.rb +36 -0
- data/spec/wl/client_spec.rb +23 -0
- data/spec/wl/login_spec.rb +7 -0
- data/wl.gemspec +29 -0
- metadata +191 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Abhi Hiremagalur
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# wl
|
2
|
+
|
3
|
+
`wl` is an unofficial Ruby client and command line interface for the truly awesome [Wunderlist](http://www.6wunderkinder.com/wunderlist)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'wl'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install wl
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
wl --help
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/wl
ADDED
data/lib/wl.rb
ADDED
data/lib/wl/cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
class CLI < Thor
|
5
|
+
desc 'login', 'Logs in to Wunderlist'
|
6
|
+
option :email, desc: 'Wunderlist email'
|
7
|
+
option :password, desc: 'Wunderlist password'
|
8
|
+
def login
|
9
|
+
email = options[:email] || ask('Wunderlist email:')
|
10
|
+
password = options[:password] || ask('Wunderlist password:')
|
11
|
+
|
12
|
+
client = Wl::Client.new
|
13
|
+
login = client.login(email, password)
|
14
|
+
|
15
|
+
say login.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/wl/client.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'api_smith'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
class Client < APISmith::Base
|
5
|
+
base_uri 'https://api.wunderlist.com/'
|
6
|
+
|
7
|
+
def login(email, password)
|
8
|
+
response = post('login', extra_query: {email: email, password: password}, as: Login)
|
9
|
+
if response.code == 200
|
10
|
+
Login.new(response.parsed_response)
|
11
|
+
else
|
12
|
+
raise response.inspect
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/wl/login.rb
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
18
|
+
end
|
data/lib/wl/version.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.wunderlist.com/login?email=fake@example.com&password=fakepass
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- max-age=0, private, must-revalidate
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Sun, 24 Mar 2013 00:59:02 GMT
|
21
|
+
Etag:
|
22
|
+
- '"87b3680a522171eae890602851b79bf2"'
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Status:
|
26
|
+
- 200 OK
|
27
|
+
Vary:
|
28
|
+
- Accept-Encoding
|
29
|
+
X-6w-Client-Status:
|
30
|
+
- unknown
|
31
|
+
X-Rack-Cache:
|
32
|
+
- invalidate, pass
|
33
|
+
X-Ratelimit-Delay-Hard:
|
34
|
+
- '0'
|
35
|
+
X-Ratelimit-Delay-Soft:
|
36
|
+
- '979'
|
37
|
+
X-Request-Id:
|
38
|
+
- 07752649375a71739be539ebf1acb483
|
39
|
+
X-Server:
|
40
|
+
- ip-10-227-29-235
|
41
|
+
Content-Length:
|
42
|
+
- '1124'
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: |
|
48
|
+
{
|
49
|
+
"id": "ABcDEFGhIJk",
|
50
|
+
"created_at": "2013-03-23T23:07:10Z",
|
51
|
+
"updated_at": "2013-03-23T23:07:10Z",
|
52
|
+
"name": "fake@example.com",
|
53
|
+
"type": "User",
|
54
|
+
"avatar": null,
|
55
|
+
"email": "fake@example.com",
|
56
|
+
"token": "131378dbc2490bf87b6080ad6aeb758a46673270bbca9c7ea26f434473bbe741",
|
57
|
+
"confirmation_state": "confirmed_email",
|
58
|
+
"email_confirmed": true,
|
59
|
+
"product": null,
|
60
|
+
"settings": {
|
61
|
+
}
|
62
|
+
}
|
63
|
+
http_version:
|
64
|
+
recorded_at: Sun, 24 Mar 2013 00:59:02 GMT
|
65
|
+
- request:
|
66
|
+
method: post
|
67
|
+
uri: https://api.wunderlist.com/login?email=fake@example.com&password=badpassword
|
68
|
+
body:
|
69
|
+
encoding: US-ASCII
|
70
|
+
string: ''
|
71
|
+
headers: {}
|
72
|
+
response:
|
73
|
+
status:
|
74
|
+
code: 404
|
75
|
+
message: Not Found
|
76
|
+
headers:
|
77
|
+
Cache-Control:
|
78
|
+
- no-cache
|
79
|
+
Content-Type:
|
80
|
+
- application/json; charset=utf-8
|
81
|
+
Date:
|
82
|
+
- Sun, 24 Mar 2013 01:23:52 GMT
|
83
|
+
Server:
|
84
|
+
- nginx
|
85
|
+
Status:
|
86
|
+
- 404 Not Found
|
87
|
+
Vary:
|
88
|
+
- Accept-Encoding
|
89
|
+
X-6w-Client-Status:
|
90
|
+
- unknown
|
91
|
+
X-Rack-Cache:
|
92
|
+
- invalidate, pass
|
93
|
+
X-Ratelimit-Delay-Hard:
|
94
|
+
- '0'
|
95
|
+
X-Ratelimit-Delay-Soft:
|
96
|
+
- '1289'
|
97
|
+
X-Request-Id:
|
98
|
+
- d91f1a03527ccdb7d101a577e7b9fca8
|
99
|
+
Content-Length:
|
100
|
+
- '233'
|
101
|
+
Connection:
|
102
|
+
- keep-alive
|
103
|
+
body:
|
104
|
+
encoding: UTF-8
|
105
|
+
string: '{"errors":{"message":"We were unable to locate a user based on the
|
106
|
+
credentials you supplied.","type":"not_found.no_such_user"},"resource":{"email":"fake@example.com","password":"[FILTERED]","controller":"sessions","action":"create"}}'
|
107
|
+
http_version:
|
108
|
+
recorded_at: Sun, 24 Mar 2013 01:23:52 GMT
|
109
|
+
recorded_with: VCR 2.4.0
|
data/spec/spec_helper.rb
ADDED
data/spec/wl/cli_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
describe CLI do
|
5
|
+
context "by default" do
|
6
|
+
let(:args) { [] }
|
7
|
+
|
8
|
+
it 'prints helpful information by default' do
|
9
|
+
output = capture(:stdout) { Wl::CLI.start(args) }
|
10
|
+
output.should include("help [TASK]")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'login', vcr: {cassette_name: 'login'} do
|
15
|
+
let(:args) { %w"login --email fake@example.com --password fakepass" }
|
16
|
+
|
17
|
+
it 'retrieves a token on behalf of the user' do
|
18
|
+
output = capture(:stdout) { Wl::CLI.start(args) }
|
19
|
+
output.should include('"name":"fake@example.com"')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def capture(stream)
|
24
|
+
begin
|
25
|
+
stream = stream.to_s
|
26
|
+
eval "$#{stream} = StringIO.new"
|
27
|
+
yield
|
28
|
+
result = eval("$#{stream}").string
|
29
|
+
ensure
|
30
|
+
eval("$#{stream} = #{stream.upcase}")
|
31
|
+
end
|
32
|
+
|
33
|
+
result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Wl
|
4
|
+
describe Client do
|
5
|
+
describe '#login' do
|
6
|
+
context 'when the email address and password are accepted', vcr: {cassette_name: 'login'} do
|
7
|
+
it 'packages the api response in a Login object' do
|
8
|
+
response = subject.login('fake@example.com', 'fakepass')
|
9
|
+
response.should be_a(Login)
|
10
|
+
response.email.should == 'fake@example.com'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when something goes wrong' do
|
15
|
+
it 'fails fast printing the raw api response', vcr: {cassette_name: 'login'} do
|
16
|
+
expect {
|
17
|
+
subject.login('fake@example.com', 'badpassword')
|
18
|
+
}.to raise_error /We were unable to locate a user based on the credentials you supplied/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/wl.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wl"
|
8
|
+
spec.version = Wl::VERSION
|
9
|
+
spec.authors = ["Abhi Hiremagalur"]
|
10
|
+
spec.email = ["abhijit@hiremaga.com"]
|
11
|
+
spec.description = %q{`wl` is an unofficial Ruby client and command line interface for the truly awesome Wunderlist}
|
12
|
+
spec.summary = %q{`wl` is an unofficial Ruby client and command line interface for the truly awesome Wunderlist}
|
13
|
+
spec.homepage = "http://github.com/hiremaga/wl"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "api_smith"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "webmock", "< 1.10"
|
28
|
+
spec.add_development_dependency "vcr"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Abhi Hiremagalur
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: api_smith
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: webmock
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - <
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.10'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - <
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.10'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: vcr
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: ! '`wl` is an unofficial Ruby client and command line interface for the
|
127
|
+
truly awesome Wunderlist'
|
128
|
+
email:
|
129
|
+
- abhijit@hiremaga.com
|
130
|
+
executables:
|
131
|
+
- wl
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- .gitignore
|
136
|
+
- .rspec
|
137
|
+
- .travis.yml
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/wl
|
143
|
+
- lib/wl.rb
|
144
|
+
- lib/wl/cli.rb
|
145
|
+
- lib/wl/client.rb
|
146
|
+
- lib/wl/login.rb
|
147
|
+
- lib/wl/version.rb
|
148
|
+
- spec/cassettes/login.yml
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/wl/cli_spec.rb
|
151
|
+
- spec/wl/client_spec.rb
|
152
|
+
- spec/wl/login_spec.rb
|
153
|
+
- wl.gemspec
|
154
|
+
homepage: http://github.com/hiremaga/wl
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
hash: -3243637196444113587
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
segments:
|
177
|
+
- 0
|
178
|
+
hash: -3243637196444113587
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 1.8.25
|
182
|
+
signing_key:
|
183
|
+
specification_version: 3
|
184
|
+
summary: ! '`wl` is an unofficial Ruby client and command line interface for the truly
|
185
|
+
awesome Wunderlist'
|
186
|
+
test_files:
|
187
|
+
- spec/cassettes/login.yml
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
- spec/wl/cli_spec.rb
|
190
|
+
- spec/wl/client_spec.rb
|
191
|
+
- spec/wl/login_spec.rb
|