Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

support 'domain' and 'registrar' properties on whois.dns.be.rb (now with tests) #216

Merged
merged 3 commits into from

2 participants

@chuckadams

As before, supporting the "domain" and "registrar" properties, plus tests added -- I piggybacked them on the status_registered.expected tests since it seems to contain a general list of other properties it tests as well.

lib/whois/record/parser/whois.dns.be.rb
@@ -76,6 +76,17 @@ class WhoisDnsBe < Base
end
+ property_supported :domain do
+ content_for_scanner.slice(/Domain:\s*(.+?)\n/, 1)
+ end
+
+ property_supported :registrar do
+ name = content_for_scanner.slice(/Registrar:\s+Name:(.+?)\s*Website:(.+?)\n/, 1)
+ url = content_for_scanner.slice(/Registrar:\s+Name:(.+?)\s*Website:(.+?)\n/, 2)
@weppos Owner
weppos added a note

Since the match is the same, I would suggest something like

if (match = content_for_scanner.match(/Registrar:\s+Name:(.+?)\s*Website:(.+?)\n/))
  name, url = match.to_a[1..2]
  Record::Registrar.new(name: name.strip, url: url.strip)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weppos
Owner

Hey @chuckadams, this is great! Can I ask you one more favor? Please also make sure to add the tests for status_available.expected so that we are sure the parser won't crash in case the domain is available.

@weppos
Owner

I'll leave this PR open so that you can push the changes to your branch and it will update automatically.

@chuckadams

That certainly is a better regex match -- I'm something of a novice in ruby (perl guy mostly) so I wasn't quite up to speed on ruby's matching API, and cargo-culted it from other parsers. :) I made the matcher change and added the extra tests.

@weppos weppos was assigned
@weppos weppos merged commit 8ac343d into from
@weppos
Owner

Merged, thank you!

@weppos weppos referenced this pull request from a commit
@weppos Preserve property order (GH-216) 4389e35
@weppos weppos referenced this pull request from a commit
@weppos CHANGELOG for GH-216 994c70a
@weppos
Owner

@chuckadams I committed a small change, however the patch was great! Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 29, 2013
  1. better registrar matching regex

    Chuck Adams authored
  2. domain+registrar tests for nonexistent .be domain

    Chuck Adams authored
This page is out of date. Refresh to see the latest.
View
12 lib/whois/record/parser/whois.dns.be.rb
@@ -76,6 +76,18 @@ class WhoisDnsBe < Base
end
+ property_supported :domain do
+ content_for_scanner.slice(/Domain:\s*(.+?)\n/, 1)
+ end
+
+ property_supported :registrar do
+ if (match = content_for_scanner.match(/Registrar:\s+Name:(.+?)\s*Website:(.+?)\n/))
+ name, url = match.to_a[1..2]
+ Record::Registrar.new(name: name.strip, url: url.strip)
+ end
+ end
+
+
# Checks whether the response has been throttled.
#
# @return [Boolean]
View
6 spec/fixtures/responses/whois.dns.be/status_available.expected
@@ -1,3 +1,6 @@
+#domain
+ should: %s == "u34jedzcq.be"
+
#status
should: %s == :available
@@ -21,3 +24,6 @@
#nameservers
should: %s CLASS(array)
should: %s == []
+
+#registrar
+ should: %s == nil
View
9 spec/fixtures/responses/whois.dns.be/status_registered.expected
@@ -1,3 +1,6 @@
+#domain
+ should: %s == "google.be"
+
#status
should: %s == :registered
@@ -30,3 +33,9 @@
should: %s[2].name == "ns1.google.com"
should: %s[3] CLASS(nameserver)
should: %s[3].name == "ns2.google.com"
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == nil
+ should: %s.name == "MarkMonitor"
+ should: %s.url == "http://www.markmonitor.com"
View
10 spec/whois/record/parser/responses/whois.dns.be/status_available_spec.rb
@@ -21,6 +21,11 @@
described_class.new(part)
end
+ describe "#domain" do
+ it do
+ subject.domain.should == "u34jedzcq.be"
+ end
+ end
describe "#status" do
it do
subject.status.should == :available
@@ -57,4 +62,9 @@
subject.nameservers.should == []
end
end
+ describe "#registrar" do
+ it do
+ subject.registrar.should == nil
+ end
+ end
end
View
13 spec/whois/record/parser/responses/whois.dns.be/status_registered_spec.rb
@@ -21,6 +21,11 @@
described_class.new(part)
end
+ describe "#domain" do
+ it do
+ subject.domain.should == "google.be"
+ end
+ end
describe "#status" do
it do
subject.status.should == :registered
@@ -66,4 +71,12 @@
subject.nameservers[3].name.should == "ns2.google.com"
end
end
+ describe "#registrar" do
+ it do
+ subject.registrar.should be_a(Whois::Record::Registrar)
+ subject.registrar.id.should == nil
+ subject.registrar.name.should == "MarkMonitor"
+ subject.registrar.url.should == "http://www.markmonitor.com"
+ end
+ end
end
Something went wrong with that request. Please try again.