whois 1.3.0 → 1.3.1

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,27 @@
1
1
  = Changelog
2
2
 
3
+
4
+ == Release 1.3.1
5
+
6
+ * SERVER: Added the following 10 new IDN TLD:
7
+ * .xn--fzc2c9e2c (.ලංකා, Sri Lanka)
8
+ * .xn--j6w193g (.香港, Hong Kong)
9
+ * .xn--kprw13d (.台灣, Taiwan)
10
+ * .xn--kpry57d (.台湾, Taiwan)
11
+ * .xn--mgbayh7gpa (.الاردن, Jordan)
12
+ * .xn--o3cw4h (.ไทย, Thailand)
13
+ * .xn--pgbs0dh (.تونس, Tunisia)
14
+ * .xn--wgbh1c (.مصر, Egypt)
15
+ * .xn--xkc2al3hye2a (.இலங்கை, Sri Lanka)
16
+ * .xn--ygbi2ammx (.فلسطين, Palestinian Territory, Occupied)
17
+
18
+ * SERVER: Sync definitions with Debian whois 5.0.7:
19
+ * Added new IPv4 allocations.
20
+ * Updated the .bd, .bo, .cm, .cu, .dz, .gr, .lb, .ni, .rw, .tw, and .tz TLD servers.
21
+
22
+ * REMOVED: Deprecated Whois::Answer::Parser.properties method.
23
+
24
+
3
25
  == Release 1.3.0
4
26
 
5
27
  * ADDED: Ability to query IANA for TLD WHOIS information. [aadlani]
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Whois is an intelligent pure Ruby WHOIS client and parser.
4
4
 
5
- It is a OS-independent library and doesn't require external C libraries or Gems: it is a 100% Ruby software with all the advantages and disadvantages that it involves.
5
+ It is a OS-independent library and doesn't require external C libraries or Gems: it is a 100% Ruby software.
6
6
 
7
7
  This software was developed to power {RoboDomain}[http://www.robodomain.com] and, since July 2009, it ran more than thousands requests.
8
8
 
@@ -11,20 +11,20 @@ An extensive test suite is available to verify the library correctness but you m
11
11
 
12
12
  == Features
13
13
 
14
- * Pure Ruby library without any external dependency other than Ruby itself
15
- * Intelligent Ruby client
16
- * Flexible and extensible configuration with support for user-defined servers
17
- * Powerful whois response parser
18
- * Support for IPv6, IPv4, TLD and domain WHOIS queries
19
- * Object oriented design
20
- * Compatible with Ruby 1.8.6 and newer, including Ruby 1.9
14
+ * Ability to query registry data for IPv4, IPv6, TLDs, and domain names
15
+ * Ability to parse WHOIS responses
16
+ * Flexible and extensible interface (e.g. You can define custom servers on the fly)
17
+ * Object oriented design, featuring 10 different design patterns
18
+ * Pure Ruby library, without any external dependency other than Ruby itself
19
+ * Compatible with Ruby 1.8.6 and greater, including Ruby 1.9 branch
20
+ * Successfully tested against multiple Ruby platforms and versions including Ruby, Ruby Enterprise Edition and MacRuby
21
21
 
22
22
 
23
23
  == Requirements
24
24
 
25
25
  * Ruby >= 1.8.6
26
26
 
27
- Whois has been {successfully tested}[http://www.ruby-whois.org/manual/installation.html] against the following Ruby platforms:
27
+ Whois has been {successfully tested}[http://www.ruby-whois.org/manual/installation.html] against the following Ruby interpreters:
28
28
 
29
29
  * Ruby 1.8.6 / 1.8.7 / 1.9.1 / 1.9.2
30
30
  * MacRuby
@@ -184,8 +184,8 @@ Bug reports and Feature suggestions {are welcomed}[http://github.com/weppos/whoi
184
184
  == More
185
185
 
186
186
  * {Homepage}[http://www.ruby-whois.org]
187
- * {GitHub Repository}[http://github.com/weppos/whois]
188
- * {API Documentation}[http://www.ruby-whois.org/api/]
187
+ * {Repository}[http://github.com/weppos/whois]
188
+ * {API Documentation}[http://www.ruby-whois.org/api/] (RDoc)
189
189
  * {Discussion Group}[http://groups.google.com/group/ruby-whois]
190
190
 
191
191
 
data/lib/whois.rb CHANGED
@@ -32,9 +32,15 @@ module Whois
32
32
  # Queries the right WHOIS server for <tt>qstring</tt> and returns
33
33
  # the response from the server.
34
34
  #
35
- # qstring - The String to be sent as query parameter.
35
+ # ==== Parameters
36
36
  #
37
- # Examples
37
+ # qstring:: The String to be sent as query parameter.
38
+ #
39
+ # ==== Returns
40
+ #
41
+ # Whois::Answer:: The answer containing the response from the WHOIS server.
42
+ #
43
+ # ==== Examples
38
44
  #
39
45
  # Whois.query("google.com")
40
46
  # # => #<Whois::Answer>
@@ -44,18 +50,30 @@ module Whois
44
50
  # Whois::Client.new.query("google.com")
45
51
  # # => #<Whois::Answer>
46
52
  #
47
- # Returns a <tt>Whois::Answer</tt> instance.
48
53
  def self.query(qstring)
49
54
  Client.new.query(qstring)
50
55
  end
51
56
 
52
57
  # Checks whether the object represented by <tt>qstring</tt> is available.
53
58
  #
54
- # qstring - The String to be sent as query parameter.
55
- # It is intented to be a domain name, otherwise this method
56
- # may return unexpected responses.
59
+ # Warning: this method is only available if a Whois parser exists
60
+ # for the top level domain of <tt>qstring</tt>.
61
+ # If no parser exists for <tt>qstring</tt>, you'll receive a
62
+ # warning message and the method will return <tt>nil</tt>.
63
+ # This is a technical limitation. Browse the lib/whois/answer/parsers
64
+ # folder to view all available parsers.
65
+ #
66
+ # ==== Parameters
67
+ #
68
+ # qstring:: The String to be sent as query parameter.
69
+ # It is intended to be a domain name, otherwise this method
70
+ # may return unexpected responses.
71
+ #
72
+ # ==== Returns
57
73
  #
58
- # Examples
74
+ # Boolean
75
+ #
76
+ # ==== Examples
59
77
  #
60
78
  # Whois.available?("google.com")
61
79
  # # => false
@@ -63,14 +81,6 @@ module Whois
63
81
  # Whois.available?("google-is-not-available-try-again-later.com")
64
82
  # # => true
65
83
  #
66
- # Warning: this method is only available if a Whois parser exists
67
- # for the top level domain of <tt>qstring</tt>.
68
- # If no parser exists for <tt>qstring</tt>, you'll receive a warning message
69
- # and the method will return <tt>nil</tt>.
70
- # This is a technical limitation. Browse the lib/whois/answer/parsers folder
71
- # to view all available parsers.
72
- #
73
- # Returns a <tt>true</tt> if the domain is available.
74
84
  def self.available?(qstring)
75
85
  query(qstring).available?
76
86
  rescue ParserNotFound => e
@@ -81,11 +91,24 @@ module Whois
81
91
 
82
92
  # Checks whether the object represented by <tt>qstring</tt> is registered.
83
93
  #
84
- # qstring - The String to be sent as query parameter.
85
- # It is intented to be a domain name, otherwise this method
94
+ # Warning: this method is only available if a Whois parser exists
95
+ # for the top level domain of <tt>qstring</tt>.
96
+ # If no parser exists for <tt>qstring</tt>, you'll receive a warning message
97
+ # and the method will return <tt>nil</tt>.
98
+ # This is a technical limitation. Browse the lib/whois/answer/parsers folder
99
+ # to view all available parsers.
100
+ #
101
+ # ==== Parameters
102
+ #
103
+ # qstring:: The String to be sent as query parameter.
104
+ # It is intended to be a domain name, otherwise this method
86
105
  # may return unexpected responses.
87
106
  #
88
- # Examples
107
+ # ==== Returns
108
+ #
109
+ # Boolean
110
+ #
111
+ # ==== Examples
89
112
  #
90
113
  # Whois.registered?("google.com")
91
114
  # # => true
@@ -93,14 +116,6 @@ module Whois
93
116
  # Whois.registered?("google-is-not-available-try-again-later.com")
94
117
  # # => false
95
118
  #
96
- # Warning: this method is only available if a Whois parser exists
97
- # for the top level domain of <tt>qstring</tt>.
98
- # If no parser exists for <tt>qstring</tt>, you'll receive a warning message
99
- # and the method will return <tt>nil</tt>.
100
- # This is a technical limitation. Browse the lib/whois/answer/parsers folder
101
- # to view all available parsers.
102
- #
103
- # Returns <tt>true</tt> if the domain is registered.
104
119
  def self.registered?(qstring)
105
120
  query(qstring).registered?
106
121
  rescue ParserNotFound => e
@@ -111,8 +126,6 @@ module Whois
111
126
 
112
127
 
113
128
  # See <tt>Whois#query</tt>.
114
- #
115
- # Returns a <tt>Whois::Answer</tt> instance.
116
129
  def self.whois(qstring)
117
130
  query(qstring)
118
131
  end
data/lib/whois/answer.rb CHANGED
@@ -66,8 +66,7 @@ module Whois
66
66
  end
67
67
 
68
68
 
69
- # Returns the content of this answer as a string.
70
- # This method joins all answer parts into a single string
69
+ # This method joins and returns all answer parts into a single string
71
70
  # and separates each response with a newline character.
72
71
  #
73
72
  # answer = Whois::Answer.new([Whois::Answer::Part.new("First answer.")])
@@ -78,6 +77,10 @@ module Whois
78
77
  # answer.content
79
78
  # # => "First answer.\nSecond answer."
80
79
  #
80
+ # ==== Returns
81
+ #
82
+ # String:: The content of this answer.
83
+ #
81
84
  def content
82
85
  @content ||= parts.map(&:response).join("\n")
83
86
  end
@@ -125,6 +128,15 @@ module Whois
125
128
  # Returns <tt>true</tt> if the <tt>property</tt> passed as symbol
126
129
  # is supported by any available parser for this answer.
127
130
  # See also <tt>Whois::Answer::Parser.supported?</tt>.
131
+ #
132
+ # ==== Parameters
133
+ #
134
+ # property:: A Symbol with the property name to check.
135
+ #
136
+ # ==== Returns
137
+ #
138
+ # Boolean
139
+ #
128
140
  def property_supported?(property)
129
141
  parser.property_supported?(property)
130
142
  end
@@ -171,4 +183,4 @@ module Whois
171
183
 
172
184
  end
173
185
 
174
- end
186
+ end
@@ -101,35 +101,47 @@ module Whois
101
101
  end
102
102
  end
103
103
 
104
- # Protected: Loops through all answer parts, for each parts tries to guess
105
- # the appropriate parser object whenever available,
104
+ # Loops through all answer parts, for each part
105
+ # tries to guess the appropriate parser object whenever available,
106
106
  # and returns the final array of server-specific parsers.
107
107
  #
108
108
  # Parsers are initialized in reverse order for performance reason.
109
109
  # See also <tt>#select_parser</tt>.
110
110
  #
111
- # Examples
111
+ # ==== Returns
112
+ #
113
+ # Returns an Array of Class,
114
+ # where each item is the parts reverse-N specific parser Class.
115
+ # Each Class is expected to be a child of Whois::Answer::Parser::Base.
116
+ #
117
+ # ==== Examples
112
118
  #
113
119
  # parser.parts
114
120
  # # => [whois.foo.com, whois.bar.com]
121
+ #
115
122
  # parser.parsers
116
123
  # # => [Whois::Answer::Parser::WhoisBarCom, Whois::Answer::Parser::WhoisFooCom]
117
124
  #
118
- # Returns an Array of Class, where
119
- # each item is the parts reverse-N specific parser Class.
120
- # Each Class is expected to be a child of Whois::Answer::Parser::Base.
121
125
  def init_parsers
122
126
  answer.parts.reverse.map { |part| self.class.parser_for(part) }
123
127
  end
124
128
 
125
- # Protected: Selects the first parser in <tt>#parsers</tt>
129
+ # Selects the first parser in <tt>#parsers</tt>
126
130
  # where <tt>given</tt> matches <tt>status</tt>.
127
131
  #
128
- # property - The Symbol property to search for
129
- # status - The Symbol status (default: :any)
132
+ # ==== Parameters
130
133
  #
134
+ # property:: The Symbol property to search for.
135
+ # status:: The Symbol status (default: :any).
131
136
  #
132
- # Examples
137
+ # ==== Returns
138
+ #
139
+ # Whois::Answer::Parser::Base::
140
+ # The parser which satisfies given requirement.
141
+ # nil::
142
+ # If the parser wasn't found.
143
+ #
144
+ # ==== Examples
133
145
  #
134
146
  # select_parser(:nameservers)
135
147
  # # => #<Whois::Answer::Parser::WhoisExampleCom>
@@ -137,9 +149,6 @@ module Whois
137
149
  # select_parser(:nameservers, :supported)
138
150
  # # => nil
139
151
  #
140
- # Returns an instance of Whois::Answer::Parser::Base
141
- # with the parser which satisfies given requirement,
142
- # or nil the parser wasn't found.
143
152
  def select_parser(property, status = :any)
144
153
  parsers.each do |parser|
145
154
  return parser if parser.class.property_registered?(property, status)
@@ -152,9 +161,16 @@ module Whois
152
161
  # The parser class is selected according to the
153
162
  # value of the <tt>#host</tt> attribute for given <tt>part</tt>.
154
163
  #
155
- # part - The Whois::Answer::Parser::Part to get the parser for
164
+ # ==== Parameters
165
+ #
166
+ # part:: The Whois::Answer::Parser::Part to get the parser for.
156
167
  #
157
- # Examples
168
+ # ==== Returns
169
+ #
170
+ # Returns an instance of the specific parser for given part.
171
+ # The instance is expected to be a child of Whois::Answer::Parser::Base.
172
+ #
173
+ # ==== Examples
158
174
  #
159
175
  # # Parser for a known host
160
176
  # Parser.parser_for("whois.example.com")
@@ -164,8 +180,6 @@ module Whois
164
180
  # Parser.parser_for("missing.example.com")
165
181
  # #<Whois::Answer::Parser::Blank>
166
182
  #
167
- # Returns an instance of the specific parser for given part.
168
- # The instance is expected to be a child of Whois::Answer::Parser::Base.
169
183
  def self.parser_for(part)
170
184
  parser_klass(part.host).new(part)
171
185
  end
@@ -177,9 +191,19 @@ module Whois
177
191
  # a custom parser, simple make sure the class is loaded in the Ruby
178
192
  # environment before this method is called.
179
193
  #
180
- # host - A String with the host
194
+ # ==== Parameters
195
+ #
196
+ # host:: A String with the host.
181
197
  #
182
- # Examples
198
+ # ==== Returns
199
+ #
200
+ # Returns an instance of Class representing the parser Class
201
+ # corresponding to <tt>host</tt>.
202
+ # If <tt>host</tt> doesn't have a specific parser implementation,
203
+ # then returns the Whois::Answer::Parser::Blank Class.
204
+ # The Class is expected to be a child of Whois::Answer::Parser::Base.
205
+ #
206
+ # ==== Examples
183
207
  #
184
208
  # Parser.parser_klass("missing.example.com")
185
209
  # # => Whois::Answer::Parser::Blank
@@ -191,11 +215,6 @@ module Whois
191
215
  # Parser.parser_klass("missing.example.com")
192
216
  # # => Whois::Answer::Parser::MissingExampleCom
193
217
  #
194
- # Returns an instance of Class representing the parser Class
195
- # corresponding to <tt>host</tt>.
196
- # If <tt>host</tt> doesn't have a specific parser implementation,
197
- # then returns the Whois::Answer::Parser::Blank Class.
198
- # The Class is expected to be a child of Whois::Answer::Parser::Base.
199
218
  def self.parser_klass(host)
200
219
  name = host_to_parser(host)
201
220
  Parser.const_defined?(name) || autoload(host)
@@ -208,12 +227,15 @@ module Whois
208
227
 
209
228
  # Converts <tt>host</tt> to the corresponding parser class name.
210
229
  #
211
- # host - A String with the host
230
+ # ==== Parameters
231
+ #
232
+ # host:: A String with the host.
212
233
  #
213
- # Examples
234
+ # ==== Examples
214
235
  #
215
236
  # Parser.host_to_parser("whois.nic.it")
216
237
  # # => "WhoisNicIt"
238
+ #
217
239
  # Parser.host_to_parser("whois.nic-info.it")
218
240
  # # => "WhoisNicInfoIt"
219
241
  #
@@ -226,20 +248,19 @@ module Whois
226
248
 
227
249
  # Requires the file at <tt>whois/answer/parser/#{name}</tt>.
228
250
  #
229
- # name - A string with the file name
251
+ # ==== Parameters
252
+ #
253
+ # name:: A string with the file name.
254
+ #
255
+ # ==== Returns
256
+ #
257
+ # Nothing.
230
258
  #
231
- # Returns nothing.
232
259
  def self.autoload(name)
233
260
  file = "whois/answer/parser/#{name}"
234
261
  require file
235
262
  end
236
263
 
237
-
238
- def self.properties # :nodoc:
239
- Whois.deprecate("Whois::Answer::Parser.properties is deprecated. Use the Whois::Answer::Parser::PROPERTIES constant.")
240
- PROPERTIES
241
- end
242
-
243
264
  end
244
265
 
245
266
  end
@@ -41,11 +41,11 @@ module Whois
41
41
  end
42
42
 
43
43
  property_supported :available? do
44
- @available ||= !!(content_for_scanner =~ /Object (.*?) NOT FOUND/)
44
+ @available ||= !!(content_for_scanner =~ /Object (.*?) NOT FOUND/)
45
45
  end
46
46
 
47
47
  property_supported :registered? do
48
- !available?
48
+ @registered ||= !available?
49
49
  end
50
50
 
51
51
 
data/lib/whois/client.rb CHANGED
@@ -34,19 +34,24 @@ module Whois
34
34
  #
35
35
  # Initializes a new <tt>Whois::Client</tt> with <tt>options</tt>.
36
36
  #
37
- # options - The Hash options used to refine the selection (default: {}):
37
+ # ==== Parameters
38
+ #
39
+ # options:: Hash of options (default: {}):
38
40
  # :timeout - The Integer script timeout, expressed in seconds (default: DEFAULT_TIMEOUT).
39
41
  #
40
42
  # If <tt>block</tt> is given, yields <tt>self</tt>.
41
43
  #
42
- # Examples
44
+ # ==== Returns
45
+ #
46
+ # Whois::Client:: The client instance.
47
+ #
48
+ # ==== Examples
43
49
  #
44
50
  # client = Whois::Client.new do |c|
45
51
  # c.timeout = nil
46
52
  # end
47
53
  # client.query("google.com")
48
54
  #
49
- # Returns a <tt>Whois::Client</tt>.
50
55
  def initialize(options = {}, &block)
51
56
  self.timeout = options[:timeout] || DEFAULT_TIMEOUT
52
57
  yield(self) if block_given?
@@ -68,14 +73,19 @@ module Whois
68
73
  # Queries the right WHOIS server for <tt>qstring</tt> and returns
69
74
  # the response from the server.
70
75
  #
71
- # qstring - The String to be sent as query parameter.
76
+ # ==== Parameters
77
+ #
78
+ # qstring:: The String to be sent as query parameter.
79
+ #
80
+ # ==== Returns
81
+ #
82
+ # Whois::Answer:: The answer object containing the WHOIS response.
72
83
  #
73
- # Examples
84
+ # ==== Examples
74
85
  #
75
86
  # client.query("google.com")
76
87
  # # => #<Whois::Answer>
77
88
  #
78
- # Returns a <tt>Whois::Answer</tt> instance.
79
89
  def query(qstring)
80
90
  string = qstring.to_s
81
91
  Timeout::timeout(timeout) do