vagrant-rubydns 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -17,6 +17,10 @@ Spin up the DNS server
17
17
 
18
18
  $ vagrant rubydns
19
19
 
20
+ Enable the plugin in your `Vagrantfile`:
21
+
22
+ config.rubydns.enable
23
+
20
24
  Bring up a machine that has a private network IP address and a hostname (see the `Vagrantfile` for an example)
21
25
 
22
26
  $ vagrant up
@@ -27,7 +31,7 @@ And you should be able to get your hostname from your host:
27
31
 
28
32
  If you shut down your guest, the entries associated with it will be removed.
29
33
 
30
- You can add static host entries to the DNS server in your Vagrantfile like so:
34
+ You can add static host entries to the DNS server in your `Vagrantfile` like so:
31
35
 
32
36
  config.rubydns.host 'myhost.example.com', '1.2.3.4'
33
37
 
data/examples/Vagrantfile CHANGED
@@ -15,6 +15,7 @@ Vagrant.require_plugin "vagrant-rubydns"
15
15
  Vagrant.configure("2") do |config|
16
16
  config.vm.box = "precise64"
17
17
 
18
+ config.rubydns.enable
18
19
  config.vm.provision :rubydns
19
20
 
20
21
  config.vm.network :private_network, ip: '172.16.32.111'
@@ -6,8 +6,10 @@ module VagrantRubydns
6
6
  end
7
7
 
8
8
  def call(env)
9
- setup_machine_dns(env)
10
- setup_static_dns(env)
9
+ if env[:global_config].rubydns.enabled?
10
+ setup_machine_dns(env)
11
+ setup_static_dns(env)
12
+ end
11
13
  @app.call(env)
12
14
  end
13
15
 
@@ -6,8 +6,10 @@ module VagrantRubydns
6
6
  end
7
7
 
8
8
  def call(env)
9
- teardown_static_dns(env)
10
- teardown_machine_dns(env)
9
+ if env[:global_config].rubydns.enabled?
10
+ teardown_static_dns(env)
11
+ teardown_machine_dns(env)
12
+ end
11
13
  @app.call(env)
12
14
  end
13
15
 
@@ -4,6 +4,19 @@ module VagrantRubydns
4
4
 
5
5
  def initialize
6
6
  @hosts = {}
7
+ @enabled = false
8
+ end
9
+
10
+ def enable(enabled=true)
11
+ @enabled = true
12
+ end
13
+
14
+ def disable
15
+ @enabled = false
16
+ end
17
+
18
+ def enabled?
19
+ @enabled
7
20
  end
8
21
 
9
22
  def host(hostname, ip_address)
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Rubydns
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/test/test_helper.rb CHANGED
@@ -36,6 +36,8 @@ def fake_environment_with_machine(hostname, ip)
36
36
  env
37
37
  )
38
38
 
39
+ machine.config.rubydns.enable
40
+
39
41
  machine.config.vm.hostname = hostname
40
42
  machine.config.vm.network :private_network, ip: ip
41
43
 
@@ -26,6 +26,20 @@ module VagrantRubydns
26
26
 
27
27
  Store.get('somehost.vagrant.dev').must_equal '1.2.3.4'
28
28
  end
29
+
30
+ it "does nothing if it is not enabled via config" do
31
+ Store.clear!
32
+
33
+ app = Proc.new {}
34
+ setup = Setup.new(app, nil)
35
+
36
+ env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
37
+ env[:global_config].rubydns.disable
38
+
39
+ setup.call(env)
40
+
41
+ Store.get('somehost.vagrant.dev').must_equal nil
42
+ end
29
43
  end
30
44
  end
31
45
  end
@@ -15,7 +15,7 @@ module VagrantRubydns
15
15
  env[:called].must_equal true
16
16
  end
17
17
 
18
- it "stores the machine's hostname => ip address" do
18
+ it "clears the machine's hostname => ip address" do
19
19
  Store.set('somehost.vagrant.dev', '1.2.3.4')
20
20
 
21
21
  app = Proc.new {}
@@ -26,6 +26,22 @@ module VagrantRubydns
26
26
 
27
27
  Store.get('somehost.vagrant.dev').must_equal nil
28
28
  end
29
+
30
+ it "does nothing when rubydns is disabled" do
31
+ # somewhat unrealistic since this entry shouldn't be there if it was
32
+ # disabled in the first place, but oh well
33
+ Store.set('somehost.vagrant.dev', '1.2.3.4')
34
+
35
+ app = Proc.new {}
36
+ teardown = Teardown.new(app, nil)
37
+
38
+ env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
39
+ env[:global_config].rubydns.disable
40
+
41
+ teardown.call(env)
42
+
43
+ Store.get('somehost.vagrant.dev').must_equal '1.2.3.4'
44
+ end
29
45
  end
30
46
  end
31
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rubydns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-03-28 00:00:00.000000000 Z
12
+ date: 2013-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubydns