jm81-whois 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +6 -3
- data/Rakefile +2 -22
- data/lib/whois/domain/base.rb +35 -35
- data/lib/whois/domain/gov.rb +1 -1
- data/lib/whois/domain/int.rb +4 -4
- data/lib/whois/domain/jobs.rb +12 -0
- data/lib/whois/domain/museum.rb +2 -2
- data/lib/whois/domain/name.rb +3 -3
- data/lib/whois/domain/pro.rb +4 -4
- data/lib/whois/domain/public_interest.rb +6 -4
- data/lib/whois/domain/verisign_grs.rb +16 -8
- data/lib/whois/version.rb +1 -1
- metadata +29 -86
- data/.gitignore +0 -10
- data/LICENSE +0 -1020
- data/jm81-whois.gemspec +0 -102
- data/test/test_helper.rb +0 -59
- data/test/whois/domain/aero_test.rb +0 -24
- data/test/whois/domain/afilias_test.rb +0 -24
- data/test/whois/domain/cat_test.rb +0 -28
- data/test/whois/domain/coop_test.rb +0 -28
- data/test/whois/domain/educause_test.rb +0 -24
- data/test/whois/domain/gov_test.rb +0 -28
- data/test/whois/domain/int_test.rb +0 -24
- data/test/whois/domain/mobi_test.rb +0 -24
- data/test/whois/domain/museum_test.rb +0 -28
- data/test/whois/domain/name_test.rb +0 -24
- data/test/whois/domain/neustar_test.rb +0 -135
- data/test/whois/domain/pro_test.rb +0 -27
- data/test/whois/domain/public_interest_test.rb +0 -88
- data/test/whois/domain/verisign_grs_test.rb +0 -90
- data/test/whois/domain/ws_test.rb +0 -24
- data/test/whois/domain_test.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWQxOGEyMzFkYzIzNzUzNDUxOTllZGMxMTg5M2MwNWU4NWRiMTI5MQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTcxZWE4ZjAwOTYwNjI0NjcxMDI3ODAzM2M2ODRmZGI5MjhiOTg5OA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTRiZjNhOWNmNDY4ZTk3YjE2YTA3MDZkMzYyMDhlYTUxZTQ2MTExYWIzYTBj
|
10
|
+
Y2U0YjM4YjQ3ZTdmMDRkMDcxZjM4ZTI1ZDc2Mjc2ZDMyNTg3ZmQwMmYwZTk1
|
11
|
+
ZDQwMDFhNTZhYTNmMzE3NmEyNTAzMTA4NjJiMDgyMjc4Y2EwOTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjBhNWM0ODEyZThkY2Q3N2IxZmQ5NTdmMDJmOGY5NDZhMmIyYWJlYjA3N2Ew
|
14
|
+
YTdhOGRjMjZmNzE4NzcwNGE4ZTBhYmUxZTYxMDdhNjVkNzU2NjEwZjA2NDA0
|
15
|
+
NzM5NTNlNjI2NDhhZjcxYmRmNmYyMDEzZTE4ODc1YzlhN2Y3NGM=
|
data/README.md
CHANGED
@@ -9,6 +9,9 @@ sudo gem install jm81-whois
|
|
9
9
|
|
10
10
|
##Example
|
11
11
|
|
12
|
+
require 'whois'
|
13
|
+
domain = Whois::Domain.new('example.com')
|
14
|
+
|
12
15
|
domain.name #=> "example.com"
|
13
16
|
domain.expires_on #=> 2011-08-13 <Date>
|
14
17
|
domain.created_on #=> 1995-08-14 <Date>
|
@@ -27,11 +30,11 @@ sudo gem install jm81-whois
|
|
27
30
|
domain.to_s # Key value pairs of anything that looks like an attribute.
|
28
31
|
# Especially useful for non-API information, such as registrant
|
29
32
|
# data.
|
30
|
-
|
33
|
+
|
31
34
|
##Code layout
|
32
35
|
|
33
36
|
Since pretty much every TLD has a different whois format, the various classes
|
34
|
-
(which inherit from Domain::Base) in the Domain module (files in domain folder)
|
37
|
+
(which inherit from Domain::Base) in the Domain module (files in domain folder)
|
35
38
|
have the following:
|
36
39
|
|
37
40
|
- HOST constant: the host name of the whois server
|
@@ -50,7 +53,7 @@ insufficient (particular likely for lists of values, such as *status* and
|
|
50
53
|
|
51
54
|
##Note on Tests
|
52
55
|
|
53
|
-
Tests are against actual whois data and thus are somewhat brittle, especially
|
56
|
+
Tests are against actual whois data and thus are somewhat brittle, especially
|
54
57
|
*expires_at* and *updated_at*.
|
55
58
|
|
56
59
|
##TODO
|
data/Rakefile
CHANGED
@@ -1,29 +1,9 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require '
|
3
|
+
require 'rdoc/task'
|
4
4
|
require 'rubygems'
|
5
5
|
require File.join(File.dirname(__FILE__), 'lib', 'whois', 'version')
|
6
6
|
|
7
|
-
begin
|
8
|
-
require 'jeweler'
|
9
|
-
Jeweler::Tasks.new do |gem|
|
10
|
-
gem.name = "jm81-whois"
|
11
|
-
gem.version = Whois::VERSION.dup
|
12
|
-
gem.summary = %Q{Ruby library for accessing Whois information}
|
13
|
-
gem.description = <<EOF
|
14
|
-
This library presents whois information for domains in a variety of TLD's
|
15
|
-
through a standardized API.
|
16
|
-
EOF
|
17
|
-
gem.email = "jmorgan@morgancreative.net"
|
18
|
-
gem.homepage = "http://github.com/jm81/whois"
|
19
|
-
gem.authors = ["Jared Morgan"]
|
20
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
-
end
|
22
|
-
Jeweler::GemcutterTasks.new
|
23
|
-
rescue LoadError
|
24
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
25
|
-
end
|
26
|
-
|
27
7
|
desc 'Default: run unit tests.'
|
28
8
|
task :default => :test
|
29
9
|
|
@@ -40,7 +20,7 @@ Rake::RDocTask.new do |rdoc|
|
|
40
20
|
else
|
41
21
|
version = ""
|
42
22
|
end
|
43
|
-
|
23
|
+
|
44
24
|
rdoc.rdoc_dir = 'rdoc'
|
45
25
|
rdoc.title = 'Whois #{version}'
|
46
26
|
rdoc.options << '--line-numbers' << '--inline-source'
|
data/lib/whois/domain/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Whois::Domain::Base
|
2
2
|
attr_reader :name, :raw
|
3
|
-
|
3
|
+
|
4
4
|
# Default keys for pairs in raw whois data.
|
5
5
|
# :method_name => 'Default Key Text'
|
6
6
|
ATTR_NAMES = {
|
@@ -14,7 +14,7 @@ class Whois::Domain::Base
|
|
14
14
|
:registrant_id => "Registrant",
|
15
15
|
:administrative_id => "Administrative"
|
16
16
|
}
|
17
|
-
|
17
|
+
|
18
18
|
# Inherited classes call class method +responds_to+ to say for which TLDs
|
19
19
|
# that class is responsible.
|
20
20
|
#
|
@@ -23,7 +23,7 @@ class Whois::Domain::Base
|
|
23
23
|
def self.responds_to(*ary)
|
24
24
|
Whois::Domain::tlds[self.name.split(":").last] = ary
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Initialize and run query for the given domain.
|
28
28
|
#
|
29
29
|
# ==== Parameters
|
@@ -32,29 +32,29 @@ class Whois::Domain::Base
|
|
32
32
|
@name = name
|
33
33
|
query
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
# retun HOST constant for the running class
|
37
37
|
def host
|
38
38
|
self.class::HOST
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# A merge of the ATTR_NAMES for the running class and the Base class. This
|
42
|
-
# allows child classes to only define keys that are different from the
|
42
|
+
# allows child classes to only define keys that are different from the
|
43
43
|
# default.
|
44
44
|
def attr_names
|
45
45
|
@attr_names ||= ATTR_NAMES.merge(self.class::ATTR_NAMES)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# The string to use in +query+. This is generally just the domain name
|
49
49
|
# followed by a new line, but some servers have a different format.
|
50
50
|
def query_string
|
51
51
|
"#{@name}\n"
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
# Query the whois server and return all lines in +@raw+. Called by initialize.
|
55
55
|
# Based on Michael Neumann's library.
|
56
56
|
def query
|
57
|
-
s =
|
57
|
+
s = TCPSocket.open(host, 43)
|
58
58
|
s.write(query_string)
|
59
59
|
@raw = s.gets(nil)
|
60
60
|
raise(Whois::LookupRestricted, @raw) if lookup_restricted?
|
@@ -66,10 +66,10 @@ class Whois::Domain::Base
|
|
66
66
|
# checking for this is server-specific.
|
67
67
|
def lookup_restricted?
|
68
68
|
false
|
69
|
-
end
|
70
|
-
|
69
|
+
end
|
70
|
+
|
71
71
|
private :attr_names, :query_string, :query
|
72
|
-
|
72
|
+
|
73
73
|
# Get Hash of attributes, by iterating through each line of +@raw+. If the
|
74
74
|
# line matches the class's ATTR_MATCH constant, it is added to the +@attrs+
|
75
75
|
# Hash. Each elements of +attrs+ is an Array, to allow for multiple lines
|
@@ -78,26 +78,26 @@ class Whois::Domain::Base
|
|
78
78
|
# based on Michael Neumann's library
|
79
79
|
def attrs
|
80
80
|
return @attrs if @attrs
|
81
|
-
|
81
|
+
|
82
82
|
@attrs = Hash.new { |hsh, key| hsh[key] = [] }
|
83
|
-
raw.
|
83
|
+
raw.each_line do |line|
|
84
84
|
m = self.class::ATTR_MATCH.match(line)
|
85
85
|
@attrs[m[1]] << m[2] if m
|
86
86
|
end
|
87
87
|
return @attrs
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
# Return attributes as newline separated key value pairs ("key: value")
|
91
91
|
def to_s
|
92
92
|
s = ""
|
93
|
-
raw.
|
93
|
+
raw.each_line do |line|
|
94
94
|
m = self.class::ATTR_MATCH.match(line)
|
95
95
|
s << "#{m[1]}: #{m[2]}\n" if m
|
96
96
|
end
|
97
97
|
s
|
98
98
|
end
|
99
|
-
|
100
|
-
# Return the value of an attribute as a single String or nil. This returns
|
99
|
+
|
100
|
+
# Return the value of an attribute as a single String or nil. This returns
|
101
101
|
# only the first element of the attribute value (see +attr_array+). It is
|
102
102
|
# preferred not to use this method directly.
|
103
103
|
#
|
@@ -106,7 +106,7 @@ class Whois::Domain::Base
|
|
106
106
|
def attr_single(attr_name)
|
107
107
|
attrs[attr_names[attr_name]] ? attrs[attr_names[attr_name]][0] : nil
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
# Return the value of an attribute converted to a Date object. This returns
|
111
111
|
# only the first element of the attribute value. It is
|
112
112
|
# preferred not to use this method directly.
|
@@ -114,20 +114,20 @@ class Whois::Domain::Base
|
|
114
114
|
# ==== Parameters
|
115
115
|
# attr_name<Symbol>:: Matches the method name
|
116
116
|
def attr_date(attr_name)
|
117
|
-
attrs[attr_names[attr_name]] ? Date.parse(attrs[attr_names[attr_name]][0]) : nil
|
117
|
+
attrs[attr_names[attr_name]][0] ? Date.parse(attrs[attr_names[attr_name]][0]) : nil
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
# Return all values of an attribute as an Array. It is
|
121
121
|
# preferred not to use this method directly.
|
122
122
|
#
|
123
123
|
# ==== Parameters
|
124
124
|
# attr_name<Symbol>:: Matches the method name
|
125
125
|
def attr_array(attr_name)
|
126
|
-
attrs[attr_names[attr_name]] || []
|
126
|
+
(attrs[attr_names[attr_name]] || []).select { |val| val && val != '' }
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
private :attr_single, :attr_date, :attr_array
|
130
|
-
|
130
|
+
|
131
131
|
# Return the whois_server used for getting details for this domain. For many
|
132
132
|
# TLD's, all data is served from the primary whois server. A few TLD's have
|
133
133
|
# details on separate servers. Return +host+ unless a whois_server is included
|
@@ -135,37 +135,37 @@ class Whois::Domain::Base
|
|
135
135
|
def whois_server
|
136
136
|
attr_single(:whois_server) || host
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# Name of this domain's Registrar
|
140
140
|
def registrar_name
|
141
141
|
attr_single(:registrar_name)
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
# Date of domain registration
|
145
145
|
def created_on
|
146
146
|
attr_date(:created_on)
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
# Last time the domain's whois information was updated (I think)
|
150
150
|
def updated_on
|
151
151
|
attr_date(:updated_on)
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
# Date domain's registration expires
|
155
155
|
def expires_on
|
156
156
|
attr_date(:expires_on)
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
# Array of status entries for domain
|
160
160
|
def status
|
161
161
|
attr_array(:status)
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
# Array of name servers for domain
|
165
165
|
def name_servers
|
166
166
|
attr_array(:name_servers)
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
# ID of this domain's Registrant
|
170
170
|
def registrant_id
|
171
171
|
attr_single(:registrant_id)
|
@@ -180,17 +180,17 @@ class Whois::Domain::Base
|
|
180
180
|
def ns
|
181
181
|
name_servers
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
# Is this domain expired (assuming it's registered)?
|
185
185
|
def expired?
|
186
186
|
expires_on && (expires_on < Date.today)
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
# Is this domain registered?
|
190
190
|
def registered?
|
191
191
|
!available?
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
# Some whois servers include the time of the last update to this domain in
|
195
195
|
# the database. For those that do not, this returns nil.
|
196
196
|
#
|
@@ -199,7 +199,7 @@ class Whois::Domain::Base
|
|
199
199
|
def database_updated_at
|
200
200
|
nil
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
# A url for registering this domain.
|
204
204
|
def register_url
|
205
205
|
"https://www.securepaynet.net/gdshop/registrar/search.asp?prog_id=morgancr&domainToCheck=#{name}&checkAvail=1"
|
data/lib/whois/domain/gov.rb
CHANGED
data/lib/whois/domain/int.rb
CHANGED
@@ -8,15 +8,15 @@ class Whois::Domain::Int < Whois::Domain::Base
|
|
8
8
|
:updated_on => 'changed',
|
9
9
|
:name_servers => 'nserver'
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
def registrar_name
|
13
13
|
".int Domain Registry (IANA)"
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def available?
|
17
|
-
@raw =~ /
|
17
|
+
@raw =~ /returned 0 objects/
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def name_servers
|
21
21
|
# Remove IP address.
|
22
22
|
super.collect{ |ns| ns.match(/\A([\S]*)\s/)[1] }
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'whois/domain/verisign_grs'
|
2
|
+
|
3
|
+
class Whois::Domain::Jobs < Whois::Domain::VerisignGrs
|
4
|
+
HOST = "whois.verisign-grs.com"
|
5
|
+
ATTR_MATCH = /^ ([^:]+):\W*(.*)$/
|
6
|
+
responds_to :jobs, :tv
|
7
|
+
|
8
|
+
ATTR_NAMES = {
|
9
|
+
:status => 'Domain Status',
|
10
|
+
:registrar_name => 'Sponsoring Registrar'
|
11
|
+
}
|
12
|
+
end
|
data/lib/whois/domain/museum.rb
CHANGED
@@ -9,11 +9,11 @@ class Whois::Domain::Museum < Whois::Domain::Base
|
|
9
9
|
:updated_on => "Last Updated On",
|
10
10
|
:expires_on => "Expiration Date"
|
11
11
|
}
|
12
|
-
|
12
|
+
|
13
13
|
def available?
|
14
14
|
@raw =~ /NOT FOUND/
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def register_url
|
18
18
|
"http://about.museum/register/"
|
19
19
|
end
|
data/lib/whois/domain/name.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Whois::Domain::Name < Whois::Domain::Base
|
2
2
|
HOST = "whois.nic.name"
|
3
|
-
ATTR_MATCH =
|
3
|
+
ATTR_MATCH = /^\s+([^:]+):\s(.*)$/
|
4
4
|
responds_to :name
|
5
5
|
|
6
6
|
ATTR_NAMES = {
|
@@ -10,11 +10,11 @@ class Whois::Domain::Name < Whois::Domain::Base
|
|
10
10
|
:expires_on => "Expires On",
|
11
11
|
:status => "Domain Status"
|
12
12
|
}
|
13
|
-
|
13
|
+
|
14
14
|
def available?
|
15
15
|
@raw =~ /No match/
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# whois.nic.name uses a query in the format
|
19
19
|
# object = name. e.g. domain = john.smith.name
|
20
20
|
def query_string
|
data/lib/whois/domain/pro.rb
CHANGED
@@ -2,23 +2,23 @@ class Whois::Domain::Pro < Whois::Domain::Base
|
|
2
2
|
HOST = "whois.registrypro.pro"
|
3
3
|
ATTR_MATCH = /^([^:]+):\W*(.*)\r$/
|
4
4
|
responds_to :pro
|
5
|
-
|
5
|
+
|
6
6
|
ATTR_NAMES = {
|
7
7
|
:registrar_name => "Sponsoring Registrar",
|
8
8
|
:created_on => "Created On",
|
9
9
|
:updated_on => "Last Updated On",
|
10
10
|
:expires_on => "Expiration Date"
|
11
11
|
}
|
12
|
-
|
12
|
+
|
13
13
|
def status
|
14
14
|
attrs["Status"] ? attrs["Status"][0].split(",").collect{|d| d.strip} : nil
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def register_url
|
18
18
|
"http://www.registrypro.pro/partners_findaregistrar.htm"
|
19
19
|
end
|
20
20
|
|
21
21
|
def available?
|
22
|
-
@raw =~ /^
|
22
|
+
@raw =~ /^NOT FOUND/
|
23
23
|
end
|
24
24
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
class Whois::Domain::PublicInterest < Whois::Domain::Base
|
2
2
|
HOST = "whois.pir.org"
|
3
|
-
ATTR_MATCH = /^([^:]+)
|
3
|
+
ATTR_MATCH = /^([^:]+):\s*(\S.*)\r$/
|
4
4
|
responds_to :org
|
5
5
|
|
6
6
|
ATTR_NAMES = {
|
7
7
|
:registrar_name => "Sponsoring Registrar",
|
8
|
-
:created_on => "
|
9
|
-
:updated_on => "
|
8
|
+
:created_on => "Creation Date",
|
9
|
+
:updated_on => "Updated Date",
|
10
|
+
:expires_on => "Registry Expiry Date",
|
11
|
+
:status => "Domain Status"
|
10
12
|
}
|
11
|
-
|
13
|
+
|
12
14
|
def available?
|
13
15
|
@raw =~ /NOT FOUND/
|
14
16
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class Whois::Domain::VerisignGrs < Whois::Domain::Base
|
2
2
|
HOST = "whois.verisign-grs.com"
|
3
3
|
ATTR_MATCH = /^ ([^:]+):\W*(.*)$/
|
4
|
-
responds_to :com, :net
|
5
|
-
|
4
|
+
responds_to :com, :net
|
5
|
+
|
6
6
|
def initialize(name)
|
7
7
|
@name = name
|
8
8
|
@host = nil
|
@@ -19,7 +19,7 @@ class Whois::Domain::VerisignGrs < Whois::Domain::Base
|
|
19
19
|
@raw = old_raw if (@raw =~ /not available/)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def host
|
24
24
|
return @host unless @host.nil?
|
25
25
|
|
@@ -30,21 +30,29 @@ class Whois::Domain::VerisignGrs < Whois::Domain::Base
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def query_string
|
34
|
+
if host == "whois.verisign-grs.com"
|
35
|
+
"domain #{@name.upcase}\n"
|
36
|
+
else
|
37
|
+
"#{@name.upcase}\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
33
41
|
DATABASE_UPDATED_AT_REGEXES = [
|
34
|
-
/Last update of whois database: ([^<]*)
|
35
|
-
/Record last updated on ([^\.]*)/
|
42
|
+
/Last update of whois database: ([^<]*)/i,
|
43
|
+
/Record last updated on ([^\.]*)/i
|
36
44
|
]
|
37
|
-
|
45
|
+
|
38
46
|
def database_updated_at
|
39
47
|
DATABASE_UPDATED_AT_REGEXES.each do |regex|
|
40
48
|
if (match_data = @raw.match(regex))
|
41
49
|
return Time.parse(match_data[1])
|
42
50
|
end
|
43
51
|
end
|
44
|
-
|
52
|
+
|
45
53
|
return nil
|
46
54
|
end
|
47
|
-
|
55
|
+
|
48
56
|
def available?
|
49
57
|
@raw =~ /^No match for/
|
50
58
|
end
|