wl 0.0.2 → 0.0.3
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/lib/wl.rb +3 -2
- data/lib/wl/cli.rb +4 -1
- data/lib/wl/dotwl.rb +17 -0
- data/lib/wl/version.rb +1 -1
- data/spec/wl/cli_spec.rb +8 -0
- data/spec/wl/dotwl_spec.rb +47 -0
- metadata +8 -4
- data/.rvmrc +0 -1
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
wl
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p392
|
data/lib/wl.rb
CHANGED
data/lib/wl/cli.rb
CHANGED
data/lib/wl/dotwl.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Wl
|
2
|
+
class Dotwl
|
3
|
+
def login(login)
|
4
|
+
File.write(token_path, login.token)
|
5
|
+
File.chmod(0600, token_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def dir
|
9
|
+
FileUtils.mkdir_p("#{Dir.home}/.wl", mode: 0700).last
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def token_path
|
14
|
+
"#{dir}/token"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/wl/version.rb
CHANGED
data/spec/wl/cli_spec.rb
CHANGED
@@ -2,7 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Wl
|
4
4
|
describe CLI do
|
5
|
+
let(:dotwl) { double(Dotwl).as_null_object }
|
6
|
+
|
5
7
|
subject do
|
8
|
+
Dotwl.stub(:new).and_return(dotwl)
|
6
9
|
Wl::CLI.start(args)
|
7
10
|
end
|
8
11
|
|
@@ -23,6 +26,11 @@ module Wl
|
|
23
26
|
output.should include('"name":"fake@example.com"')
|
24
27
|
end
|
25
28
|
|
29
|
+
it 'stores the token' do
|
30
|
+
dotwl.should_receive(:login).with(an_instance_of(Login))
|
31
|
+
subject
|
32
|
+
end
|
33
|
+
|
26
34
|
context 'when an email and password are not provided' do
|
27
35
|
let(:args) { %w"login" }
|
28
36
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module Wl
|
5
|
+
describe Dotwl do
|
6
|
+
let(:fake_home) { Dir.mktmpdir('home') }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Dir.stub(home: fake_home)
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rmtree(fake_home)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#dir' do
|
17
|
+
it "creates the .wl directory in the user's home directory" do
|
18
|
+
expect {
|
19
|
+
subject.dir
|
20
|
+
}.to change { File.directory?("#{Dir.home}/.wl") }.to(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is private" do
|
24
|
+
subject.dir
|
25
|
+
|
26
|
+
stat = File.stat("#{Dir.home}/.wl")
|
27
|
+
sprintf("%o", stat.mode).should eq '40700'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#login' do
|
32
|
+
before do
|
33
|
+
fake_login = double(Login, token: 'faketoken')
|
34
|
+
subject.login(fake_login)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'saves the token for later use' do
|
38
|
+
File.read("#{Dir.home}/.wl/token").should eq 'faketoken'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'saves the token privately' do
|
42
|
+
stat = File.stat("#{Dir.home}/.wl/token")
|
43
|
+
sprintf("%o", stat.mode).should eq '100600'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -150,7 +150,8 @@ extra_rdoc_files: []
|
|
150
150
|
files:
|
151
151
|
- .gitignore
|
152
152
|
- .rspec
|
153
|
-
- .
|
153
|
+
- .ruby-gemset
|
154
|
+
- .ruby-version
|
154
155
|
- .travis.yml
|
155
156
|
- Gemfile
|
156
157
|
- LICENSE.txt
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- lib/wl.rb
|
161
162
|
- lib/wl/cli.rb
|
162
163
|
- lib/wl/client.rb
|
164
|
+
- lib/wl/dotwl.rb
|
163
165
|
- lib/wl/login.rb
|
164
166
|
- lib/wl/version.rb
|
165
167
|
- spec/cassettes/login.yml
|
@@ -168,6 +170,7 @@ files:
|
|
168
170
|
- spec/spec_helper.rb
|
169
171
|
- spec/wl/cli_spec.rb
|
170
172
|
- spec/wl/client_spec.rb
|
173
|
+
- spec/wl/dotwl_spec.rb
|
171
174
|
- spec/wl/login_spec.rb
|
172
175
|
- wl.gemspec
|
173
176
|
homepage: http://github.com/hiremaga/wl
|
@@ -185,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
188
|
version: '0'
|
186
189
|
segments:
|
187
190
|
- 0
|
188
|
-
hash:
|
191
|
+
hash: 2086549849182975583
|
189
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
193
|
none: false
|
191
194
|
requirements:
|
@@ -194,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
197
|
version: '0'
|
195
198
|
segments:
|
196
199
|
- 0
|
197
|
-
hash:
|
200
|
+
hash: 2086549849182975583
|
198
201
|
requirements: []
|
199
202
|
rubyforge_project:
|
200
203
|
rubygems_version: 1.8.25
|
@@ -209,4 +212,5 @@ test_files:
|
|
209
212
|
- spec/spec_helper.rb
|
210
213
|
- spec/wl/cli_spec.rb
|
211
214
|
- spec/wl/client_spec.rb
|
215
|
+
- spec/wl/dotwl_spec.rb
|
212
216
|
- spec/wl/login_spec.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.3@wl --create
|