vagrant-multi-hostsupdater 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b87cd919819f6b66773070ea606950aafad31c46
4
- data.tar.gz: 1e25433e87227be92e37d4afdff688dbf3886432
3
+ metadata.gz: 525bc4999260ee40ed1d7f3126df0c71b82c9e4b
4
+ data.tar.gz: 14c86c1da0060ef2e67560229765c3c83ffe923c
5
5
  SHA512:
6
- metadata.gz: b723ddfd39e78f65a657684429a99045d1590ece87b1abe826c66a801c8a5702025bfac976d89c42a26d3b2e7418a522fcd6a5cfaa8ed4f1360945eeacb34ba5
7
- data.tar.gz: 716a840dcaa6b908404be97c700d93b01345f8cf74dfa8dcfc88167a8c29a2545bedbcaffeb8df119fa7f6725c55d9311926ce0db68ca00e5b3db50491b83c80
6
+ metadata.gz: 956dd624474534c5b6abe3eb81667637177445aec2691c601887c1d8bb273d5b16d3b849d9eb119016d523d39165be4b882fa34e0a8f3f0d5d6ff2bc1a7e0c48
7
+ data.tar.gz: fe7df8850a24b426612f8517c266b5cd32ab7d2c833af453e28af93bb5f45e62913e10359cd770a87f1cfa29834841196a1e2965eff47c9d5bae4f33f2c8e969
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Vagrant::Hostsupdater
1
+ # Vagrant::MultiHostsUpdater
2
2
 
3
3
  This plugin adds an entry to your /etc/hosts file on the host system.
4
4
 
@@ -7,7 +7,7 @@ On **up**, **resume** and **reload** commands, it tries to add the information,
7
7
  On **halt** and **destroy**, those entries will be removed again.
8
8
  By setting the remove\_on\_suspend option, you can have them removed on **suspend**, too:
9
9
 
10
- config.hostsupdater.remove_on_suspend = true
10
+ config.multihostsupdater.remove_on_suspend = true
11
11
 
12
12
 
13
13
 
@@ -25,7 +25,7 @@ At the moment, the only things you need, are the hostname and a :private_network
25
25
 
26
26
  config.vm.network :private_network, ip: "192.168.3.10"
27
27
  config.vm.hostname = "www.testing.de"
28
- config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
28
+ config.multihostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
29
29
 
30
30
  This ip and the hostname will be used for the entry in the /etc/hosts file.
31
31
 
@@ -2,7 +2,7 @@ require "vagrant-multi-hostsupdater/version"
2
2
  require "vagrant-multi-hostsupdater/plugin"
3
3
 
4
4
  module VagrantPlugins
5
- module HostsUpdater
5
+ module MultiHostsUpdater
6
6
  def self.source_root
7
7
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module VagrantPlugins
2
- module HostsUpdater
2
+ module MultiHostsUpdater
3
3
  module Action
4
4
  class CacheHosts
5
- include HostsUpdater
5
+ include MultiHostsUpdater
6
6
 
7
7
  def initialize(app, env)
8
8
  @app = app
@@ -1,8 +1,8 @@
1
1
  module VagrantPlugins
2
- module HostsUpdater
2
+ module MultiHostsUpdater
3
3
  module Action
4
4
  class RemoveHosts
5
- include HostsUpdater
5
+ include MultiHostsUpdater
6
6
 
7
7
  def initialize(app, env)
8
8
  @app = app
@@ -13,7 +13,7 @@ module VagrantPlugins
13
13
  def call(env)
14
14
  machine_action = env[:machine_action]
15
15
  if machine_action != :destroy || !@machine.id
16
- if machine_action != :suspend || @machine.config.hostsupdater.remove_on_suspend
16
+ if machine_action != :suspend || @machine.config.multihostsupdater.remove_on_suspend
17
17
  @ui.info "Removing hosts"
18
18
  removeHostEntries
19
19
  else
@@ -1,9 +1,9 @@
1
- require_relative "../HostsUpdater"
1
+ require_relative "../MultiHostsUpdater"
2
2
  module VagrantPlugins
3
- module HostsUpdater
3
+ module MultiHostsUpdater
4
4
  module Action
5
5
  class UpdateHosts
6
- include HostsUpdater
6
+ include MultiHostsUpdater
7
7
 
8
8
 
9
9
  def initialize(app, env)
@@ -13,8 +13,9 @@ module VagrantPlugins
13
13
  end
14
14
 
15
15
  def call(env)
16
- @ui.info "Checking for host entries"
16
+ @ui.info "Checking for host entries with env #{env}"
17
17
  @app.call(env)
18
+ puts "about to call addhostentries"
18
19
  addHostEntries()
19
20
  end
20
21
 
@@ -15,15 +15,15 @@ module VagrantPlugins
15
15
 
16
16
  # Get hostnames by specific IP.
17
17
  # This option is only valid if a Hash is provided
18
- # from the `config.MultiHostsUpdater.aliases` parameter
18
+ # from the `config.multihostsupdater.aliases` parameter
19
19
  def getHostnames(ip=nil)
20
20
 
21
21
  hostnames = []
22
- if @machine.config.MultiHostsUpdater.aliases.is_a?(Hash)
23
- hostnames = @machine.config.MultiHostsUpdater.aliases[ip] || hostnames
22
+ if @machine.config.multihostsupdater.aliases.is_a?(Hash)
23
+ hostnames = @machine.config.multihostsupdater.aliases[ip] || hostnames
24
24
  else
