boxen 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
  gemspec
data/boxen.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "boxen"
5
- gem.version = "1.3.0"
5
+ gem.version = "1.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)."
data/lib/boxen/flags.rb CHANGED
@@ -16,6 +16,10 @@ module Boxen
16
16
  attr_reader :srcdir
17
17
  attr_reader :user
18
18
 
19
+ attr_reader :disable_service
20
+ attr_reader :enable_service
21
+ attr_reader :restart_service
22
+
19
23
  # Create a new instance, optionally providing CLI `args` to
20
24
  # parse immediately.
21
25
 
@@ -30,6 +34,9 @@ module Boxen
30
34
  @report = false
31
35
  @projects = false
32
36
  @stealth = false
37
+ @disable_service = false
38
+ @enable_service = false
39
+ @restart_service = false
33
40
  @disable_services = false
34
41
  @enable_services = false
35
42
  @restart_services = false
@@ -59,15 +66,27 @@ module Boxen
59
66
  @help = true
60
67
  end
61
68
 
62
- o.on "--disable-services", "Disable Boxen services." do
69
+ o.on "--disable-service SERVICE", "Disable a Boxen service." do |service|
70
+ @disable_service = service
71
+ end
72
+
73
+ o.on "--enable-service SERVICE", "Enable a Boxen service." do |service|
74
+ @enable_service = service
75
+ end
76
+
77
+ o.on "--restart-service SERVICE", "Restart a Boxen service." do |service|
78
+ @restart_service = service
79
+ end
80
+
81
+ o.on "--disable-services", "Disable all Boxen services." do
63
82
  @disable_services = true
64
83
  end
65
84
 
66
- o.on "--enable-services", "Enable Boxen services." do
85
+ o.on "--enable-services", "Enable all Boxen services." do
67
86
  @enable_services = true
68
87
  end
69
88
 
70
- o.on "--restart-services", "Restart Boxen services." do
89
+ o.on "--restart-services", "Restart all Boxen services." do
71
90
  @restart_services = true
72
91
  end
73
92
 
@@ -176,6 +195,18 @@ module Boxen
176
195
  @enable_services
177
196
  end
178
197
 
198
+ def disable_service?
199
+ @disable_service
200
+ end
201
+
202
+ def enable_service?
203
+ @enable_service
204
+ end
205
+
206
+ def restart_service?
207
+ @restart_service
208
+ end
209
+
179
210
  def restart_services?
180
211
  @restart_services
181
212
  end
@@ -1,11 +1,29 @@
1
1
  require "boxen/preflight"
2
2
 
3
3
  class Boxen::Preflight::OS < Boxen::Preflight
4
+ SUPPORTED_RELEASES = %w(10.8 10.9)
5
+
4
6
  def ok?
5
- `sw_vers -productVersion`.start_with? "10.8"
7
+ osx? && supported_release?
6
8
  end
7
9
 
8
10
  def run
9
- abort "You must be running OS X 10.8 (Mountain Lion)."
11
+ abort "You must be running one of the following OS X versions: #{SUPPORTED_RELEASES.join(' ')}."
12
+ end
13
+
14
+ private
15
+
16
+ def osx?
17
+ `uname -s` == "Darwin"
18
+ end
19
+
20
+ def supported_release?
21
+ SUPPORTED_RELEASES.any? do |r|
22
+ current_release.starts_with? r
23
+ end
24
+ end
25
+
26
+ def current_release
27
+ @current_release ||= `sw_vers -productVersion`
10
28
  end
11
29
  end
data/lib/boxen/runner.rb CHANGED
@@ -83,6 +83,37 @@ module Boxen
83
83
  exit
84
84
  end
85
85
 
