maphosts 1.0 → 1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/maphosts/host_manager.rb +10 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13b54a0cbab8bf845ef76c02d32576d710f574d3
4
- data.tar.gz: 5bff0397570b797916fe8637f20e8838258a6f57
3
+ metadata.gz: cbadb93ab581c3b339ae2b71d692f9e5bdae6fa7
4
+ data.tar.gz: 9a87667fbb0ec23b24d32fa750a6da564dbc6f04
5
5
  SHA512:
6
- metadata.gz: 6ebd7964fdbf05ed9cc0456cf63cbde04e460b8748f2e34be3dc73f71f5976eb72afd08719a852c8d09e2824b3e226e2448bac3fff376990cca5edc7272795b0
7
- data.tar.gz: da9c01c59f23f0609f0227c0d0e3c09e4abc392736677e6e85a76a3bbaab69d54b8d322b3f3b396faa5a69983f7515a44fe88dfe03df928cb11bdbff0d057a3c
6
+ metadata.gz: 162aae6901dc1be99fe2240412930b66cb6efd074ed330511043b062d911752b54aa33f5b44c815c420e2dcd28b3042a768d46226ba8653503558a107e789e46
7
+ data.tar.gz: 6a1b960cb1829f23bfcb3597ae14a587fe6faa15fa73b18f91f74d19e346e45cfc9a7a7acaf89091aedad82497abfff6ee8f4bc80ec8976350903926ceb65817
@@ -36,7 +36,16 @@ class HostManager
36
36
  if !@dirty
37
37
  nil
38
38
  else
39
- @hostsfile.to_s.strip!
39
+ # Strip whitespace at end of file
40
+ if !@hostsfile.elements.last.nil? && @hostsfile.elements.last.kind_of?(Hosts::EmptyElement)
41
+ @hostsfile.elements.delete @hostsfile.elements.last
42
+ end
43
+
44
+ if @hostsfile.to_s.empty?
45
+ raise "The patched hostsfile is empty. This is most likely due to a bug. No worry, the file has not been written."
46
+ end
47
+
48
+ @hostsfile
40
49
  end
41
50
  end
42
51
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maphosts
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Scholten