25
25
  hostnames = Array(@machine.config.vm.hostname)
26
- hostnames.concat(@machine.config.MultiHostsUpdater.aliases)
26
+ hostnames.concat(@machine.config.multihostsupdater.aliases)
27
27
  end
28
28
 
29
29
  return hostnames
@@ -51,17 +51,17 @@ module VagrantPlugins
51
51
  end
52
52
 
53
53
  def cacheHostEntries
54
- @machine.config.MultiHostsUpdater.id = @machine.id
54
+ @machine.config.multihostsupdater.id = @machine.id
55
55
  end
56
56
 
57
57
  def removeHostEntries
58
- if !@machine.id and !@machine.config.MultiHostsUpdater.id
58
+ if !@machine.id and !@machine.config.multihostsupdater.id
59
59
  @ui.warn "No machine id, nothing removed from #@@hosts_path"
60
60
  return
61
61
  end
62
62
  file = File.open(@@hosts_path, "rb")
63
63
  hostsContents = file.read
64
- uuid = @machine.id || @machine.config.MultiHostsUpdater.id
64
+ uuid = @machine.id || @machine.config.multihostsupdater.id
65
65
  hashedId = Digest::MD5.hexdigest(uuid)
66
66
  if hostsContents.match(/#{hashedId}/)
67
67
  removeFromHosts
@@ -94,7 +94,7 @@ module VagrantPlugins
94
94
  end
95
95
 
96
96
  def removeFromHosts(options = {})
97
- uuid = @machine.id || @machine.config.MultiHostsUpdater.id
97
+ uuid = @machine.id || @machine.config.multihostsupdater.id
98
98
  hashedId = Digest::MD5.hexdigest(uuid)
99
99
  if !File.writable?(@@hosts_path)
100
100
  sudo(%Q(sed -i -e '/#{hashedId}/ d' #@@hosts_path))
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
- module HostsUpdater
2
+ module MultiHostsUpdater
3
3
  class Command < Vagrant.plugin('2', :command)
4
4
  #include HostsFile
5
5
 
@@ -1,7 +1,7 @@
1
1
  require "vagrant"
2
2
 
3
3
  module VagrantPlugins
4
- module HostsUpdater
4
+ module MultiHostsUpdater
5
5
  class Config < Vagrant.plugin("2", :config)
6
6
 
7
7
  # Array of hostnames to add or a Map[String => Array] of IPs to hostnames.
@@ -3,48 +3,48 @@ require "vagrant-multi-hostsupdater/Action/CacheHosts"
3
3
  require "vagrant-multi-hostsupdater/Action/RemoveHosts"
4
4
 
5
5
  module VagrantPlugins
6
- module HostsUpdater
6
+ module MultiHostsUpdater
7
7
  class Plugin < Vagrant.plugin('2')
8
- name 'HostsUpdater'
8
+ name 'MultiHostsUpdater'
9
9
  description <<-DESC
10
10
  This plugin manages the /etc/hosts file for the host machine. An entry is
11
11
  created for the hostname attribute in the vm.config.
12
12
  DESC
13
13
 
14
- config(:hostsupdater) do
14
+ config(:multihostsupdater) do
15
15
  require_relative 'config'
16
16
  Config
17
17
  end
18
18
 
19
- action_hook(:hostsupdater, :machine_action_up) do |hook|
19
+ action_hook(:multihostsupdater, :machine_action_up) do |hook|
20
20
  hook.append(Action::UpdateHosts)
21
21
  end
22
22
 
23
- action_hook(:hostsupdater, :machine_action_halt) do |hook|
23
+ action_hook(:multihostsupdater, :machine_action_halt) do |hook|
24
24
  hook.append(Action::RemoveHosts)
25
25
  end
26
26
 
27
- action_hook(:hostsupdater, :machine_action_suspend) do |hook|
27
+ action_hook(:multihostsupdater, :machine_action_suspend) do |hook|
28
28
  hook.append(Action::RemoveHosts)
29
29
  end
30
30
 
31
- action_hook(:hostsupdater, :machine_action_destroy) do |hook|
31
+ action_hook(:multihostsupdater, :machine_action_destroy) do |hook|
32
32
  hook.prepend(Action::CacheHosts)
33
33
  end
34
34
 
35
- action_hook(:hostsupdater, :machine_action_destroy) do |hook|
35
+ action_hook(:multihostsupdater, :machine_action_destroy) do |hook|
36
36
  hook.append(Action::RemoveHosts)
37
37
  end
38
38
 
39
- action_hook(:hostsupdater, :machine_action_reload) do |hook|
39
+ action_hook(:multihostsupdater, :machine_action_reload) do |hook|
40
40
  hook.append(Action::UpdateHosts)
41
41
  end
42
42
 
43
- action_hook(:hostsupdater, :machine_action_resume) do |hook|
43
+ action_hook(:multihostsupdater, :machine_action_resume) do |hook|
44
44
  hook.append(Action::UpdateHosts)
45
45
  end
46
46
 
47
- command(:hostsupdater) do
47
+ command(:multihostsupdater) do
48
48
  require_relative 'command'
49
49
  Command
50
50
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module MultiHostsUpdater
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-multi-hostsupdater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Fellows