86
+ # --disable-service [name] stops a service
87
+
88
+ if flags.disable_service?
89
+ service = Boxen::Service.new(flags.disable_service)
90
+ puts "Disabling #{service}..."
91
+ service.disable
92
+
93
+ exit
94
+ end
95
+
96
+ # --enable-service [name] starts a service
97
+
98
+ if flags.enable_service?
99
+ service = Boxen::Service.new(flags.enable_service)
100
+ puts "Enabling #{service}..."
101
+ service.enable
102
+
103
+ exit
104
+ end
105
+
106
+ # --restart-service [name] starts a service
107
+
108
+ if flags.restart_service?
109
+ service = Boxen::Service.new(flags.restart_service)
110
+ puts "Restarting #{service}..."
111
+ service.disable
112
+ service.enable
113
+
114
+ exit
115
+ end
116
+
86
117
  # --list-services lists all services
87
118
 
88
119
  if flags.list_services?
@@ -40,6 +40,48 @@ class BoxenRunnerTest < Boxen::Test
40
40
  runner.report(stub('result'))
41
41
  end
42
42
 
43
+ def test_disable_service
44
+ config = Boxen::Config.new
45
+ flags = Boxen::Flags.new('--disable-service', 'test')
46
+ runner = Boxen::Runner.new config, flags
47
+
48
+ service = mock('service', :disable => true)
49
+ Boxen::Service.stubs(:new).returns(service)
50
+
51
+ assert_raises(SystemExit) do
52
+ runner.process
53
+ end
54
+ end
55
+
56
+ def test_enable_service
57
+ config = Boxen::Config.new
58
+ flags = Boxen::Flags.new('--enable-service', 'test')
59
+ runner = Boxen::Runner.new config, flags
60
+
61
+ service = mock('service', :enable => true)
62
+ Boxen::Service.stubs(:new).returns(service)
63
+
64
+ assert_raises(SystemExit) do
65
+ runner.process
66
+ end
67
+ end
68
+
69
+ def test_restart_service
70
+ config = Boxen::Config.new
71
+ flags = Boxen::Flags.new('--restart-service', 'test')
72
+ runner = Boxen::Runner.new config, flags
73
+
74
+ service = mock('service')
75
+ service.expects(:disable).once
76
+ service.expects(:enable).once
77
+
78
+ Boxen::Service.stubs(:new).returns(service)
79
+
80
+ assert_raises(SystemExit) do
81
+ runner.process
82
+ end
83
+ end
84
+
43
85
  def test_disable_services
44
86
  config = Boxen::Config.new
45
87
  flags = Boxen::Flags.new('--disable-services')
metadata CHANGED
@@ -1,160 +1,175 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: boxen
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 3
8
- - 0
9
- version: 1.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - John Barnette
13
9
  - Will Farrington
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2013-05-22 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2013-06-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: ansi
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
26
20
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 1
30
- - 4
31
- version: "1.4"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.4'
32
23
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: hiera
36
24
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.4'
31
+ - !ruby/object:Gem::Dependency
32
+ name: hiera
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
39
36
  - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 0
44
- version: "1.0"
37
+ - !ruby/object:Gem::Version
38
+ version: '1.0'
45
39
  type: :runtime
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- name: highline
49
40
  prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
51
- requirements:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: highline
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
52
  - - ~>
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 1
56
- - 6
57
- version: "1.6"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
58
55
  type: :runtime
59
- version_requirements: *id003
60
- - !ruby/object:Gem::Dependency
61
- name: json_pure
62
56
  prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 1
69
- - 7
70
- - 7
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.6'
63
+ - !ruby/object:Gem::Dependency
64
+ name: json_pure
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
71
70
  version: 1.7.7
72
71
  - - <
73
- - !ruby/object:Gem::Version
74
- segments:
75
- - 2
76
- - 0
77
- version: "2.0"
72
+ - !ruby/object:Gem::Version
73
+ version: '2.0'
78
74
  type: :runtime
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: librarian-puppet
82
75
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
84
- requirements:
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: 1.7.7
82
+ - - <
83
+ - !ruby/object:Gem::Version
84
+ version: '2.0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: librarian-puppet
87
+ requirement: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
85
90
  - - ~>
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- - 9
90
- - 9
91
+ - !ruby/object:Gem::Version
91
92
  version: 0.9.9
92
93
  type: :runtime
93
- version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- name: octokit
96
94
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- requirements:
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: 0.9.9
101
+ - !ruby/object:Gem::Dependency
102
+ name: octokit
103
+ requirement: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
99
106
  - - ~>
