vagrant-dns 0.2.1 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # v0.2.2
2
+
3
+ * Default to 127.0.0.1 when no network option is given
4
+ * Warn if no default pattern is configured because TLD is given, but no host_name
5
+
6
+ # v0.2.1
7
+
8
+ * Fix a crash when /etc/resolver is not present
9
+
1
10
  # v0.2.0
2
11
 
3
12
  * Deactivate ipv6 support (was broken anyways)
@@ -34,10 +34,15 @@ module VagrantDNS
34
34
  registry = YAML.load(File.read(config_file)) if File.exists?(config_file)
35
35
  registry ||= {}
36
36
  opts = dns_options(vm)
37
- patterns = opts[:patterns] || opts[:tlds].map { |tld| /^.*#{opts[:host_name]}.#{tld}$/ }
37
+ patterns = opts[:patterns] || default_patterns(opts)
38
38
  network = opts[:networks].first
39
- ip = network.last.first
40
-
39
+
40
+ if network
41
+ ip = network.last.first
42
+ else
43
+ ip = '127.0.0.1'
44
+ end
45
+
41
46
  patterns.each do |p|
42
47
  p = p.source if p.respond_to? :source # Regexp#to_s is unusable
43
48
  registry[p] = ip
@@ -53,6 +58,15 @@ module VagrantDNS
53
58
  dns_options
54
59
  end
55
60
 
61
+ def default_patterns(opts)
62
+ if opts[:host_name]
63
+ opts[:tlds].map { |tld| /^.*#{opts[:host_name]}.#{tld}$/ }
64
+ else
65
+ warn 'TLD but no host_name given. No patterns will be configured.'
66
+ []
67
+ end
68
+ end
69
+
56
70
  def resolver_file(port)
57
71
  contents = <<-FILE
58
72
  # this file is generated by vagrant-dns
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Dns
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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: 2012-05-02 00:00:00.000000000 Z
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vagrant