boxen 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ ---
2
+ script: "./script/tests"
3
+ gemfile: "this/does/not/exist"
4
+ rvm:
5
+ - "1.8.7"
data/README.md CHANGED
@@ -28,8 +28,8 @@ Use the OS X system Ruby (1.8.7). Run `script/tests` often. Open PR's.
28
28
  There are roughly nine million puppet modules under the
29
29
  [Boxen GitHub organization][boxen]. To clone them all, run
30
30
  `script/sync-puppet`. This script will make sure every
31
- `boxen/puppet-*` repo is cloned under the `./puppet`, which is ignored
32
- by Git.
31
+ `boxen/puppet-*` repo is cloned under the `./puppet` directory, which is
32
+ ignored by Git.
33
33
 
34
34
  [boxen]: https://github.com/boxen
35
35
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "boxen"
5
- gem.version = "0.3.3"
5
+ gem.version = "0.4.0"
6
6
  gem.authors = ["John Barnette", "Will Farrington"]
7
7
  gem.email = ["jbarnette@github.com", "wfarr@github.com"]
8
8
  gem.description = "Manage Mac development boxes with love (and Puppet)."
@@ -43,6 +43,41 @@ module Boxen
43
43
  exit
44
44
  end
45
45
 
46
+ # --disable-services stops all services
47
+
48
+ if flags.disable_services?
49
+ Dir["/Library/LaunchDaemons/com.boxen.*.plist"]. each do |service|
50
+ service_human_name = service.match(/com\.boxen\.(.+)\.plist$/)[1]
51
+ puts "Disabling #{service_human_name}..."
52
+ Boxen::Util.sudo("/bin/launchctl", "unload", "-w", service)
53
+ end
54
+
55
+ exit
56
+ end
57
+
58
+ # --enable-services starts all services
59
+
60
+ if flags.enable_services?
61
+ Dir["/Library/LaunchDaemons/com.boxen.*.plist"]. each do |service|
62
+ service_human_name = service.match(/com\.boxen\.(.+)\.plist$/)[1]
63
+ puts "Enabling #{service_human_name}..."
64
+ Boxen::Util.sudo("/bin/launchctl", "load", "-w", service)
65
+ end
66
+
67
+ exit
68
+ end
69
+
70
+ # --list-services lists all services
71
+
72
+ if flags.list_services?
73
+ Dir["/Library/LaunchDaemons/com.boxen.*.plist"]. each do |service|
74
+ service_human_name = service.match(/com\.boxen\.(.+)\.plist$/)[1]
75
+ puts service_human_name
76
+ end
77
+
78
+ exit
79
+ end
80
+
46
81
  # Actually run Puppet and return its exit code.
47
82
 
48
83
  puppet.run
@@ -20,15 +20,18 @@ module Boxen
20
20
  # parse immediately.
21
21
 
22
22
  def initialize(*args)
23
- @args = []
24
- @debug = false
25
- @env = false
26
- @fde = true
27
- @help = false
28
- @pretend = false
29
- @profile = false
30
- @projects = false
31
- @stealth = false
23
+ @args = []
24
+ @debug = false
25
+ @env = false
26
+ @fde = true
27
+ @help = false
28
+ @pretend = false
29
+ @profile = false
30
+ @projects = false
31
+ @stealth = false
32
+ @disable_services = false
33
+ @enable_services = false
34
+ @list_services = false
32
35
 
33
36
  @options = OptionParser.new do |o|
34
37
  o.banner = "Usage: #{File.basename $0} [options] [projects...]\n\n"
@@ -49,6 +52,18 @@ module Boxen
49
52
  @help = true
50
53
  end
51
54
 
55
+ o.on "--disable-services", "Disable Boxen services." do
56
+ @disable_services = true
57
+ end
58
+
59
+ o.on "--enable-services", "Enable Boxen services." do
60
+ @enable_services = true
61
+ end
62
+
63
+ o.on "--list-services", "List Boxen services." do
64
+ @list_services = true
65
+ end
66
+
52
67
  o.on "--homedir DIR", "Boxen's home directory." do |homedir|
53
68
  @homedir = homedir
54
69
  end
@@ -131,6 +146,18 @@ module Boxen
131
146
  @help
132
147
  end
133
148
 
149
+ def disable_services?
150
+ @disable_services
151
+ end
152
+
153
+ def enable_services?
154
+ @enable_services
155
+ end
156
+
157
+ def list_services?
158
+ @list_services
159
+ end
160
+
134
161
  # Parse `args` as an array of CLI argument Strings. Raises
135
162
  # Boxen::Error if anything goes wrong. Returns `self`.
136
163
 
@@ -6,6 +6,9 @@ class BoxenCLITest < Boxen::Test
6
6
  @config = Boxen::Config.new
7
7
  @flags = Boxen::Flags.new
8
8
  @cli = Boxen::CLI.new(@config, @flags)
9
+
10
+ $stdout.stubs(:puts).returns(true)
11
+ $stdout.stubs(:write).returns(true)
9
12
  end
10
13
 
11
14
  def test_initialize
@@ -17,7 +20,7 @@ class BoxenCLITest < Boxen::Test
17
20
  assert_equal config, cli.config
18
21
  assert_equal flags, cli.flags
19
22
  assert_equal config, cli.puppet.config
20
-
23
+
21
24
  assert_equal config, cli.reporter.config
22
25
  assert_equal config, cli.reporter.checkout.config
23
26
  assert_equal cli.checkout, cli.reporter.checkout
@@ -82,6 +85,16 @@ class BoxenCLITest < Boxen::Test
82
85
  @cli.run
83
86
  end
84
87
 
88
+ def test_run_success_exit_code_2
89
+ @cli.stubs(:issues?).returns(true)
90
+ @cli.stubs(:process).returns(2)
91
+
92
+ @cli.reporter.expects(:record_failure).never
93
+ @cli.reporter.expects(:close_failures)
94
+
95
+ @cli.run
96
+ end
97
+
85
98
  def test_run_failure_no_issues
86
99
  @cli.stubs(:issues?).returns(false)
87
100
  @cli.stubs(:process).returns(1)
@@ -101,4 +114,69 @@ class BoxenCLITest < Boxen::Test
101
114
 
102
115
  @cli.run
103
116
  end
104
- end
117
+
118
+ def test_run_success_exit_code_2_no_issues
119
+ @cli.stubs(:issues?).returns(false)
120
+ @cli.stubs(:process).returns(2)
121
+
122
+ @cli.reporter.expects(:record_failure).never
123
+ @cli.reporter.expects(:close_failures).never
124
+
125
+ @cli.run
126
+ end
127
+
128
+ def test_disable_services
129
+ config = Boxen::Config.new
130
+ flags = Boxen::Flags.new('--disable-services')
131
+ cli = Boxen::CLI.new config, flags
132
+
133
+ Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
134
+ "/Library/LaunchDaemons/com.boxen.test.plist"
135
+ ])
136
+ Boxen::Util.expects(:sudo).with(
137
+ "/bin/launchctl",
138
+ "unload",
139
+ "-w",
140
+ "/Library/LaunchDaemons/com.boxen.test.plist"
141
+ ).returns(true)
142
+
143
+ assert_raises(SystemExit) do
144
+ cli.process
145
+ end
146
+
147
+ def test_enable_services
148
+ config = Boxen::Config.new
149
+ flags = Boxen::Flags.new('--enable-services')
150
+ cli = Boxen::CLI.new config, flags
151
+
152
+ Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
153
+ "/Library/LaunchDaemons/com.boxen.test.plist"
154
+ ])
155
+
156
+ Boxen::Util.expects(:sudo).with(
157
+ "/bin/launchctl",
158
+ "load",
159
+ "-w",
160
+ "/Library/LaunchDaemons/com.boxen.test.plist"
161
+ ).returns(true)
162
+
163
+ assert_raises(SystemExit) do
164
+ cli.process
165
+ end
166
+
167
+ def test_list_services
168
+ config = Boxen::Config.new
169
+ flags = Boxen::Flags.new('--list-services')
170
+ cli = Boxen::CLI.new config, flags
171
+
172
+ Dir.expects(:[]).with("/Library/LaunchDaemons/com.boxen.*.plist").returns([
173
+ "/Library/LaunchDaemons/com.boxen.test.plist"
174
+ ])
175
+
176
+ assert_raises(SystemExit) do
177
+ cli.process
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
@@ -53,6 +53,21 @@ class BoxenFlagsTest < Boxen::Test
53
53
  end
54
54
  end
55
55
 
56
+ def test_disable_services?
57
+ refute flags.disable_services?
58
+ assert flags("--disable-services").disable_services?
59
+ end
60
+
61
+ def test_enable_services?
62
+ refute flags.enable_services?
63
+ assert flags("--enable-services").enable_services?
64
+ end
65
+
66
+ def test_list_services?
67
+ refute flags.list_services?
68
+ assert flags("--list-services").list_services?
69
+ end
70
+
56
71
  def test_homedir
57
72
  assert_nil flags.homedir
58
73
  assert_equal "foo", flags("--homedir", "foo").homedir
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Barnette
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-10-05 00:00:00 -10:00
19
+ date: 2012-10-09 00:00:00 -10:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -168,6 +168,7 @@ extra_rdoc_files: []
168
168
 
169
169
  files:
170
170
  - .gitignore
171
+ - .travis.yml
171
172
  - Gemfile
172
173
  - LICENSE
173
174
  - README.md