100
- - !ruby/object:Gem::Version
101
- segments:
102
- - 1
103
- - 15
104
- version: "1.15"
107
+ - !ruby/object:Gem::Version
108
+ version: '1.15'
105
109
  type: :runtime
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: puppet
109
110
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
111
- requirements:
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ version: '1.15'
117
+ - !ruby/object:Gem::Dependency
118
+ name: puppet
119
+ requirement: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
112
122
  - - ~>
113
- - !ruby/object:Gem::Version
114
- segments:
115
- - 3
116
- - 0
117
- version: "3.0"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
118
125
  type: :runtime
119
- version_requirements: *id007
120
- - !ruby/object:Gem::Dependency
121
- name: minitest
122
126
  prerelease: false
123
- requirement: &id008 !ruby/object:Gem::Requirement
124
- requirements:
125
- - - "="
126
- - !ruby/object:Gem::Version
127
- segments:
128
- - 4
129
- - 4
130
- - 0
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: '3.0'
133
+ - !ruby/object:Gem::Dependency
134
+ name: minitest
135
+ requirement: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - '='
139
+ - !ruby/object:Gem::Version
131
140
  version: 4.4.0
132
141
  type: :development
133
- version_requirements: *id008
134
- - !ruby/object:Gem::Dependency
135
- name: mocha
136
142
  prerelease: false
137
- requirement: &id009 !ruby/object:Gem::Requirement
138
- requirements:
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - '='
147
+ - !ruby/object:Gem::Version
148
+ version: 4.4.0
149
+ - !ruby/object:Gem::Dependency
150
+ name: mocha
151
+ requirement: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
139
154
  - - ~>
140
- - !ruby/object:Gem::Version
141
- segments:
142
- - 0
143
- - 13
144
- version: "0.13"
155
+ - !ruby/object:Gem::Version
156
+ version: '0.13'
145
157
  type: :development
146
- version_requirements: *id009
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ~>
163
+ - !ruby/object:Gem::Version
164
+ version: '0.13'
147
165
  description: Manage Mac development boxes with love (and Puppet).
148
- email:
166
+ email:
149
167
  - jbarnette@github.com
150
168
  - wfarr@github.com
151
169
  executables: []
152
-
153
170
  extensions: []
154
-
155
171
  extra_rdoc_files: []
156
-
157
- files:
172
+ files:
158
173
  - .gitignore
159
174
  - .travis.yml
160
175
  - Gemfile
@@ -219,37 +234,31 @@ files:
219
234
  - test/fixtures/repo/modules/projects/manifests/first-project.pp
220
235
  - test/fixtures/repo/modules/projects/manifests/second-project.pp
221
236
  - test/system_timer.rb
222
- has_rdoc: true
223
237
  homepage: https://github.com/boxen/boxen
224
238
  licenses: []
225
-
226
239
  post_install_message:
227
240
  rdoc_options: []
228
-
229
- require_paths:
241
+ require_paths:
230
242
  - lib
231
- required_ruby_version: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - ">="
234
- - !ruby/object:Gem::Version
235
- segments:
236
- - 0
237
- version: "0"
238
- required_rubygems_version: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - ">="
241
- - !ruby/object:Gem::Version
242
- segments:
243
- - 0
244
- version: "0"
243
+ required_ruby_version: !ruby/object:Gem::Requirement
244
+ none: false
245
+ requirements:
246
+ - - ! '>='
247
+ - !ruby/object:Gem::Version
248
+ version: '0'
249
+ required_rubygems_version: !ruby/object:Gem::Requirement
250
+ none: false
251
+ requirements:
252
+ - - ! '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
245
255
  requirements: []
246
-
247
256
  rubyforge_project:
248
- rubygems_version: 1.3.6
257
+ rubygems_version: 1.8.23
249
258
  signing_key:
250
259
  specification_version: 3
251
260
  summary: You know, for laptops and stuff.
252
- test_files:
261
+ test_files:
253
262
  - test/boxen/test.rb
254
263
  - test/boxen_check_test.rb
255
264
  - test/boxen_checkout_test.rb