vagrant-betterhosts 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 674b9ba6010434da286903277af9e899b2d2a982a8a4ce1434b523b460350b53
4
- data.tar.gz: 4b635e5ddc088af98faa0c59b200fd9346b01ac0b540ca6a70375f4a01d852cb
3
+ metadata.gz: eca3ca87fa47244989ff3f69adfa4eac5ac0793cc68d81b05ff1f77d053da052
4
+ data.tar.gz: 26bdb0c3f05e282baa1760849a65e7dfeaeba2ab267ab95a6916a6f5dd0f7c02
5
5
  SHA512:
6
- metadata.gz: 38c82c8b5344f0cc3d64521746dfdf1bd987f6362468b8fece767aff2ac1a1117d78fca0f30579f331ba38b5e45ee476cdb04ca2d5387a113ac92c6a9a3f7b39
7
- data.tar.gz: 37ead61d094950df99c39c10638bf223360d619b3fc0fbd8cc35330884486e3ac1e01d2382cc7994467eaf0b374e9ac1b8fe0a766539f79e86cf10499c94819f
6
+ metadata.gz: dc7655a442b2ba3aeee62349861c3ee0979e5f754ae8744a7925ff3b67ba184eb4dfc3c8784767332bbb6de080638b7a6b4bfd0b6e966c95305d3d2ee0923473
7
+ data.tar.gz: e4c5bf8a7ae014223a0d688d56c8ee5221dcc2ef813ff086b63e164239f0f139a6824ad47d130a7445c01bd8eb0f7ddfaa1da52bfc4c630313752118b4cd8ffd
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ GIT
28
28
  PATH
29
29
  remote: .
30
30
  specs:
31
- vagrant-betterhosts (1.0.0)
31
+ vagrant-betterhosts (0.2.0)
32
32
 
33
33
  GEM
34
34
  remote: https://rubygems.org/
@@ -71,10 +71,7 @@ module VagrantPlugins
71
71
 
72
72
  case @machine.config.betterhosts.aliases
73
73
  when Array
74
- # simple list of aliases to link to all ips
75
- ips.each do |ip|
76
- hostnames[ip] += @machine.config.betterhosts.aliases
77
- end
74
+ hostnames[ips[0]] += @machine.config.betterhosts.aliases
78
75
  when Hash
79
76
  # complex definition of aliases for various ips
80
77
  @machine.config.betterhosts.aliases.each do |ip, hosts|
@@ -82,9 +79,16 @@ module VagrantPlugins
82
79
  end
83
80
  end
84
81
 
85
- return hostnames
82
+ # handle default hostname(s) if not already specified in the aliases
83
+ Array(@machine.config.vm.hostname).each do |host|
84
+ next unless hostnames.none? { |_, v| v.include?(host) }
85
+
86
+ hostnames[ips[0]].unshift host
87
+ end
88
+
89
+ hostnames
86
90
  end
87
-
91
+
88
92
  def disableClean(ip_address)
89
93
  unless ip_address.nil?
90
94
  return @machine.config.betterhosts.disable_clean
@@ -105,6 +109,7 @@ module VagrantPlugins
105
109
  @ui.error "[vagrant-betterhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
106
110
  next
107
111
  end
112
+ @ui.info "[vagrant-betterhosts] Adding #{hostnames} for address #{ip_address}"
108
113
  if cli.include? ".exe"
109
114
  clean = "\"--clean\","
110
115
  if disableClean(ip_address)
@@ -175,37 +180,16 @@ module VagrantPlugins
175
180
  end
176
181
 
177
182
  def generateHostnamesByIps()
178
- hostnames_by_ips = []
179
183
  ips = getIps
180
- if ips.count() < 1
181
- return hostnames_by_ips
182
- end
184
+ return [] unless ips.any?
185
+
186
+ hostnames_by_ips = {}
183
187
  hostnames = getHostnames(ips)
184
- if ips.count() > 1
185
- ips.each do |ip|
186
- ip_address = ip
187
- if hostnames[ip].count() > 0
188
- hostnames[ip].each do |hostname|
189
- if !ip_address.nil?
190
- @ui.info "[vagrant-betterhosts] - found entry for: #{ip_address} #{hostname}"
191
- end
192
- end
193
- hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
194
- end
195
- end
196
- else
197
- ip_address = ips[0]
198
- if hostnames[ip_address].count() > 0
199
- hostnames[ip_address].each do |hostname|
200
- if !ip_address.nil?
201
- @ui.info "[vagrant-betterhosts] - found entry for: #{ip_address} #{hostname}"
202
- end
203
- end
204
- hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
205
- end
188
+ ips.each do |ip|
189
+ hostnames_by_ips[ip] = hostnames[ip].join(' ') if hostnames[ip].any?
206
190
  end
207
191
 
208
- return hostnames_by_ips
192
+ hostnames_by_ips
209
193
  end
210
194
  end
211
195
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module BetterHosts
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-betterhosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Butler