From 02a41a8592a856a02207b3af9b9f8110c7751374 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Fri, 25 Sep 2009 19:55:02 +0200 Subject: [PATCH] Minor improvements for the RDoc documentation. --- lib/whois.rb | 31 +++++++++++++++++---------- lib/whois/answer/parser.rb | 5 ++++- lib/whois/answer/parser/blank.rb | 2 +- lib/whois/answer/part.rb | 7 +++--- lib/whois/client.rb | 6 ++++++ lib/whois/errors.rb | 8 +++++-- lib/whois/server/adapters/none.rb | 2 +- lib/whois/server/adapters/standard.rb | 4 ++-- 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/lib/whois.rb b/lib/whois.rb index 449e0d510..156af1c73 100644 --- a/lib/whois.rb +++ b/lib/whois.rb @@ -30,7 +30,16 @@ module Whois # Queries the right whois server for qstring and returns - # a Whois::Answer instance containing the response from the server. + # a Whois::Answer instance containing the response from the server. + # + # Whois.query("google.com") + # # => # + # + # This is equivalent to + # + # Whois::Client.new.query("google.com") + # # => # + # def self.whois(qstring) query(qstring) end @@ -39,11 +48,11 @@ def self.whois(qstring) # qstring is intended to be a domain name, # otherwise this method may return unexpected responses. # - # Whois.available?("google.com") - # # => false - # - # Whois.available?("google-is-not-available-try-again-later.com") - # # => true + # Whois.available?("google.com") + # # => false + # + # Whois.available?("google-is-not-available-try-again-later.com") + # # => true # # Warning: this method is only available if a Whois parser exists # for qstring top level domain. Otherwise you'll get a warning message @@ -63,11 +72,11 @@ def self.available?(qstring) # qstring is intended to be a domain name, # otherwise this method may return unexpected responses. # - # Whois.registered?("google.com") - # # => true - # - # Whois.registered?("google-is-not-available-try-again-later.com") - # # => false + # Whois.registered?("google.com") + # # => true + # + # Whois.registered?("google-is-not-available-try-again-later.com") + # # => false # # Warning: this method is only available if a Whois parser exists # for qstring top level domain. Otherwise you'll get a warning message diff --git a/lib/whois/answer/parser.rb b/lib/whois/answer/parser.rb index a13973f0f..3e54ddd9e 100644 --- a/lib/whois/answer/parser.rb +++ b/lib/whois/answer/parser.rb @@ -32,13 +32,16 @@ class Parser :nameservers, ] + # Returns an array containing the name of all methods + # that can be registered and should be implemented by + # server-specific parsers. def self.registrable_methods @@registrable_methods end attr_reader :answer - + def initialize(answer) @answer = answer end diff --git a/lib/whois/answer/parser/blank.rb b/lib/whois/answer/parser/blank.rb index 5066bbabf..cecf26f07 100644 --- a/lib/whois/answer/parser/blank.rb +++ b/lib/whois/answer/parser/blank.rb @@ -22,7 +22,7 @@ class Answer class Parser # - # = blank parser + # = Blank parser # # The Blank parser isn't a real parser. It's just a fake parser # that acts as a parser but doesn't provide any special capability. diff --git a/lib/whois/answer/part.rb b/lib/whois/answer/part.rb index f89842d02..1b264609a 100644 --- a/lib/whois/answer/part.rb +++ b/lib/whois/answer/part.rb @@ -23,9 +23,10 @@ class Answer # # = Part # - # A single answer fragment. For instance, in case of thin server, - # an answer may be composed by more parts corresponding - # to all responses returned by the whois servers. + # A single Whois::Answer fragment. For instance, + # in case of thin server, an Whois::Answer may be composed by + # one or more parts corresponding to all responses + # returned by the WHOIS servers. # class Part < SuperStruct.new(:response, :host) end diff --git a/lib/whois/client.rb b/lib/whois/client.rb index 70a386a7f..1f96700b0 100644 --- a/lib/whois/client.rb +++ b/lib/whois/client.rb @@ -60,6 +60,12 @@ class Query # :nodoc end + # Queries the right whois server for qstring and returns + # a Whois::Answer instance containing the response from the server. + # + # client.query("google.com") + # # => # + # def query(qstring) Timeout::timeout(timeout) do @server = Server.guess(qstring) diff --git a/lib/whois/errors.rb b/lib/whois/errors.rb index b525e670f..7e9f460ba 100644 --- a/lib/whois/errors.rb +++ b/lib/whois/errors.rb @@ -38,13 +38,13 @@ class InterfaceNotSupported < ServerError end # Raised when a server is known to not be available for this kind of object - # or because this specific object doesn't support whois. (\x03) + # or because this specific object doesn't support WHOIS. (\x03) class NoInterfaceError < InterfaceNotSupported end # Raised when the class has found a server but it doesn't support the # standard whois interface via port 43. This is the case of some - # specific domains that only provide a web–based whois interface. (\x01) + # specific domains that only provide a web–based WHOIS interface. (\x01) class WebInterfaceError < InterfaceNotSupported end @@ -74,9 +74,13 @@ class ParserError < Error class ParserNotFound < ParserError end + # Raised when the property method has not been overwritten (implemented) + # in a child parser class. class PropertyNotImplemented < ParserError end + # Raised when you are trying to access a property that is not supported + # by any of the parsers available for current WHOIS answer. class PropertyNotSupported < ParserError end diff --git a/lib/whois/server/adapters/none.rb b/lib/whois/server/adapters/none.rb index bdc9a5b2d..465de9c6b 100644 --- a/lib/whois/server/adapters/none.rb +++ b/lib/whois/server/adapters/none.rb @@ -39,7 +39,7 @@ class None < Base # ==== Raises # NoInterfaceError:: for every request # - def request(query) + def request(qstring) raise NoInterfaceError, "This `#{type}' has no whois server" end diff --git a/lib/whois/server/adapters/standard.rb b/lib/whois/server/adapters/standard.rb index 88b1c83ef..de21a0add 100644 --- a/lib/whois/server/adapters/standard.rb +++ b/lib/whois/server/adapters/standard.rb @@ -30,8 +30,8 @@ module Adapters # class Standard < Base - def request(query) - response = query_the_socket(query, host) + def request(qstring) + response = query_the_socket(qstring, host) append_to_buffer response, host end