web_server_uid 1.0.1 → 1.0.2

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
- SHA1:
3
- metadata.gz: 1a8a676540be4df67822b2ca72623dde3800bb4c
4
- data.tar.gz: cb182fae67d7d1cea39040248e800e4b2b744526
5
2
  SHA512:
6
- metadata.gz: 5385c0ce03a88ae0a4fd2f91b314e1a4fb1a86d736ef51cf0c5c1f2fae90f62e86d1e2142f423de470ea24664dd3ea30b5ecad9fb6a3e3f1eb231d5b68d0192e
7
- data.tar.gz: 34ef20fb44cd5c59c8bbc75a0a2051ff50ea48a18414276df71d768a369af9fa85b230a53c62fecce13fb30531168c7ccbbeebf05b82e3452555c00fa9f437ad
3
+ metadata.gz: e8f5f29b829da6ef41b7789a931278e878f77bdaf1c64370433f7f7de75ded726a6f62a5bd8a9fc2e97ed7f8ab960992f689343b548dc76ae48b39fcfb0800ea
4
+ data.tar.gz: 77db7d257dad40b4bcb15fcc7e33b2b0a632ac1ae8661f045b277e80c3907a496ef4e019adad6299283893185781a8436104594aa0cacbb4a894c501feeba839
5
+ SHA1:
6
+ metadata.gz: 9cf12083ce04c9ae62ed0a0da13f78b70aabd706
7
+ data.tar.gz: 7f1ab1260023026d0102c8a771d49207d02842b5
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ### Version 1.0.2, 2014-02-27
2
+
3
+ * Fix issue where WebServerUid#generate would fail if the network was unreachable; now we just fall back to
4
+ `127.0.0.1`. (Guess where I'm writing this from?)
5
+
6
+ ### Version 1.0.1, 2014-02-18
7
+
8
+ * Make `#to_s` and `#inspect` work reasonably, to make debugging a whole lot easier.
9
+
10
+ ### Version 1.0.0, 2014-02-14
11
+
12
+ Initial release.
data/README.md CHANGED
@@ -66,6 +66,8 @@ particularly dependent on exact Ruby versions, and should be compatible with a b
66
66
 
67
67
  Current build status: ![Current Build Status](https://api.travis-ci.org/swiftype/web_server_uid.png?branch=master)
68
68
 
69
+ Brought to you by the folks at [Swiftype](https://www.swiftype.com). First version written by [Andrew Geweke](https://www.github.com/ageweke).
70
+
69
71
  ## Installation
70
72
 
71
73
  Add this line to your application's Gemfile:
@@ -123,12 +123,17 @@ class WebServerUid
123
123
  #
124
124
  # Note that this could be an IPv6 address. This works properly; we grab the four LSB, above.
125
125
  #
126
+ # We fall back to 127.0.0.1 if we get Errno::ENETUNREACH -- for example, if the network is offline. (Guess where
127
+ # I'm writing this comment from?)
128
+ #
126
129
  # (Much credit to http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/.)
127
130
  def find_local_ip_address
128
131
  @local_ip_address ||= begin
129
132
  require 'socket'
130
133
  ipaddr_string = UDPSocket.open {|s| s.connect('8.8.8.8', 1); s.addr.last }
131
134
  IPAddr.new(ipaddr_string)
135
+ rescue Errno::ENETUNREACH => unreachable
136
+ IPAddr.new("127.0.0.1")
132
137
  end
133
138
  end
134
139
  end
@@ -1,3 +1,3 @@
1
1
  class WebServerUid
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -22,6 +22,13 @@ describe WebServerUid do
22
22
  end
23
23
  end
24
24
 
25
+ it "should fall back to 127.0.0.1 if the network is unreachable (like if you're offline)" do
26
+ pending "We can't successfully test this right now; the expectation below works, but then persists into other examples, breaking them :("
27
+ expect(UDPSocket).to receive(:open).with().and_raise(Errno::ENETUNREACH)
28
+ generated = WebServerUid.generate
29
+ expect(generated.service_number_as_ip).to eq(IPAddr.new("127.0.0.1"))
30
+ end
31
+
25
32
  describe "generating a brand-new instance" do
26
33
  before :each do
27
34
  @generated = WebServerUid.generate
@@ -36,9 +43,13 @@ describe WebServerUid do
36
43
  end
37
44
 
38
45
  it "should have the right IP" do
39
- require 'socket'
40
- expected_ipaddr_string = UDPSocket.open {|s| s.connect('8.8.8.8', 1); s.addr.last }
41
- expected_ipaddr = IPAddr.new(expected_ipaddr_string)
46
+ begin
47
+ require 'socket'
48
+ expected_ipaddr_string = UDPSocket.open {|s| s.connect('8.8.8.8', 1); s.addr.last }
49
+ expected_ipaddr = IPAddr.new(expected_ipaddr_string)
50
+ rescue Errno::ENETUNREACH => unreachable
51
+ expected_ipaddr = IPAddr.new("127.0.0.1")
52
+ end
42
53
 
43
54
  expect(@generated.service_number_as_ip).to eq(expected_ipaddr)
44
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_server_uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Geweke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-02-18 00:00:00 Z
12
+ date: 2014-02-27 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -54,6 +54,7 @@ extra_rdoc_files: []
54
54
  files:
55
55
  - .gitignore
56
56
  - .travis.yml
57
+ - CHANGELOG.md
57
58
  - Gemfile
58
59
  - LICENSE.txt
59
60
  - README.md