boxen 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/boxen.gemspec +3 -3
- data/lib/boxen/preflight/creds.rb +23 -19
- data/lib/boxen/runner.rb +1 -1
- data/lib/boxen/service.rb +11 -1
- data/test/boxen_preflight_creds_test.rb +40 -0
- data/test/boxen_runner_test.rb +1 -1
- data/test/boxen_service_test.rb +6 -0
- metadata +5 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cffbc20a2321cfcfdca7fe583bd73118486dcc77
|
4
|
+
data.tar.gz: 73893a045299bebec51c8d270af6e76c18c37a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f2f13dddcee592cfef053fb6b0a17a2c690d1ed9e8e100e83cd90c4bc525636505051a60b0b9a8cc71b1882ea55f92d346c67f86c4a6d6a9d27fbd88cc8015
|
7
|
+
data.tar.gz: fb9d784e16383c1e52a88a05791ffa1c42dbf4a8021259230d97d4bf89a1cf5c8474f5cec03fd8072380eb50d206ae2ff7362bd8f2c8eb7f79961810fc29ea0d
|
data/.gitignore
CHANGED
data/boxen.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "boxen"
|
5
|
-
gem.version = "2.
|
6
|
-
gem.authors = ["John Barnette", "Will Farrington"]
|
7
|
-
gem.email = ["jbarnette@github.com", "wfarr@github.com"]
|
5
|
+
gem.version = "2.2.0"
|
6
|
+
gem.authors = ["John Barnette", "Will Farrington", "David Goodlad"]
|
7
|
+
gem.email = ["jbarnette@github.com", "wfarr@github.com", "dgoodlad@github.com"]
|
8
8
|
gem.description = "Manage Mac development boxes with love (and Puppet)."
|
9
9
|
gem.summary = "You know, for laptops and stuff."
|
10
10
|
gem.homepage = "https://github.com/boxen/boxen"
|
@@ -65,25 +65,7 @@ class Boxen::Preflight::Creds < Boxen::Preflight
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def run
|
68
|
-
|
69
|
-
|
70
|
-
if ENV['BOXEN_GITHUB_LOGIN'] || ENV['BOXEN_GITHUB_PASSWORD']
|
71
|
-
warn "Oh, looks like you've provided your username and password as environmental variables..."
|
72
|
-
config.login = ENV['BOXEN_GITHUB_LOGIN']
|
73
|
-
@password = ENV['BOXEN_GITHUB_PASSWORD']
|
74
|
-
else
|
75
|
-
warn "Hey, I need your current GitHub credentials to continue."
|
76
|
-
|
77
|
-
config.login = console.ask "GitHub login: " do |q|
|
78
|
-
q.default = config.login || config.user
|
79
|
-
q.validate = /\A[^@]+\Z/
|
80
|
-
end
|
81
|
-
|
82
|
-
@password = console.ask "GitHub password: " do |q|
|
83
|
-
q.echo = "*"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
68
|
+
fetch_login_and_password
|
87
69
|
tokens = get_tokens
|
88
70
|
|
89
71
|
unless auth = tokens.detect { |a| a.note == "Boxen" }
|
@@ -101,4 +83,26 @@ class Boxen::Preflight::Creds < Boxen::Preflight
|
|
101
83
|
"I was able to get your OAuth token, but was unable to use it."
|
102
84
|
end
|
103
85
|
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def fetch_login_and_password
|
90
|
+
console = HighLine.new
|
91
|
+
|
92
|
+
config.login = fetch_from_env("login") || console.ask("GitHub login: ") do |q|
|
93
|
+
q.default = config.login || config.user
|
94
|
+
q.validate = /\A[^@]+\Z/
|
95
|
+
end
|
96
|
+
|
97
|
+
@password = fetch_from_env("password") || console.ask("GitHub password: ") do |q|
|
98
|
+
q.echo = "*"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def fetch_from_env(thing)
|
103
|
+
key = "BOXEN_GITHUB_#{thing.upcase}"
|
104
|
+
return unless found = ENV[key]
|
105
|
+
warn "Oh, looks like you've provided your #{thing} as environmental variable..."
|
106
|
+
found
|
107
|
+
end
|
104
108
|
end
|
data/lib/boxen/runner.rb
CHANGED
@@ -127,7 +127,7 @@ module Boxen
|
|
127
127
|
# --restart-services restarts all services
|
128
128
|
|
129
129
|
if flags.restart_services?
|
130
|
-
Boxen::Service.
|
130
|
+
Boxen::Service.list_enabled.each do |service|
|
131
131
|
puts "Restarting #{service}..."
|
132
132
|
service.disable
|
133
133
|
service.enable
|
data/lib/boxen/service.rb
CHANGED
@@ -10,6 +10,13 @@ module Boxen
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.list_enabled
|
14
|
+
prefix = /^dev\./
|
15
|
+
enabled = capture_output("sudo /bin/launchctl list").split("\n").map { |l| l.split(/\s/) }.map(&:last)
|
16
|
+
names = enabled.grep(prefix).map { |name| name.sub(prefix, "") }.compact
|
17
|
+
names.map { |name| new(name) }
|
18
|
+
end
|
19
|
+
|
13
20
|
def initialize(name)
|
14
21
|
@name = name
|
15
22
|
end
|
@@ -26,9 +33,12 @@ module Boxen
|
|
26
33
|
Boxen::Util.sudo('/bin/launchctl', 'unload', '-w', location)
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
36
|
private
|
31
37
|
|
38
|
+
def self.capture_output(command)
|
39
|
+
`#{command}`
|
40
|
+
end
|
41
|
+
|
32
42
|
def location
|
33
43
|
"#{self.class.location}/dev.#{name}.plist"
|
34
44
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'boxen/test'
|
2
|
+
require 'boxen/config'
|
2
3
|
require 'boxen/preflight/creds'
|
3
4
|
|
4
5
|
class BoxenPreflightCredsTest < Boxen::Test
|
@@ -7,6 +8,8 @@ class BoxenPreflightCredsTest < Boxen::Test
|
|
7
8
|
c.user = 'mojombo'
|
8
9
|
c.token = 'sekr3t!'
|
9
10
|
end
|
11
|
+
ENV.delete("BOXEN_GITHUB_LOGIN")
|
12
|
+
ENV.delete("BOXEN_GITHUB_PASSWORD")
|
10
13
|
end
|
11
14
|
|
12
15
|
def test_basic
|
@@ -37,4 +40,41 @@ class BoxenPreflightCredsTest < Boxen::Test
|
|
37
40
|
preflight.get_tokens
|
38
41
|
assert_equal "123456", preflight.otp
|
39
42
|
end
|
43
|
+
|
44
|
+
def test_fetch_login_and_password_when_nothing_is_given_in_env
|
45
|
+
# fetches login and password by asking
|
46
|
+
preflight = Boxen::Preflight::Creds.new @config
|
47
|
+
HighLine.any_instance.expects(:ask).with("GitHub login: ").returns "l"
|
48
|
+
HighLine.any_instance.expects(:ask).with("GitHub password: ").returns "p"
|
49
|
+
preflight.send(:fetch_login_and_password)
|
50
|
+
|
51
|
+
assert_equal "l", @config.login
|
52
|
+
assert_equal "p", preflight.instance_variable_get(:@password)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_fetch_password_when_login_is_given_in_env
|
56
|
+
# fetches only password by asking
|
57
|
+
ENV["BOXEN_GITHUB_LOGIN"] = "l"
|
58
|
+
preflight = Boxen::Preflight::Creds.new @config
|
59
|
+
preflight.expects(:warn)
|
60
|
+
HighLine.any_instance.expects(:ask).with("GitHub login: ").never
|
61
|
+
HighLine.any_instance.expects(:ask).with("GitHub password: ").returns "p"
|
62
|
+
preflight.send(:fetch_login_and_password)
|
63
|
+
|
64
|
+
assert_equal "l", @config.login
|
65
|
+
assert_equal "p", preflight.instance_variable_get(:@password)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_fetch_login_when_password_is_given_in_env
|
69
|
+
# fetches only login by asking
|
70
|
+
ENV["BOXEN_GITHUB_PASSWORD"] = "p"
|
71
|
+
preflight = Boxen::Preflight::Creds.new @config
|
72
|
+
preflight.expects(:warn)
|
73
|
+
HighLine.any_instance.expects(:ask).with("GitHub login: ").returns "l"
|
74
|
+
HighLine.any_instance.expects(:ask).with("GitHub password: ").never
|
75
|
+
preflight.send(:fetch_login_and_password)
|
76
|
+
|
77
|
+
assert_equal "l", @config.login
|
78
|
+
assert_equal "p", preflight.instance_variable_get(:@password)
|
79
|
+
end
|
40
80
|
end
|
data/test/boxen_runner_test.rb
CHANGED
@@ -118,7 +118,7 @@ class BoxenRunnerTest < Boxen::Test
|
|
118
118
|
service.expects(:disable).once
|
119
119
|
service.expects(:enable).once
|
120
120
|
end
|
121
|
-
Boxen::Service.stubs(:
|
121
|
+
Boxen::Service.stubs(:list_enabled).returns(services)
|
122
122
|
|
123
123
|
assert_raises(SystemExit) do
|
124
124
|
runner.process
|
data/test/boxen_service_test.rb
CHANGED
@@ -12,6 +12,12 @@ class BoxenServiceTest < Boxen::Test
|
|
12
12
|
assert_equal ['other', 'test'], services.collect(&:name).sort
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_list_enabled
|
16
|
+
Boxen::Service.expects(:capture_output).with("sudo /bin/launchctl list").returns "foo bar dev.baz\nfoo bar bazz"
|
17
|
+
services = Boxen::Service.list_enabled
|
18
|
+
assert_equal ['baz'], services.collect(&:name)
|
19
|
+
end
|
20
|
+
|
15
21
|
def test_enable
|
16
22
|
service = Boxen::Service.new('blip')
|
17
23
|
Boxen::Util.expects(:sudo).with('/bin/launchctl', 'load', '-w',
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Barnette
|
8
8
|
- Will Farrington
|
9
|
+
- David Goodlad
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: ansi
|
@@ -147,12 +148,12 @@ description: Manage Mac development boxes with love (and Puppet).
|
|
147
148
|
email:
|
148
149
|
- jbarnette@github.com
|
149
150
|
- wfarr@github.com
|
151
|
+
- dgoodlad@github.com
|
150
152
|
executables: []
|
151
153
|
extensions: []
|
152
154
|
extra_rdoc_files: []
|
153
155
|
files:
|
154
156
|
- .gitignore
|
155
|
-
- .ruby-version
|
156
157
|
- .travis.yml
|
157
158
|
- Gemfile
|
158
159
|
- LICENSE
|
@@ -265,3 +266,4 @@ test_files:
|
|
265
266
|
- test/fixtures/repo/modules/projects/manifests/first-project.pp
|
266
267
|
- test/fixtures/repo/modules/projects/manifests/second-project.pp
|
267
268
|
- test/system_timer.rb
|
269
|
+
has_rdoc:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
system
|