Skip to content

Commit

Permalink
kero.yachay.pe parser now recognizes throttled responses
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Nov 20, 2012
1 parent 5150894 commit b73890a
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -17,7 +17,9 @@

- NEW: Support for non-deep querying (GH-112)

* NEW: Added full whois.dns.pl parser.
- NEW: Added full whois.dns.pl parser.

- NEW: kero.yachay.pe parser now recognizes throttled responses.

- CHANGED: Dropped support for Ruby 1.8

Expand Down
44 changes: 27 additions & 17 deletions lib/whois/record/parser/kero.yachay.pe.rb
Expand Up @@ -14,38 +14,36 @@ module Whois
class Record
class Parser

#
# = kero.yachay.pe parser
#
# Parser for the kero.yachay.pe server.
#
# NOTE: This parser is just a stub and provides only a few basic methods
# to check for domain availability and get domain status.
# Please consider to contribute implementing missing methods.
# See WhoisNicIt parser for an explanation of all available methods
# and examples.
# @note This parser is just a stub and provides only a few basic methods
# to check for domain availability and get domain status.
# Please consider to contribute implementing missing methods.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
class KeroYachayPe < Base

property_supported :status do
if content_for_scanner =~ /Status:\s+(.+?)\n/
case $1.downcase
when "active"
:registered
when "not registered"
:available
when "inactive"
:inactive
else
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
when "active"
:registered
when "not registered"
:available
when "inactive"
:inactive
else
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
end
else
Whois.bug!(ParserError, "Unable to parse status.")
end
end

property_supported :available? do
(status == :available)
status == :available
end

property_supported :registered? do
Expand All @@ -68,6 +66,18 @@ class KeroYachayPe < Base
end
end


# Checks whether the response has been throttled.
#
# @return [Boolean]
#
# @example
# Looup quota exceeded.
#
def response_throttled?
!content_for_scanner.match(/Looup quota exceeded./).nil?
end

end

end
Expand Down
@@ -0,0 +1,2 @@
#response_throttled?
should: %s == true
18 changes: 18 additions & 0 deletions spec/fixtures/responses/kero.yachay.pe/response_throttled.txt
@@ -0,0 +1,18 @@
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated. Whois database is provided as a service to the internet
community.

The data is for information purposes only. Red Cientifica Peruana does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes.

The compilation, repackaging, dissemination or other use of this Data is
expressly prohibited.

Your request could not be performed.
Looup quota exceeded.
Expand Up @@ -21,3 +21,8 @@
#nameservers
should: %s CLASS(array)
should: %s == []



#response_throttled?
should: %s == false
Expand Up @@ -22,3 +22,8 @@
should: %s CLASS(array)
should: %s SIZE(0)
should: %s == []



#response_throttled?
should: %s == false
Expand Up @@ -29,3 +29,8 @@
should: %s[2].name == "ns3.google.com"
should: %s[3] CLASS(nameserver)
should: %s[3].name == "ns4.google.com"



#response_throttled?
should: %s == false
Expand Up @@ -23,5 +23,9 @@
should: %s == []



#response_throttled?
should: %s == false

#response_unavailable?
should: %s == false
Expand Up @@ -23,5 +23,9 @@
should: %s == []



#response_throttled?
should: %s == false

#response_unavailable?
should: %s == false
Expand Up @@ -33,6 +33,7 @@
should: %s[3].name == "ns4.google.com"



#response_throttled?
should: %s == false

Expand Down
@@ -0,0 +1,29 @@
# encoding: utf-8

# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/kero.yachay.pe/response_throttled.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/kero.yachay.pe.rb'

describe Whois::Record::Parser::KeroYachayPe, "response_throttled.expected" do

subject do
file = fixture("responses", "kero.yachay.pe/response_throttled.txt")
part = Whois::Record::Part.new(:body => File.read(file))
described_class.new(part)
end

describe "#response_throttled?" do
it do
subject.response_throttled?.should == true
end
end
end
Expand Up @@ -57,4 +57,9 @@
subject.nameservers.should == []
end
end
describe "#response_throttled?" do
it do
subject.response_throttled?.should == false
end
end
end
Expand Up @@ -58,4 +58,9 @@
subject.nameservers.should == []
end
end
describe "#response_throttled?" do
it do
subject.response_throttled?.should == false
end
end
end
Expand Up @@ -65,4 +65,9 @@
subject.nameservers[3].name.should == "ns4.google.com"
end
end
describe "#response_throttled?" do
it do
subject.response_throttled?.should == false
end
end
end
Expand Up @@ -62,4 +62,9 @@
subject.response_throttled?.should == false
end
end
describe "#response_unavailable?" do
it do
subject.response_unavailable?.should == false
end
end
end
Expand Up @@ -62,4 +62,9 @@
subject.response_throttled?.should == false
end
end
describe "#response_unavailable?" do
it do
subject.response_unavailable?.should == false
end
end
end

0 comments on commit b73890a

Please sign in to comment.