Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

kero.yachay.pe parser now recognizes throttled responses

  • Loading branch information...
commit b73890a0cae8575321bc01849b123cf045c8efe7 1 parent 5150894
Simone Carletti authored
Showing with 128 additions and 18 deletions.
  1. +3 −1 CHANGELOG.md
  2. +27 −17 lib/whois/record/parser/kero.yachay.pe.rb
  3. +2 −0  spec/fixtures/responses/kero.yachay.pe/response_throttled.expected
  4. +18 −0 spec/fixtures/responses/kero.yachay.pe/response_throttled.txt
  5. +5 −0 spec/fixtures/responses/kero.yachay.pe/status_available.expected
  6. +5 −0 spec/fixtures/responses/kero.yachay.pe/status_inactive.expected
  7. +5 −0 spec/fixtures/responses/kero.yachay.pe/status_registered.expected
  8. +4 −0 spec/fixtures/responses/whois.domain-registry.nl/status_available.expected
  9. +4 −0 spec/fixtures/responses/whois.domain-registry.nl/status_redemption.expected
  10. +1 −0  spec/fixtures/responses/whois.domain-registry.nl/status_registered.expected
  11. +29 −0 spec/whois/record/parser/responses/kero.yachay.pe/response_throttled_spec.rb
  12. +5 −0 spec/whois/record/parser/responses/kero.yachay.pe/status_available_spec.rb
  13. +5 −0 spec/whois/record/parser/responses/kero.yachay.pe/status_inactive_spec.rb
  14. +5 −0 spec/whois/record/parser/responses/kero.yachay.pe/status_registered_spec.rb
  15. +5 −0 spec/whois/record/parser/responses/whois.domain-registry.nl/status_available_spec.rb
  16. +5 −0 spec/whois/record/parser/responses/whois.domain-registry.nl/status_redemption_spec.rb
4 CHANGELOG.md
View
@@ -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
44 lib/whois/record/parser/kero.yachay.pe.rb
View
@@ -14,30 +14,28 @@ 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.")
@@ -45,7 +43,7 @@ class KeroYachayPe < Base
end
property_supported :available? do
- (status == :available)
+ status == :available
end
property_supported :registered? do
@@ -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
2  spec/fixtures/responses/kero.yachay.pe/response_throttled.expected
View
@@ -0,0 +1,2 @@
+#response_throttled?
+ should: %s == true
18 spec/fixtures/responses/kero.yachay.pe/response_throttled.txt
View
@@ -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.
5 spec/fixtures/responses/kero.yachay.pe/status_available.expected
View
@@ -21,3 +21,8 @@
#nameservers
should: %s CLASS(array)
should: %s == []
+
+
+
+#response_throttled?
+ should: %s == false
5 spec/fixtures/responses/kero.yachay.pe/status_inactive.expected
View
@@ -22,3 +22,8 @@
should: %s CLASS(array)
should: %s SIZE(0)
should: %s == []
+
+
+
+#response_throttled?
+ should: %s == false
5 spec/fixtures/responses/kero.yachay.pe/status_registered.expected
View
@@ -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
4 spec/fixtures/responses/whois.domain-registry.nl/status_available.expected
View
@@ -23,5 +23,9 @@
should: %s == []
+
#response_throttled?
should: %s == false
+
+#response_unavailable?
+ should: %s == false
4 spec/fixtures/responses/whois.domain-registry.nl/status_redemption.expected
View
@@ -23,5 +23,9 @@
should: %s == []
+
#response_throttled?
should: %s == false
+
+#response_unavailable?
+ should: %s == false
1  spec/fixtures/responses/whois.domain-registry.nl/status_registered.expected
View
@@ -33,6 +33,7 @@
should: %s[3].name == "ns4.google.com"
+
#response_throttled?
should: %s == false
29 spec/whois/record/parser/responses/kero.yachay.pe/response_throttled_spec.rb
View
@@ -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
5 spec/whois/record/parser/responses/kero.yachay.pe/status_available_spec.rb
View
@@ -57,4 +57,9 @@
subject.nameservers.should == []
end
end
+ describe "#response_throttled?" do
+ it do
+ subject.response_throttled?.should == false
+ end
+ end
end
5 spec/whois/record/parser/responses/kero.yachay.pe/status_inactive_spec.rb
View
@@ -58,4 +58,9 @@
subject.nameservers.should == []
end
end
+ describe "#response_throttled?" do
+ it do
+ subject.response_throttled?.should == false
+ end
+ end
end
5 spec/whois/record/parser/responses/kero.yachay.pe/status_registered_spec.rb
View
@@ -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
5 spec/whois/record/parser/responses/whois.domain-registry.nl/status_available_spec.rb
View
@@ -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
5 spec/whois/record/parser/responses/whois.domain-registry.nl/status_redemption_spec.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.