Skip to content

Commit

Permalink
Renamed query method into request and wrapped request call into q…
Browse files Browse the repository at this point in the history
…uery so that the call can be easily mock, tested and extended.

The response can now be intercepted before sending back the value to the called, in this way the response can be parsed or normalized.
  • Loading branch information
weppos committed Jul 22, 2009
1 parent 6d0b49f commit 9662cd2
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/afilias.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Afilias < Base

def query(qstring)
def request(qstring)
response = ask_the_socket(qstring, "whois.afilias-grs.info", DEFAULT_WHOIS_PORT)
if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
ask_the_socket(qstring, $1, DEFAULT_WHOIS_PORT)
Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/arpa.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Arpa < Base

def query(qstring)
def request(qstring)
Server.guess(inaddr_to_ip(qstring)).query(qstring)
end

Expand Down
6 changes: 5 additions & 1 deletion lib/whois/server/adapters/base.rb
Expand Up @@ -34,9 +34,13 @@ def initialize(extension, server, options = {})
end

def query(qstring)
request(qstring)
end

def request(qstring)
raise NotImplementedError
end


protected

Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/formatted.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Formatted < Base

def query(qstring)
def request(qstring)
query_the_socket(sprintf(options[:format], qstring), server)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/none.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class None < Base

def query(qstring)
def request(qstring)
raise NoInterfaceError, "This TLD has no whois server"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/pir.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Pir < Base

def query(qstring)
def request(qstring)
response = ask_the_socket("FULL #{qstring}", "whois.publicinterestregistry.net", DEFAULT_WHOIS_PORT)
if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
response =~ /Registrant Street1:Whois Server:(\S+)/
Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/standard.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Standard < Base

def query(qstring)
def request(qstring)
query_the_socket(qstring, server)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/verisign.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Verisign < Base

def query(qstring)
def request(qstring)
response = ask_the_socket("=#{qstring}", "whois.crsnic.net", DEFAULT_WHOIS_PORT)
if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
ask_the_socket(qstring, $1, DEFAULT_WHOIS_PORT)
Expand Down
2 changes: 1 addition & 1 deletion lib/whois/server/adapters/web.rb
Expand Up @@ -20,7 +20,7 @@ module Adapters

class Web < Base

def query(qstring)
def request(qstring)
raise WebInterfaceError, "This TLD has no whois server, " +
"but you can access the whois database at `#{options[:web]}'"
end
Expand Down

0 comments on commit 9662cd2

Please sign in to comment.