Skip to content

Commit

Permalink
Minor improvements for the RDoc documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Sep 25, 2009
1 parent 6a4ee3a commit 02a41a8
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
31 changes: 20 additions & 11 deletions lib/whois.rb
Expand Up @@ -30,7 +30,16 @@ module Whois


# Queries the right whois server for <tt>qstring</tt> and returns
# a Whois::Answer instance containing the response from the server.
# a <tt>Whois::Answer</tt> instance containing the response from the server.
#
# Whois.query("google.com")
# # => #<Whois::Answer>
#
# This is equivalent to
#
# Whois::Client.new.query("google.com")
# # => #<Whois::Answer>
#
def self.whois(qstring)
query(qstring)
end
Expand All @@ -39,11 +48,11 @@ def self.whois(qstring)
# <tt>qstring</tt> 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 <tt>qstring</tt> top level domain. Otherwise you'll get a warning message
Expand All @@ -63,11 +72,11 @@ def self.available?(qstring)
# <tt>qstring</tt> 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 <tt>qstring</tt> top level domain. Otherwise you'll get a warning message
Expand Down
5 changes: 4 additions & 1 deletion lib/whois/answer/parser.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/whois/answer/parser/blank.rb
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions lib/whois/answer/part.rb
Expand Up @@ -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 <tt>Whois::Answer</tt> fragment. For instance,
# in case of thin server, an <tt>Whois::Answer</tt> may be composed by
# one or more parts corresponding to all responses
# returned by the WHOIS servers.
#
class Part < SuperStruct.new(:response, :host)
end
Expand Down
6 changes: 6 additions & 0 deletions lib/whois/client.rb
Expand Up @@ -60,6 +60,12 @@ class Query # :nodoc
end


# Queries the right whois server for <tt>qstring</tt> and returns
# a <tt>Whois::Answer</tt> instance containing the response from the server.
#
# client.query("google.com")
# # => #<Whois::Answer>
#
def query(qstring)
Timeout::timeout(timeout) do
@server = Server.guess(qstring)
Expand Down
8 changes: 6 additions & 2 deletions lib/whois/errors.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/none.rb
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/whois/server/adapters/standard.rb
Expand Up @@ -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

Expand Down

0 comments on commit 02a41a8

Please sign in to comment.