wl 0.0.1 → 0.0.2

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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@wl --create
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # wl
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/hiremaga/wl.png)](http://travis-ci.org/hiremaga/wl) [![Code Climate](https://codeclimate.com/github/hiremaga/wl.png)](https://codeclimate.com/github/hiremaga/wl)
4
+
3
5
  `wl` is an unofficial Ruby client and command line interface for the truly awesome [Wunderlist](http://www.6wunderkinder.com/wunderlist)
4
6
 
5
7
  ## Installation
data/lib/wl/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'thor'
2
+ require 'highline'
2
3
 
3
4
  module Wl
4
5
  class CLI < Thor
@@ -6,13 +7,18 @@ module Wl
6
7
  option :email, desc: 'Wunderlist email'
7
8
  option :password, desc: 'Wunderlist password'
8
9
  def login
9
- email = options[:email] || ask('Wunderlist email:')
10
- password = options[:password] || ask('Wunderlist password:')
10
+ email = options[:email] || ui.ask('Wunderlist email: ')
11
+ password = options[:password] || ui.ask('Wunderlist password: ') { |q| q.echo = '*' }
11
12
 
12
13
  client = Wl::Client.new
13
14
  login = client.login(email, password)
14
15
 
15
- say login.to_json
16
+ ui.say login.to_json
17
+ end
18
+
19
+ private
20
+ def ui
21
+ @ui ||= HighLine.new
16
22
  end
17
23
  end
18
24
  end
data/lib/wl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,14 @@
1
+ module CaptureOutput
2
+ def capture(stream)
3
+ begin
4
+ stream = stream.to_s
5
+ eval "$#{stream} = StringIO.new"
6
+ yield
7
+ result = eval("$#{stream}").string
8
+ ensure
9
+ eval("$#{stream} = #{stream.upcase}")
10
+ end
11
+
12
+ result
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = 'spec/cassettes'
5
+ c.hook_into :webmock
6
+ c.configure_rspec_metadata!
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'wl'
3
- require 'vcr'
4
3
 
5
- VCR.configure do |c|
6
- c.cassette_library_dir = 'spec/cassettes'
7
- c.hook_into :webmock
8
- c.configure_rspec_metadata!
4
+ Dir['spec/helpers/**/*.rb'].each { |helper| require File.expand_path(helper) }
5
+
6
+ RSpec.configure do |c|
7
+ c.include CaptureOutput
9
8
  end
data/spec/wl/cli_spec.rb CHANGED
@@ -2,11 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  module Wl
4
4
  describe CLI do
5
+ subject do
6
+ Wl::CLI.start(args)
7
+ end
8
+
5
9
  context "by default" do
6
10
  let(:args) { [] }
7
11
 
8
12
  it 'prints helpful information by default' do
9
- output = capture(:stdout) { Wl::CLI.start(args) }
13
+ output = capture(:stdout) { subject }
10
14
  output.should include("help [TASK]")
11
15
  end
12
16
  end
@@ -15,22 +19,26 @@ module Wl
15
19
  let(:args) { %w"login --email fake@example.com --password fakepass" }
16
20
 
17
21
  it 'retrieves a token on behalf of the user' do
18
- output = capture(:stdout) { Wl::CLI.start(args) }
22
+ output = capture(:stdout) { subject }
19
23
  output.should include('"name":"fake@example.com"')
20
24
  end
21
- end
22
25
 
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
26
+ context 'when an email and password are not provided' do
27
+ let(:args) { %w"login" }
32
28
 
33
- result
29
+ it 'asks the user for each' do
30
+ ui = mock(HighLine).as_null_object
31
+ HighLine.stub(new: ui)
32
+ ui.should_receive(:ask).with('Wunderlist email: ').and_return('foo@example.com')
33
+ ui.should_receive(:ask).with('Wunderlist password: ').and_return('foopass')
34
+
35
+ client = mock(Wl::Client)
36
+ Wl::Client.stub(new: client)
37
+ client.should_receive(:login).with('foo@example.com', 'foopass')
38
+
39
+ subject
40
+ end
41
+ end
34
42
  end
35
43
  end
36
44
  end
data/wl.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "thor"
22
+ spec.add_dependency "highline"
22
23
  spec.add_dependency "api_smith"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.3"
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: highline
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'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: api_smith
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +150,7 @@ extra_rdoc_files: []
134
150
  files:
135
151
  - .gitignore
136
152
  - .rspec
153
+ - .rvmrc
137
154
  - .travis.yml
138
155
  - Gemfile
139
156
  - LICENSE.txt
@@ -146,6 +163,8 @@ files:
146
163
  - lib/wl/login.rb
147
164
  - lib/wl/version.rb
148
165
  - spec/cassettes/login.yml
166
+ - spec/helpers/capture_output.rb
167
+ - spec/helpers/vcr.rb
149
168
  - spec/spec_helper.rb
150
169
  - spec/wl/cli_spec.rb
151
170
  - spec/wl/client_spec.rb
@@ -166,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
185
  version: '0'
167
186
  segments:
168
187
  - 0
169
- hash: -3243637196444113587
188
+ hash: 777019882129541853
170
189
  required_rubygems_version: !ruby/object:Gem::Requirement
171
190
  none: false
172
191
  requirements:
@@ -175,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
194
  version: '0'
176
195
  segments:
177
196
  - 0
178
- hash: -3243637196444113587
197
+ hash: 777019882129541853
179
198
  requirements: []
180
199
  rubyforge_project:
181
200
  rubygems_version: 1.8.25
@@ -185,6 +204,8 @@ summary: ! '`wl` is an unofficial Ruby client and command line interface for the
185
204
  awesome Wunderlist'
186
205
  test_files:
187
206
  - spec/cassettes/login.yml
207
+ - spec/helpers/capture_output.rb
208
+ - spec/helpers/vcr.rb
188
209
  - spec/spec_helper.rb
189
210
  - spec/wl/cli_spec.rb
190
211
  - spec/wl/client_spec.rb