akaer 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis-gemfile +5 -3
- data/.travis.yml +1 -1
- data/Gemfile +5 -4
- data/README.md +1 -0
- data/akaer.gemspec +1 -1
- data/bin/akaer +4 -4
- data/doc/Akaer.html +5 -5
- data/doc/Akaer/Application.html +112 -112
- data/doc/Akaer/ApplicationMethods.html +5 -5
- data/doc/Akaer/ApplicationMethods/General.html +7 -7
- data/doc/Akaer/ApplicationMethods/System.html +25 -25
- data/doc/Akaer/Configuration.html +10 -10
- data/doc/Akaer/Version.html +7 -7
- data/doc/_index.html +6 -6
- data/doc/class_list.html +2 -1
- data/doc/file.README.html +7 -6
- data/doc/file_list.html +2 -1
- data/doc/frames.html +1 -1
- data/doc/index.html +7 -6
- data/doc/js/full_list.js +7 -2
- data/doc/method_list.html +21 -60
- data/doc/top-level-namespace.html +5 -5
- data/lib/akaer/application.rb +45 -52
- data/lib/akaer/configuration.rb +5 -5
- data/lib/akaer/version.rb +2 -2
- data/spec/akaer/application_spec.rb +76 -60
- data/spec/coverage_helper.rb +3 -0
- metadata +5 -5
data/lib/akaer/configuration.rb
CHANGED
@@ -46,11 +46,11 @@ module Akaer
|
|
46
46
|
super(file, overrides, logger)
|
47
47
|
|
48
48
|
# Make sure some arguments are of correct type
|
49
|
-
self.log_file = $stdout if
|
50
|
-
self.log_file = $stderr if
|
51
|
-
self.addresses =
|
52
|
-
self.aliases =
|
53
|
-
self.log_level =
|
49
|
+
self.log_file = $stdout if log_file == "STDOUT"
|
50
|
+
self.log_file = $stderr if log_file == "STDERR"
|
51
|
+
self.addresses = addresses.ensure_array
|
52
|
+
self.aliases = aliases.to_integer
|
53
|
+
self.log_level = log_level.to_integer
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/akaer/version.rb
CHANGED
@@ -39,13 +39,13 @@ describe Akaer::Application do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it("should return the same instance") do
|
42
|
-
::Akaer::Application.stub(:new)
|
42
|
+
::Akaer::Application.stub(:new) { Time.now }
|
43
43
|
instance = ::Akaer::Application.instance("start")
|
44
44
|
expect(::Akaer::Application.instance("stop")).to be(instance)
|
45
45
|
end
|
46
46
|
|
47
47
|
it("should return a new instance if requested to") do
|
48
|
-
::Akaer::Application.stub(:new)
|
48
|
+
::Akaer::Application.stub(:new) { Time.now }
|
49
49
|
instance = ::Akaer::Application.instance("")
|
50
50
|
expect(::Akaer::Application.instance({"log-file" => "/dev/null"}, nil, true)).not_to be(instance)
|
51
51
|
end
|
@@ -171,6 +171,15 @@ describe Akaer::Application do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
describe "#is_osx?" do
|
175
|
+
it "should return the correct information" do
|
176
|
+
stub_const("RbConfig::CONFIG", {"host_os" => "darwin foo"})
|
177
|
+
expect(application.is_osx?).to be_true
|
178
|
+
stub_const("RbConfig::CONFIG", {"host_os" => "another"})
|
179
|
+
expect(application.is_osx?).to be_false
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
174
183
|
describe "#manage" do
|
175
184
|
it "should show a right message to the user" do
|
176
185
|
application.logger.should_receive(:info).with(/.+.*03.*\/.*05.*.+ *Adding.* address .*10.0.0.3.* to interface .*lo0.*/)
|
@@ -265,37 +274,41 @@ describe Akaer::Application do
|
|
265
274
|
end
|
266
275
|
|
267
276
|
describe "#action_install" do
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
application.action_install
|
274
|
-
expect(::File.exists?(application.launch_agent_path)).to be_true
|
275
|
-
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
276
|
-
end
|
277
|
+
before(:each) do
|
278
|
+
application.stub(:is_osx?).and_return(true)
|
279
|
+
application.stub(:execute_command)
|
280
|
+
end
|
277
281
|
|
278
|
-
|
279
|
-
|
280
|
-
|
282
|
+
it "should create the agent" do
|
283
|
+
application.stub(:launch_agent_path).and_return(launch_agent_path)
|
284
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
281
285
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
+
application.action_install
|
287
|
+
expect(::File.exists?(application.launch_agent_path)).to be_true
|
288
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should not create and invalid agent" do
|
292
|
+
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
286
293
|
|
287
|
-
|
288
|
-
application.stub(:execute_command) do |command|
|
289
|
-
command =~ /^launchctl/ ? raise(StandardError) : system(command)
|
290
|
-
end
|
294
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
291
295
|
|
292
|
-
|
293
|
-
|
296
|
+
application.logger.should_receive(:error).with("Cannot create the launch agent.")
|
297
|
+
application.action_install
|
298
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
299
|
+
end
|
294
300
|
|
295
|
-
|
296
|
-
|
297
|
-
|
301
|
+
it "should not load an invalid agent" do
|
302
|
+
application.stub(:execute_command) do |command|
|
303
|
+
command =~ /^launchctl/ ? raise(StandardError) : true
|
298
304
|
end
|
305
|
+
|
306
|
+
application.stub(:launch_agent_path).and_return(launch_agent_path)
|
307
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
308
|
+
|
309
|
+
application.logger.should_receive(:error).with("Cannot load the launch agent.")
|
310
|
+
application.action_install
|
311
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
299
312
|
end
|
300
313
|
|
301
314
|
it "should raise an exception if not running on OSX" do
|
@@ -306,45 +319,48 @@ describe Akaer::Application do
|
|
306
319
|
end
|
307
320
|
|
308
321
|
describe "#action_uninstall" do
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
Bovem::Logger.stub(:default_file).and_return($stdout)
|
315
|
-
application.action_install
|
316
|
-
application.action_uninstall
|
317
|
-
expect(::File.exists?(application.launch_agent_path)).to be_false
|
318
|
-
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
319
|
-
end
|
322
|
+
before(:each) do
|
323
|
+
application.stub(:is_osx?).and_return(true)
|
324
|
+
application.stub(:execute_command)
|
325
|
+
end
|
320
326
|
|
321
|
-
|
322
|
-
|
327
|
+
it "should remove the agent" do
|
328
|
+
application.stub(:launch_agent_path).and_return(launch_agent_path)
|
329
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
323
330
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
331
|
+
Bovem::Logger.stub(:default_file).and_return($stdout)
|
332
|
+
application.action_install
|
333
|
+
application.action_uninstall
|
334
|
+
expect(::File.exists?(application.launch_agent_path)).to be_false
|
335
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
336
|
+
end
|
329
337
|
|
330
|
-
|
331
|
-
|
338
|
+
it "should not load delete an invalid resolver" do
|
339
|
+
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
332
340
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
341
|
+
application.action_install
|
342
|
+
application.logger.should_receive(:warn).at_least(1)
|
343
|
+
application.action_uninstall
|
344
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
345
|
+
end
|
338
346
|
|
339
|
-
|
340
|
-
|
347
|
+
it "should not delete an invalid agent" do
|
348
|
+
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
341
349
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
350
|
+
application.action_install
|
351
|
+
application.logger.should_receive(:warn).at_least(1)
|
352
|
+
application.action_uninstall
|
353
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should not load delete invalid agent" do
|
357
|
+
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
358
|
+
|
359
|
+
application.action_install
|
360
|
+
application.stub(:execute_command).and_raise(StandardError)
|
361
|
+
application.logger.should_receive(:warn).at_least(1)
|
362
|
+
application.action_uninstall
|
363
|
+
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
348
364
|
end
|
349
365
|
|
350
366
|
it "should raise an exception if not running on OSX" do
|
data/spec/coverage_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akaer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mamertes
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: 2.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: mustache
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
segments:
|
113
113
|
- 0
|
114
|
-
hash: -
|
114
|
+
hash: -3163015799533818897
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project: akaer
|
117
117
|
rubygems_version: 1.8.25
|