vagrant-hostsupdater 0.0.2 → 0.0.3

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
- SHA512:
3
- data.tar.gz: 41d5f5dda99247f31cdfca83d319b2efc2dc5673fba3ed70b689da8eb509856a73b20f73945becd9a87749fe89548364d31ecd7b3e705f5e3f42bfc26e8f9c7e
4
- metadata.gz: fbdae7cc3bff2600a7655198c1d8220009db57d54b0951b35dce7d30e4edc1bbf4a22bd4221c6432e58b989e46130ff2017e01a374e84ca92ab3258312201887
5
2
  SHA1:
6
- data.tar.gz: fc06b84167b3666201b9f7d78352b5e2daf08f90
7
- metadata.gz: 7a2e5544226f6040c035bc0313786b848652fb7b
3
+ data.tar.gz: 6663b44949ad00cfb53164de9cc616c6cf08003c
4
+ metadata.gz: d28529fec2edd9b8777ff9e76f13b911967b8d53
5
+ SHA512:
6
+ data.tar.gz: a0ebcf97535835ab90809366426e709a9498a86a79aee3552a02655df423fb918b2ed69fde2bb6d5c2e427912c6f9c4846980e5fce257a0b20ab13e02b5d26da
7
+ metadata.gz: 9243d172905732d62f823acbca185986f1b3cc4daa4a6a100503854d60af6fad2c8d475171b936d579f9ba5112b7f46ac829aaded6eda2e0fa4733f1ffe5ff1a
data/README.md CHANGED
@@ -1,24 +1,32 @@
1
1
  # Vagrant::Hostsupdater
2
2
 
3
- TODO: Write a gem description
3
+ This plugin adds an entry to your /etc/hosts file on the host system.
4
4
 
5
- ## Installation
5
+ On **up** and **reload** commands, it tries to add the information, if its not already existant in your hosts file. If it needs to be added, you will be asked for an administrator password, since it uses sudo to edit the file.
6
6
 
7
- Add this line to your application's Gemfile:
7
+ On **halt**, **suspend** and **destroy**, those entries will be removed again.
8
8
 
9
- gem 'vagrant-hostsupdater'
9
+ ## Versions
10
+ ### 0.0.3
11
+ * added aliases config option to define additional hostnames
10
12
 
11
- And then execute:
13
+ ## Installation
12
14
 
13
- $ bundle
15
+ $ vagrant plugin install vagrant-hostsupdater
14
16
 
15
- Or install it yourself as:
17
+ Uninstall it with:
16
18
 
17
- $ gem install vagrant-hostsupdater
19
+ $ vagrant plugin uninstall vagrant-hostsupdater
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ At the moment, the only things you need, are the hostname and a :private_network network with a fixed ip.
24
+
25
+ $ config.vm.network :private_network, ip: "192.168.3.10"
26
+ $ config.vm.hostname = "www.testing.de"
27
+ $ config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
28
+
29
+ This ip and the hostname will be used for the entry in the /etc/hosts file.
22
30
 
23
31
  ## Contributing
24
32
 
@@ -17,6 +17,9 @@ module VagrantPlugins
17
17
 
18
18
  def getHostnames
19
19
  hostnames = Array(@machine.config.vm.hostname)
20
+ if @machine.config.hostsupdater.aliases
21
+ hostnames.concat(@machine.config.hostsupdater.aliases)
22
+ end
20
23
  return hostnames
21
24
  end
22
25
 
@@ -29,10 +32,12 @@ module VagrantPlugins
29
32
  name = @machine.name
30
33
  entries = []
31
34
  ips.each do |ip|
32
- hostEntry = host_entry(ip, hostnames, name, uuid)
33
- escapedEntry = Regexp.quote(hostEntry)
34
- if !hostsContents.match(/#{escapedEntry}/)
35
- entries.push(hostEntry)
35
+ hostEntries = getHostEntries(ip, hostnames, name, uuid)
36
+ hostEntries.each do |hostEntry|
37
+ escapedEntry = Regexp.quote(hostEntry)
38
+ if !hostsContents.match(/#{escapedEntry}/)
39
+ entries.push(hostEntry)
40
+ end
36
41
  end
37
42
  end
38
43
  sudo(addToHosts(entries))
@@ -57,6 +62,14 @@ module VagrantPlugins
57
62
  %Q(#{ip} #{hostnames.join(' ')} #{signature(name, uuid)})
58
63
  end
59
64
 
65
+ def getHostEntries(ip, hostnames, name, uuid = self.uuid)
66
+ entries = []
67
+ hostnames.each do |hostname|
68
+ entries.push(%Q(#{ip} #{hostname} #{signature(name, uuid)}))
69
+ end
70
+ return entries
71
+ end
72
+
60
73
  def addToHosts(entries)
61
74
  return if entries.length == 0
62
75
  hosts_path = '/etc/hosts'
@@ -3,9 +3,7 @@ require "vagrant"
3
3
  module VagrantPlugins
4
4
  module HostsUpdater
5
5
  class Config < Vagrant.plugin("2", :config)
6
-
7
-
8
-
6
+ attr_accessor :aliases
9
7
  end
10
8
  end
11
9
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module HostsUpdater
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-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
  - "Falk Ku\xCC\x88hnel"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-04-30 00:00:00 Z
12
+ date: 2013-05-01 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false