whois 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,13 @@
1
1
  = Changelog
2
2
 
3
3
 
4
+ == Release 0.5.3
5
+
6
+ FIXED: self.valid_ipv6?(addr) references valid_v4? instead of valid_ipv4? (closes #300)
7
+
8
+ FIXED: In some rare circumstances the server guessing fails to return the right server but returns an other server instead (closes #260).
9
+
10
+
4
11
  == Release 0.5.2
5
12
 
6
13
  * ADDED: Whois::Client.new now accepts a block and yields self.
@@ -175,7 +175,7 @@ module Whois
175
175
 
176
176
  def self.find_for_tld(qstring)
177
177
  definitions(:tld).each do |definition|
178
- return factory(:tld, *definition) if /#{definition.first}$/ =~ qstring
178
+ return factory(:tld, *definition) if /#{Regexp.escape(definition.first)}$/ =~ qstring
179
179
  end
180
180
  nil
181
181
  end
@@ -193,9 +193,9 @@ module Whois
193
193
  return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr
194
194
  return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr
195
195
  # IPv6 (IPv4 compat)
196
- return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:/ =~ addr && valid_v4?($')
197
- return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($')
198
- return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($')
196
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:/ =~ addr && valid_ipv4?($')
197
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_ipv4?($')
198
+ return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_ipv4?($')
199
199
  false
200
200
  end
201
201
 
@@ -19,7 +19,7 @@ module Whois
19
19
  module Version
20
20
  MAJOR = 0
21
21
  MINOR = 5
22
- TINY = 2
22
+ TINY = 3
23
23
 
24
24
  STRING = [MAJOR, MINOR, TINY].join('.')
25
25
  end
@@ -1,57 +1,99 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ServerTest < Test::Unit::TestCase
4
- include Whois
4
+
5
+ def setup
6
+ Whois::Server.class_eval { class_variable_set("@@definitions", { :tld => [], :ipv4 =>[], :ipv6 => [] }) }
7
+ end
8
+
5
9
 
6
10
  def test_guess_should_recognize_email
7
- Server.expects(:find_for_email).with("email@example.org").returns(true)
8
- assert Server.guess("email@example.org")
11
+ Whois::Server.expects(:find_for_email).with("email@example.org").returns(true)
12
+ assert Whois::Server.guess("email@example.org")
9
13
  end
10
14
 
11
15
  def test_guess_should_recognize_tld
12
- Server.expects(:find_for_tld).with("google.com").returns(true)
13
- assert Server.guess("google.com")
16
+ Whois::Server.expects(:find_for_tld).with("google.com").returns(true)
17
+ assert Whois::Server.guess("google.com")
18
+ end
19
+
20
+ def test_guess_should_recognize_ipv4
21
+ Whois::Server.expects(:find_for_ipv4).with("192.168.1.1").returns(true)
22
+ assert Whois::Server.guess("192.168.1.1")
23
+ end
24
+
25
+ def test_guess_should_recognize_ipv6
26
+ Whois::Server.expects(:find_for_ipv6).with("2001:0db8:85a3:0000:0000:8a2e:0370:7334").returns(true)
27
+ assert Whois::Server.guess("2001:0db8:85a3:0000:0000:8a2e:0370:7334")
28
+ end
29
+
30
+ def test_guess_should_recognize_ipv6_with_zeros_group
31
+ Whois::Server.expects(:find_for_ipv6).with("2002::1").returns(true)
32
+ assert Whois::Server.guess("2002::1")
14
33
  end
15
34
 
16
35
  def test_guess_should_raise_servernotfound_with_unrecognized_query
17
- assert_raise(ServerNotFound){ Server.guess("xyz") }
36
+ assert_raise(Whois::ServerNotFound){ Whois::Server.guess("xyz") }
37
+ end
38
+
39
+
40
+ def test_find_for_tld_should_not_consider_dot_as_regexp_instruction
41
+ Whois::Server.define(:tld, ".no.com", "whois.no.com")
42
+ Whois::Server.define(:tld, ".com", "whois.com")
43
+ assert_equal "whois.com", Whois::Server.guess("antoniocangiano.com").host
44
+ end
45
+
46
+ def test_find_for_ipv6_should_factory_ipv6_with_ipv4_compatibility
47
+ Whois::Server.define(:ipv6, "::192.168.1.1", "whois.foo")
48
+ Whois::Server.expects(:factory).with(:ipv6, any_parameters).returns(true)
49
+ assert Whois::Server.guess("::192.168.1.1")
18
50
  end
19
51
 
20
52
 
21
53
  def test_definitions
22
- assert_instance_of Hash, Server.definitions
54
+ assert_instance_of Hash, Whois::Server.definitions
23
55
  end
24
56
 
25
57
  def test_definitions_with_key
26
- assert_equal nil, Server.definitions(:foo)
27
- Server.define(:foo, ".foo", "whois.foo")
28
- assert_equal [[".foo", "whois.foo", {}]], Server.definitions(:foo)
58
+ assert_equal nil, Whois::Server.definitions(:foo)
59
+ Whois::Server.define(:foo, ".foo", "whois.foo")
60
+ assert_equal [[".foo", "whois.foo", {}]], Whois::Server.definitions(:foo)
29
61
  end
30
62
 
31
63
 
32
64
  def test_define_tld
33
- Server.define(:tld, ".foo", "whois.foo")
34
- assert_equal [".foo", "whois.foo", {}], Server.definitions[:tld].last
65
+ Whois::Server.define(:tld, ".foo", "whois.foo")
66
+ assert_equal [".foo", "whois.foo", {}], Whois::Server.definitions[:tld].last
35
67
  end
36
68
 
37
69
  def test_define_tld_with_options
38
- Server.define(:tld, ".foo", "whois.foo", :foo => "bar")
39
- assert_equal [".foo", "whois.foo", { :foo => "bar" }], Server.definitions[:tld].last
70
+ Whois::Server.define(:tld, ".foo", "whois.foo", :foo => "bar")
71
+ assert_equal [".foo", "whois.foo", { :foo => "bar" }], Whois::Server.definitions[:tld].last
72
+ end
73
+
74
+ def test_define_ipv4
75
+ Whois::Server.define(:ipv4, ".foo", "whois.foo")
76
+ assert_equal [".foo", "whois.foo", {}], Whois::Server.definitions[:ipv4].last
77
+ end
78
+
79
+ def test_define_ipv4_with_options
80
+ Whois::Server.define(:ipv4, ".foo", "whois.foo", :foo => "bar")
81
+ assert_equal [".foo", "whois.foo", { :foo => "bar" }], Whois::Server.definitions[:ipv4].last
40
82
  end
41
83
 
42
84
 
43
85
  def test_factory
44
- server = Server.factory(:tld, ".foo", "whois.foo")
45
- assert_instance_of Server::Adapters::Standard, server
86
+ server = Whois::Server.factory(:tld, ".foo", "whois.foo")
87
+ assert_instance_of Whois::Server::Adapters::Standard, server
46
88
  end
47
89
 
48
90
  def test_factory_with_adapter
49
- server = Server.factory(:tld, ".foo", "whois.foo", :adapter => Server::Adapters::None)
50
- assert_instance_of Server::Adapters::None, server
91
+ server = Whois::Server.factory(:tld, ".foo", "whois.foo", :adapter => Whois::Server::Adapters::None)
92
+ assert_instance_of Whois::Server::Adapters::None, server
51
93
  end
52
94
 
53
95
  def test_factory_with_adapter_should_delete_adapter_option
54
- server = Server.factory(:tld, ".foo", "whois.foo", :adapter => Server::Adapters::None, :foo => "bar")
96
+ server = Whois::Server.factory(:tld, ".foo", "whois.foo", :adapter => Whois::Server::Adapters::None, :foo => "bar")
55
97
  assert_equal server.options, { :foo => "bar" }
56
98
  end
57
99
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{whois}
5
- s.version = "0.5.2"
5
+ s.version = "0.5.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simone Carletti"]
9
- s.date = %q{2009-08-20}
9
+ s.date = %q{2009-09-18}
10
10
  s.default_executable = %q{ruby-whois}
11
11
  s.description = %q{ Whois is an intelligent WHOIS client written in pure Ruby. It enables you to query registry data for ipv4, ipv6 and top level domains.
12
12
  }
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Whois", "--main", "README.rdoc"]
19
19
  s.require_paths = ["lib"]
20
20
  s.rubyforge_project = %q{whois}
21
- s.rubygems_version = %q{1.3.5}
21
+ s.rubygems_version = %q{1.3.4}
22
22
  s.summary = %q{An intelligent pure Ruby WHOIS client.}
23
23
  s.test_files = ["test/adapters/afilias_test.rb", "test/adapters/none_test.rb", "test/adapters/not_implemented_test.rb", "test/adapters/pir_test.rb", "test/adapters/standard_test.rb", "test/adapters/verisign_test.rb", "test/adapters/web_test.rb", "test/client_test.rb", "test/deprecated_test.rb", "test/server_test.rb", "test/test_helper.rb", "test/whois_test.rb"]
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whois
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-20 00:00:00 +02:00
12
+ date: 2009-09-18 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  requirements: []
162
162
 
163
163
  rubyforge_project: whois
164
- rubygems_version: 1.3.5
164
+ rubygems_version: 1.3.4
165
165
  signing_key:
166
166
  specification_version: 3
167
167
  summary: An intelligent pure Ruby WHOIS client.