vagrant-vmhosts 0.0.3 → 0.0.4

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.
@@ -8,13 +8,15 @@ module VagrantVmHosts
8
8
  @app.call(env)
9
9
 
10
10
  hosts = env[:vm].config.vmhosts.list
11
- env[:ui].info I18n.t("vagrant.plugins.vmhosts.adding")
12
- hosts.each do |host|
13
- if !env[:vm].channel.test("grep '^#{host['ip']}[[:space:]]' /etc/hosts")
14
- env[:vm].channel.sudo("printf '%s\t%s %s\n' '#{host['ip']}' '#{host['canonical']}' '#{host['aliases'].join(' ')}' >> /etc/hosts")
11
+
12
+ if !hosts.empty?
13
+ env[:ui].info I18n.t("vagrant.plugins.vmhosts.adding")
14
+ hosts.each do |host|
15
+ if !env[:vm].channel.test("grep '^#{host['ip']}[[:space:]]' /etc/hosts")
16
+ env[:vm].channel.sudo("printf '%s\t%s %s\n' '#{host['ip']}' '#{host['canonical']}' '#{host['aliases'].join(' ')}' >> /etc/hosts")
17
+ end
15
18
  end
16
19
  end
17
20
  end
18
21
  end
19
22
  end
20
-
@@ -1,6 +1,10 @@
1
1
  module VagrantVmHosts
2
2
  class Config < Vagrant::Config::Base
3
- attr_accessor :list
3
+ attr_writer :list
4
+
5
+ def list
6
+ @list || []
7
+ end
4
8
 
5
9
  def validate(env, errors)
6
10
  # check hash format
@@ -1,3 +1,3 @@
1
1
  module VagrantVmHosts
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmhosts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kristof Willaert