vagrant-hostsupdater 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: 01d5aa0f13ab1d213adbff522d9cc6825492c0d3
4
- data.tar.gz: c7d0971e65e54de6cad8022c127645b1a93c632d
3
+ metadata.gz: 092e9d19e52604448eef2935325883f9f9a1406d
4
+ data.tar.gz: df0ef378226ef4c9bdb7194546f0a8dee36aad0d
5
5
  SHA512:
6
- metadata.gz: 373c154650de651c9fde2dcfec57ee154210b99af767aac96ae7994788db2766e20b14a31b3ac1842adf65d568d7ccf28e1c8d706bcda47f39bfeb5e9ab35569
7
- data.tar.gz: bf16bbf73b6971e1c557ff475140e0357db372e1c88a21769d9d792089b23c7fc6d82164b4d9a42ccbed349862d2d37a5366d6c7420439e0013774f1f8a8a456
6
+ metadata.gz: 5403a44f9eb9389019bcfbf947b0df3a1b64abc0de2b6f7fe8f6abdfbfa2d5b0896cb1c11287b26a5baec29ce1b0e70085865abbe04c285d09fccfa47701ec45
7
+ data.tar.gz: fc3bf266de0209b090151fa7dcfa56a7339da8e5e6a101fa8239d10ae667e0670f1266683604df1a1d2bf49415a5f26fd315ba7b08d9d8ea7f79854afa08c4c7
data/README.md CHANGED
@@ -11,6 +11,10 @@ By setting the remove\_on\_suspend option, you can have them removed on **suspen
11
11
 
12
12
  ## Versions
13
13
 
14
+ ### 0.0.7
15
+ * using hashed uids now to identify hosts entries (you might need to remove previous hostentries manually)
16
+ * fixed removing of host entries
17
+
14
18
  ### 0.0.6
15
19
  * no sudo, if /etc/hosts is writeable
16
20
 
@@ -56,17 +56,9 @@ module VagrantPlugins
56
56
  file = File.open("/etc/hosts", "rb")
57
57
  hostsContents = file.read
58
58
  uuid = @machine.id
59
- escapedId = Regexp.quote(uuid)
60
- puts "#{uuid}"
61
- puts "#{escapedId}"
62
- if hostsContents.match(/#{escapedId}/)
63
- puts "removing uids"
64
- puts "#{removeFromHosts}"
65
- if !File.writable?("/etc/hosts")
66
- sudo(removeFromHosts)
67
- else
68
- removeFromHosts
69
- end
59
+ hashedId = Digest::MD5.hexdigest(uuid)
60
+ if hostsContents.match(/#{hashedId}/)
61
+ removeFromHosts
70
62
  end
71
63
  end
72
64
 
@@ -92,13 +84,22 @@ module VagrantPlugins
92
84
  def removeFromHosts(options = {})
93
85
  hosts_path = '/etc/hosts'
94
86
  uuid = @machine.id
95
- %Q(sed -e '/#{uuid}/ d' -n #{hosts_path})
87
+ hashedId = Digest::MD5.hexdigest(uuid)
88
+ if !File.writable?("/etc/hosts")
89
+ sudo(%Q(sed -i -e '/#{hashedId}/ d' #{hosts_path}))
90
+ else
91
+ output = `sed -e "/#{hashedId}/ d" #{hosts_path}`
92
+ hostsFile = File.open(hosts_path, "w")
93
+ hostsFile.write(output)
94
+ hostsFile.close()
95
+ end
96
96
  end
97
97
 
98
98
 
99
99
 
100
100
  def signature(name, uuid = self.uuid)
101
- %Q(# VAGRANT: #{uuid} (#{name}))
101
+ hashedId = Digest::MD5.hexdigest(uuid)
102
+ %Q(# VAGRANT: #{hashedId} (#{name}) / #{uuid})
102
103
  end
103
104
 
104
105
  def sudo(command)
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module HostsUpdater
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Falk K\xC3\xBChnel"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-06-10 00:00:00 Z
12
+ date: 2013-06-18 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false