Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix RDoc formatting

  • Loading branch information...
commit 6500dd3b8bc1982ed6eeafa0b93d65da31a69dec 1 parent 2a8115e
@weppos authored
View
16 lib/whois.rb
@@ -58,16 +58,16 @@ def self.query(qstring)
#
# Warning: this method is only available if a Whois parser exists
# for the top level domain of <tt>qstring</tt>.
- # If no parser exists for <tt>qstring</tt>, you'll receive a warning message
- # and the method will return <tt>nil</tt>.
- # This is a technical limitation. Browse the lib/whois/answer/parsers folder
- # to view all available parsers.
+ # If no parser exists for <tt>qstring</tt>, you'll receive a
+ # warning message and the method will return <tt>nil</tt>.
+ # This is a technical limitation. Browse the lib/whois/answer/parsers
+ # folder to view all available parsers.
#
# ==== Parameters
#
# qstring:: The String to be sent as query parameter.
- # It is intended to be a domain name, otherwise this method
- # may return unexpected responses.
+ # It is intended to be a domain name, otherwise this method
+ # may return unexpected responses.
#
# ==== Returns
#
@@ -101,8 +101,8 @@ def self.available?(qstring)
# ==== Parameters
#
# qstring:: The String to be sent as query parameter.
- # It is intended to be a domain name, otherwise this method
- # may return unexpected responses.
+ # It is intended to be a domain name, otherwise this method
+ # may return unexpected responses.
#
# ==== Returns
#
View
18 lib/whois/answer.rb
@@ -66,8 +66,7 @@ def eql?(other)
end
- # Returns the content of this answer as a string.
- # This method joins all answer parts into a single string
+ # This method joins and returns all answer parts into a single string
# and separates each response with a newline character.
#
# answer = Whois::Answer.new([Whois::Answer::Part.new("First answer.")])
@@ -78,6 +77,10 @@ def eql?(other)
# answer.content
# # => "First answer.\nSecond answer."
#
+ # ==== Returns
+ #
+ # String:: The content of this answer.
+ #
def content
@content ||= parts.map(&:response).join("\n")
end
@@ -125,6 +128,15 @@ def properties
# Returns <tt>true</tt> if the <tt>property</tt> passed as symbol
# is supported by any available parser for this answer.
# See also <tt>Whois::Answer::Parser.supported?</tt>.
+ #
+ # ==== Parameters
+ #
+ # property:: A Symbol with the property name to check.
+ #
+ # ==== Returns
+ #
+ # Boolean
+ #
def property_supported?(property)
parser.property_supported?(property)
end
@@ -171,4 +183,4 @@ def #{$1}?
end
-end
+end
View
83 lib/whois/answer/parser.rb
@@ -101,35 +101,47 @@ def delegate_to_parsers(method, *args, &block)
end
end
- # Protected: Loops through all answer parts, for each parts tries to guess
- # the appropriate parser object whenever available,
+ # Loops through all answer parts, for each part
+ # tries to guess the appropriate parser object whenever available,
# and returns the final array of server-specific parsers.
#
# Parsers are initialized in reverse order for performance reason.
# See also <tt>#select_parser</tt>.
#
- # Examples
+ # ==== Returns
+ #
+ # Returns an Array of Class,
+ # where each item is the parts reverse-N specific parser Class.
+ # Each Class is expected to be a child of Whois::Answer::Parser::Base.
+ #
+ # ==== Examples
#
# parser.parts
# # => [whois.foo.com, whois.bar.com]
+ #
# parser.parsers
# # => [Whois::Answer::Parser::WhoisBarCom, Whois::Answer::Parser::WhoisFooCom]
#
- # Returns an Array of Class, where
- # each item is the parts reverse-N specific parser Class.
- # Each Class is expected to be a child of Whois::Answer::Parser::Base.
def init_parsers
answer.parts.reverse.map { |part| self.class.parser_for(part) }
end
- # Protected: Selects the first parser in <tt>#parsers</tt>
+ # Selects the first parser in <tt>#parsers</tt>
# where <tt>given</tt> matches <tt>status</tt>.
#
- # property - The Symbol property to search for
- # status - The Symbol status (default: :any)
+ # ==== Parameters
+ #
+ # property:: The Symbol property to search for.
+ # status:: The Symbol status (default: :any).
+ #
+ # ==== Returns
#
+ # Whois::Answer::Parser::Base::
+ # The parser which satisfies given requirement.
+ # nil::
+ # If the parser wasn't found.
#
- # Examples
+ # ==== Examples
#
# select_parser(:nameservers)
# # => #<Whois::Answer::Parser::WhoisExampleCom>
@@ -137,9 +149,6 @@ def init_parsers
# select_parser(:nameservers, :supported)
# # => nil
#
- # Returns an instance of Whois::Answer::Parser::Base
- # with the parser which satisfies given requirement,
- # or nil the parser wasn't found.
def select_parser(property, status = :any)
parsers.each do |parser|
return parser if parser.class.property_registered?(property, status)
@@ -152,9 +161,16 @@ def select_parser(property, status = :any)
# The parser class is selected according to the
# value of the <tt>#host</tt> attribute for given <tt>part</tt>.
#
- # part - The Whois::Answer::Parser::Part to get the parser for
+ # ==== Parameters
+ #
+ # part:: The Whois::Answer::Parser::Part to get the parser for.
#
- # Examples
+ # ==== Returns
+ #
+ # Returns an instance of the specific parser for given part.
+ # The instance is expected to be a child of Whois::Answer::Parser::Base.
+ #
+ # ==== Examples
#
# # Parser for a known host
# Parser.parser_for("whois.example.com")
@@ -164,8 +180,6 @@ def select_parser(property, status = :any)
# Parser.parser_for("missing.example.com")
# #<Whois::Answer::Parser::Blank>
#
- # Returns an instance of the specific parser for given part.
- # The instance is expected to be a child of Whois::Answer::Parser::Base.
def self.parser_for(part)
parser_klass(part.host).new(part)
end
@@ -177,9 +191,19 @@ def self.parser_for(part)
# a custom parser, simple make sure the class is loaded in the Ruby
# environment before this method is called.
#
- # host - A String with the host
+ # ==== Parameters
+ #
+ # host:: A String with the host.
#
- # Examples
+ # ==== Returns
+ #
+ # Returns an instance of Class representing the parser Class
+ # corresponding to <tt>host</tt>.
+ # If <tt>host</tt> doesn't have a specific parser implementation,
+ # then returns the Whois::Answer::Parser::Blank Class.
+ # The Class is expected to be a child of Whois::Answer::Parser::Base.
+ #
+ # ==== Examples
#
# Parser.parser_klass("missing.example.com")
# # => Whois::Answer::Parser::Blank
@@ -191,11 +215,6 @@ def self.parser_for(part)
# Parser.parser_klass("missing.example.com")
# # => Whois::Answer::Parser::MissingExampleCom
#
- # Returns an instance of Class representing the parser Class
- # corresponding to <tt>host</tt>.
- # If <tt>host</tt> doesn't have a specific parser implementation,
- # then returns the Whois::Answer::Parser::Blank Class.
- # The Class is expected to be a child of Whois::Answer::Parser::Base.
def self.parser_klass(host)
name = host_to_parser(host)
Parser.const_defined?(name) || autoload(host)
@@ -208,12 +227,15 @@ def self.parser_klass(host)
# Converts <tt>host</tt> to the corresponding parser class name.
#
- # host - A String with the host
+ # ==== Parameters
+ #
+ # host:: A String with the host.
#
- # Examples
+ # ==== Examples
#
# Parser.host_to_parser("whois.nic.it")
# # => "WhoisNicIt"
+ #
# Parser.host_to_parser("whois.nic-info.it")
# # => "WhoisNicInfoIt"
#
@@ -226,9 +248,14 @@ def self.host_to_parser(host)
# Requires the file at <tt>whois/answer/parser/#{name}</tt>.
#
- # name - A string with the file name
+ # ==== Parameters
+ #
+ # name:: A string with the file name.
+ #
+ # ==== Returns
+ #
+ # Nothing.
#
- # Returns nothing.
def self.autoload(name)
file = "whois/answer/parser/#{name}"
require file
View
22 lib/whois/client.rb
@@ -34,19 +34,24 @@ class Client
#
# Initializes a new <tt>Whois::Client</tt> with <tt>options</tt>.
#
- # options - The Hash options used to refine the selection (default: {}):
+ # ==== Parameters
+ #
+ # options:: The Hash options used to refine the selection (default: {}):
# :timeout - The Integer script timeout, expressed in seconds (default: DEFAULT_TIMEOUT).
#
# If <tt>block</tt> is given, yields <tt>self</tt>.
#
- # Examples
+ # ==== Returns
+ #
+ # Whois::Client:: The client instance.
+ #
+ # ==== Examples
#
# client = Whois::Client.new do |c|
# c.timeout = nil
# end
# client.query("google.com")
#
- # Returns a <tt>Whois::Client</tt>.
def initialize(options = {}, &block)
self.timeout = options[:timeout] || DEFAULT_TIMEOUT
yield(self) if block_given?
@@ -68,14 +73,19 @@ class Query # :nodoc:
# Queries the right WHOIS server for <tt>qstring</tt> and returns
# the response from the server.
#
- # qstring - The String to be sent as query parameter.
+ # ==== Parameters
+ #
+ # qstring:: The String to be sent as query parameter.
+ #
+ # ==== Returns
+ #
+ # Whois::Answer:: The answer object containing the WHOIS response.
#
- # Examples
+ # ==== Examples
#
# client.query("google.com")
# # => #<Whois::Answer>
#
- # Returns a <tt>Whois::Answer</tt> instance.
def query(qstring)
string = qstring.to_s
Timeout::timeout(timeout) do
View
98 lib/whois/server.rb
@@ -38,8 +38,8 @@ module Adapters
@@definitions = {}
# Searches the /definitions folder for definition files and loads them.
- # This method is automatically invoked when this file is parsed by the Ruby interpreter
- # (scroll down to the bottom of this file).
+ # This method is automatically invoked when this file is parsed
+ # by the Ruby interpreter (scroll down to the bottom of this file).
def self.load_definitions
Dir[File.dirname(__FILE__) + '/definitions/*.rb'].each { |file| load(file) }
end
@@ -49,16 +49,16 @@ def self.load_definitions
#
# ==== Parameters
#
- # type:: The type of WHOIS server to lookup.
- # Known values are :tld, :ipv4, :ipv6.
+ # type:: The type of WHOIS server to lookup.
+ # Known values are :tld, :ipv4, :ipv6.
#
# ==== Returns
#
- # Hash:: If the method is called without specifying a <tt>type</tt>.
+ # Hash:: If the method is called without specifying a <tt>type</tt>.
# Array:: If the method is called specifying a <tt>type</tt>,
- # and the <tt>type</tt> exists.
- # nil:: If the method is called specifying a <tt>type</tt>,
- # and the <tt>type</tt> doesn't exist.
+ # and the <tt>type</tt> exists.
+ # nil:: If the method is called specifying a <tt>type</tt>,
+ # and the <tt>type</tt> doesn't exist.
#
# ==== Examples
#
@@ -83,18 +83,18 @@ def self.definitions(type = nil)
#
# ==== Parameters
#
- # type:: The type of WHOIS server to define.
- # Known values are :tld, :ipv4, :ipv6.
- # allocation:: The allocation, range or hostname
- # this server is responsible for.
- # host:: The server hostname.
- # Use nil if unknown or not available.
- # options:: Hash of options to customize Adapter behavior.
- # The <tt>:adapter</tt> option has a special meaning and determines
- # the adapter Class to use.
- # Defaults to </tt>Whois::Server::Adapters::Standard</tt> unless specified.
- # All the other options are passed directly to the adapter which
- # can decide how to use them.
+ # type:: The type of WHOIS server to define.
+ # Known values are :tld, :ipv4, :ipv6.
+ # allocation:: The allocation, range or hostname
+ # this server is responsible for.
+ # host:: The server hostname.
+ # Use nil if unknown or not available.
+ # options:: Hash of options to customize Adapter behavior.
+ # The <tt>:adapter</tt> option has a special meaning
+ # and determines the adapter Class to use.
+ # Defaults to </tt>Whois::Server::Adapters::Standard</tt>
+ # unless specified. All the other options are passed
+ # directly to the adapter which can decide how to use them.
#
# ==== Returns
#
@@ -112,10 +112,13 @@ def self.definitions(type = nil)
# Whois::Server.define :ipv6, "2001:2000::/19", "whois.ripe.net"
#
# # Define a new server with a custom adapter
- # Whois::Server.define :tld, ".test", nil, :adapter => Whois::Server::Adapter::None
+ # Whois::Server.define :tld, ".test", nil,
+ # :adapter => Whois::Server::Adapter::None
#
# # Define a new server with a custom adapter and options
- # Whois::Server.define :tld, ".ar", nil, :adapter => Whois::Server::Adapters::Web, :web => "http://www.nic.ar/"
+ # Whois::Server.define :tld, ".ar", nil,
+ # :adapter => Whois::Server::Adapters::Web,
+ # :web => "http://www.nic.ar/"
#
def self.define(type, allocation, host, options = {})
@@definitions[type] ||= []
@@ -126,37 +129,41 @@ def self.define(type, allocation, host, options = {})
# and returns the server instance.
#
# By default, returns a new Whois::Servers::Adapter::Standard instance.
- # You can customize the behavior passing a custom adapter class as <tt>:adapter</tt> option.
+ # You can customize the behavior passing a custom adapter class
+ # as <tt>:adapter</tt> option.
#
# Whois::Server.factory :tld, ".it", "whois.nic.it"
# # => #<Whois::Servers::Adapter::Standard>
#
- # Whois::Server.factory :tld, ".it", "whois.nic.it", :option => Whois::Servers::Adapter::Custom
+ # Whois::Server.factory :tld, ".it", "whois.nic.it",
+ # :option => Whois::Servers::Adapter::Custom
# # => #<Whois::Servers::Adapter::Custom>
#
- # Please note that any adapter is responsible for a limited set of queries,
- # which should be included in the range of the <tt>allocation</tt> parameter.
- # Use <tt>Whois::Server#guess</tt> if you are not sure which adapter is the right one
- # for a specific string.
+ # Please note that any adapter is responsible for a limited set
+ # of queries, which should be included in the range
+ # of the <tt>allocation</tt> parameter.
+ # Use <tt>Whois::Server#guess</tt> if you are not sure which adapter
+ # is the right one for a specific string.
#
# ==== Parameters
#
- # type:: The type of WHOIS server to create.
- # Known values are :tld, :ipv4, :ipv6.
- # allocation:: The allocation, range or hostname
- # this server is responsible for.
- # host:: The server hostname.
- # Use nil if unknown or not available.
- # options:: Hash of options to customize Adapter behavior.
- # The <tt>:adapter</tt> option has a special meaning and determines
- # the adapter Class to use.
- # Defaults to </tt>Whois::Server::Adapters::Standard</tt> unless specified.
- # All the other options are passed directly to the adapter which
- # can decide how to use them.
+ # type:: The type of WHOIS server to define.
+ # Known values are :tld, :ipv4, :ipv6.
+ # allocation:: The allocation, range or hostname
+ # this server is responsible for.
+ # host:: The server hostname.
+ # Use nil if unknown or not available.
+ # options:: Hash of options to customize Adapter behavior.
+ # The <tt>:adapter</tt> option has a special meaning
+ # and determines the adapter Class to use.
+ # Defaults to </tt>Whois::Server::Adapters::Standard</tt>
+ # unless specified. All the other options are passed
+ # directly to the adapter which can decide how to use them.
#
# ==== Returns
#
- # Whois::Server::Adapters::Standard:: An adapter that can be used to perform queries.
+ # Whois::Server::Adapters::Standard::
+ # An adapter that can be used to perform queries.
#
def self.factory(type, allocation, host, options = {})
options = options.dup
@@ -181,15 +188,18 @@ def self.factory(type, allocation, host, options = {})
#
# ==== Returns
#
- # Whois::Server::Adapters::Base:: The adapter that can be used to perform
+ # Whois::Server::Adapters::Base::
+ # The adapter that can be used to perform
# WHOIS queries for <tt>qstring</tt>.
#
# ==== Raises
#
- # ServerNotFound:: When unable to find an appropriate WHOIS adapter
+ # Whois::ServerNotFound::
+ # When unable to find an appropriate WHOIS adapter
# for <tt>qstring</tt>. Most of the cases, the <tt>qstring</tt>
# haven't been recognised as one of the supported query types.
- # ServerNotSupported:: When the <tt>qstring</tt> type is detected,
+ # Whois::ServerNotSupported::
+ # When the <tt>qstring</tt> type is detected,
# but the object type doesn't have any supported WHOIS adapter associated.
#
def self.guess(qstring)
Please sign in to comment.
Something went wrong with that request. Please try again.