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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22db4fda8e23d989ad1c6aaf1597f6a5e9675aa4
4
- data.tar.gz: 527f73d5200a67c927ffa288578cd65e0d01c050
3
+ metadata.gz: 7b834934e1e6464dff4bed92852f583042b35431
4
+ data.tar.gz: 0bd6fab1ad72007220577e477c42bbba6ddcc7ec
5
5
  SHA512:
6
- metadata.gz: c6657496ca8bc1e67a8266e28a3a655bf49e265ab9f5956696d0fb4663e339bb790def23f759e480498f71495cfb50abcc4a7009ed1241f99e3fd2d7f47d3bfa
7
- data.tar.gz: 4b9b1cca197f5832e44a66054240d83c97d552c29afd17645ae504f9f4e7c9a138414fef9b4e12f4e60548e2c058f60f35f44425f2aed49d1d68fb18617bae4b
6
+ metadata.gz: ac3ad9dc7199a0803698f64cc0e63c41585351ddc051aed35cfdfed3ea8a37a7725ec30eed752309fa6b2b058f2813f7ff9e87dbe3ecaa0dbd13fc53b0f84361
7
+ data.tar.gz: 8983a8199bb1e4649dd2e9027fd80444ffcee72ed348fb470a188ce26102a46182455afc5a77ba7bc0833c78b704b5a4dca07bee0afeebe1da0f273b440d7e29
@@ -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 IPAddr::InvalidAddressError
93
+ rescue @invalid_address_error => e
88
94
  # ignore
89
95
  end
90
96
  return name if is_address
@@ -1,5 +1,5 @@
1
1
  module Resolve
2
2
  class Hostname
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -26,12 +26,27 @@ describe Resolve::Hostname do
26
26
  end
27
27
 
28
28
  context 'with invalid IPv4 address' do
29
- it 'returns false' do
30
- expect{ r.primary_version_address?('256.256.256.256') }.to raise_error(IPAddr::InvalidAddressError)
31
- expect{ r.primary_version_address?('256.256.256.0') }.to raise_error(IPAddr::InvalidAddressError)
32
- expect{ r.primary_version_address?('256.256.0.0') }.to raise_error(IPAddr::InvalidAddressError)
33
- expect{ r.primary_version_address?('256.0.0.0') }.to raise_error(IPAddr::InvalidAddressError)
34
- expect{ r.primary_version_address?('0.0.0.0') }.not_to raise_error()
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.3
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-12 00:00:00.000000000 Z
11
+ date: 2013-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler