resolve-hostname 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resolve/hostname.rb +7 -1
- data/lib/resolve/hostname/version.rb +1 -1
- data/spec/resolve_hostname_spec.rb +21 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b834934e1e6464dff4bed92852f583042b35431
|
4
|
+
data.tar.gz: 0bd6fab1ad72007220577e477c42bbba6ddcc7ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac3ad9dc7199a0803698f64cc0e63c41585351ddc051aed35cfdfed3ea8a37a7725ec30eed752309fa6b2b058f2813f7ff9e87dbe3ecaa0dbd13fc53b0f84361
|
7
|
+
data.tar.gz: 8983a8199bb1e4649dd2e9027fd80444ffcee72ed348fb470a188ce26102a46182455afc5a77ba7bc0833c78b704b5a4dca07bee0afeebe1da0f273b440d7e29
|
data/lib/resolve/hostname.rb
CHANGED
@@ -50,6 +50,12 @@ module Resolve
|
|
50
50
|
|
51
51
|
@resolver = nil
|
52
52
|
@resolver_expires = nil
|
53
|
+
|
54
|
+
@invalid_address_error = if IPAddr.const_defined?('InvalidAddressError')
|
55
|
+
IPAddr::InvalidAddressError
|
56
|
+
else
|
57
|
+
ArgumentError
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
def getaddress(name)
|
@@ -84,7 +90,7 @@ module Resolve
|
|
84
90
|
begin
|
85
91
|
IPAddr.new(name)
|
86
92
|
is_address = true
|
87
|
-
rescue
|
93
|
+
rescue @invalid_address_error => e
|
88
94
|
# ignore
|
89
95
|
end
|
90
96
|
return name if is_address
|
@@ -26,12 +26,27 @@ describe Resolve::Hostname do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'with invalid IPv4 address' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
context 'in ruby 2.0.0 or later' do
|
30
|
+
if IPAddr.const_defined?('InvalidAddressError')
|
31
|
+
it 'raises IPAddr::InvalidAddressError' do
|
32
|
+
expect{ r.primary_version_address?('256.256.256.256') }.to raise_error(IPAddr::InvalidAddressError)
|
33
|
+
expect{ r.primary_version_address?('256.256.256.0') }.to raise_error(IPAddr::InvalidAddressError)
|
34
|
+
expect{ r.primary_version_address?('256.256.0.0') }.to raise_error(IPAddr::InvalidAddressError)
|
35
|
+
expect{ r.primary_version_address?('256.0.0.0') }.to raise_error(IPAddr::InvalidAddressError)
|
36
|
+
expect{ r.primary_version_address?('0.0.0.0') }.not_to raise_error()
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context 'in ruby 1.9.3 or earlier' do
|
41
|
+
unless IPAddr.const_defined?('InvalidAddressError')
|
42
|
+
it 'raises ArgumentError' do
|
43
|
+
expect{ r.primary_version_address?('256.256.256.256') }.to raise_error(ArgumentError)
|
44
|
+
expect{ r.primary_version_address?('256.256.256.0') }.to raise_error(ArgumentError)
|
45
|
+
expect{ r.primary_version_address?('256.256.0.0') }.to raise_error(ArgumentError)
|
46
|
+
expect{ r.primary_version_address?('256.0.0.0') }.to raise_error(ArgumentError)
|
47
|
+
expect{ r.primary_version_address?('0.0.0.0') }.not_to raise_error()
|
48
|
+
end
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resolve-hostname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|