akaer 2.1.2 → 2.2.0

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.
@@ -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 self.log_file == "STDOUT"
50
- self.log_file = $stderr if self.log_file == "STDERR"
51
- self.addresses = self.addresses.ensure_array
52
- self.aliases = self.aliases.to_integer
53
- self.log_level = self.log_level.to_integer
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
@@ -13,10 +13,10 @@ module Akaer
13
13
  MAJOR = 2
14
14
 
15
15
  # The minor version.
16
- MINOR = 1
16
+ MINOR = 2
17
17
 
18
18
  # The patch version.
19
- PATCH = 2
19
+ PATCH = 0
20
20
 
21
21
  # The current version of akaer.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -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) do Time.now end
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) do Time.now end
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
- if ::RbConfig::CONFIG['host_os'] =~ /^darwin/ then
269
- it "should create the agent" do
270
- application.stub(:launch_agent_path).and_return(launch_agent_path)
271
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
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
- it "should not create and invalid agent" do
279
- application.stub(:launch_agent_path).and_return("/invalid/agent")
280
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
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
- application.logger.should_receive(:error).with("Cannot create the launch agent.")
283
- application.action_install
284
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
285
- end
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
- it "should not load an invalid agent" do
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
- application.stub(:launch_agent_path).and_return(launch_agent_path)
293
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
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
- application.logger.should_receive(:error).with("Cannot load the launch agent.")
296
- application.action_install
297
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
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
- if ::RbConfig::CONFIG['host_os'] =~ /^darwin/ then
310
- it "should remove the agent" do
311
- application.stub(:launch_agent_path).and_return(launch_agent_path)
312
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
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
- it "should not load delete an invalid resolver" do
322
- application.stub(:launch_agent_path).and_return("/invalid/agent")
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
- application.action_install
325
- application.logger.should_receive(:warn).at_least(1)
326
- application.action_uninstall
327
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
328
- end
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
- it "should not delete an invalid agent" do
331
- application.stub(:launch_agent_path).and_return("/invalid/agent")
338
+ it "should not load delete an invalid resolver" do
339
+ application.stub(:launch_agent_path).and_return("/invalid/agent")
332
340
 
333
- application.action_install
334
- application.logger.should_receive(:warn).at_least(1)
335
- application.action_uninstall
336
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
337
- end
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
- it "should not load delete invalid agent" do
340
- application.stub(:launch_agent_path).and_return("/invalid/agent")
347
+ it "should not delete an invalid agent" do
348
+ application.stub(:launch_agent_path).and_return("/invalid/agent")
341
349
 
342
- application.action_install
343
- application.stub(:execute_command).and_raise(StandardError)
344
- application.logger.should_receive(:warn).at_least(1)
345
- application.action_uninstall
346
- ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
347
- end
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
@@ -6,6 +6,9 @@
6
6
 
7
7
  require "pathname"
8
8
  require "simplecov"
9
+ require "coveralls"
10
+
11
+ Coveralls.wear!
9
12
 
10
13
  SimpleCov.start do
11
14
  root = Pathname.new(File.dirname(__FILE__)) + ".."
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.1.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-04-13 00:00:00.000000000 Z
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.1.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.1.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: -1555315638351113188
114
+ hash: -3163015799533818897
115
115
  requirements: []
116
116
  rubyforge_project: akaer
117
117
  rubygems_version: 1.8.25