Skip to content

Commit

Permalink
Added full whois.nic.co parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Sep 19, 2012
1 parent cb7f380 commit c442604
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,8 @@

* NEW: Added full whois.nic.dm parser (GH-43).

* NEW: Added full whois.nic.co parser.

* FIXED: Fixed whois.register.com parser for enom formats (GH-181). [Thanks @JustinCampbell]

* FIXED: whois.jprs.js parser should support status `Suspended`.
Expand Down
7 changes: 6 additions & 1 deletion lib/whois/record/parser/base_shared2.rb
Expand Up @@ -113,12 +113,17 @@ def parse

def build_contact(element, type)
node("#{element} ID") do |str|
address = (1..3).
map { |i| node("#{element} Address#{i}") }.
delete_if(&:nil?).
join("\n")

Record::Contact.new(
:type => type,
:id => node("#{element} ID"),
:name => node("#{element} Name"),
:organization => node("#{element} Organization"),
:address => node("#{element} Address1"),
:address => address,
:city => node("#{element} City"),
:zip => node("#{element} Postal Code"),
:state => node("#{element} State/Province"),
Expand Down
30 changes: 30 additions & 0 deletions spec/fixtures/responses/whois.nic.co/status_available.expected
@@ -1,3 +1,17 @@
#domain
should: %s == "u34jedzcq.co"

#domain_id
should: %s == nil


#referral_whois
should: %s raise_error(Whois::PropertyNotSupported)

#referral_url
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == nil

Expand All @@ -18,6 +32,22 @@
should: %s == nil


#registrar
should: %s == nil

#registrant_contacts
should: %s CLASS(array)
should: %s == []

#admin_contacts
should: %s CLASS(array)
should: %s == []

#technical_contacts
should: %s CLASS(array)
should: %s == []


#nameservers
should: %s CLASS(array)
should: %s == []
75 changes: 75 additions & 0 deletions spec/fixtures/responses/whois.nic.co/status_registered.expected
@@ -1,3 +1,17 @@
#domain
should: %s == "t.co"

#domain_id
should: %s == "D740225-CO"


#referral_whois
should: %s raise_error(Whois::PropertyNotSupported)

#referral_url
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == ["serverDeleteProhibited", "serverTransferProhibited"]

Expand All @@ -20,6 +34,67 @@
should: %s CLASS(time)
should: %s == Time.parse("2013-04-25 23:59:59 UTC")


#registrar
should: %s CLASS(registrar)
should: %s.id == "13"
should: %s.name == "MELBOURNE IT LTD"

#registrant_contacts
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
should: %s[0].id == "TWITTERREG2012"
should: %s[0].name == "Twitter, Inc."
should: %s[0].organization == "Twitter, Inc."
should: %s[0].address == "1355 Market Street\nSuite 900"
should: %s[0].city == "San Francisco"
should: %s[0].zip == "94103"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.4152229670"
should: %s[0].fax == "+1.4152220922"
should: %s[0].email == "domains@twitter.com"

#admin_contacts
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
should: %s[0].id == "TWITTERADMIN2012"
should: %s[0].name == "Domain Admin"
should: %s[0].organization == "Twitter, Inc."
should: %s[0].address == "1355 Market Street\nSuite 900"
should: %s[0].city == "San Francisco"
should: %s[0].zip == "94103"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.4152229670"
should: %s[0].fax == "+1.4152220922"
should: %s[0].email == "domains@twitter.com"

#technical_contacts
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
should: %s[0].id == "TWITTERTECH2012"
should: %s[0].name == "Tech Admin"
should: %s[0].organization == "Twitter, Inc."
should: %s[0].address == "1355 Market Street\nSuite 900"
should: %s[0].city == "San Francisco"
should: %s[0].zip == "94103"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.4152229670"
should: %s[0].fax == "+1.4152220922"
should: %s[0].email == "domains-tech@twitter.com"


#nameservers
should: %s CLASS(array)
should: %s SIZE(4)
Expand Down
Expand Up @@ -21,6 +21,26 @@
described_class.new(part)
end

describe "#domain" do
it do
subject.domain.should == "u34jedzcq.co"
end
end
describe "#domain_id" do
it do
subject.domain_id.should == nil
end
end
describe "#referral_whois" do
it do
lambda { subject.referral_whois }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#referral_url" do
it do
lambda { subject.referral_url }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#status" do
it do
subject.status.should == nil
Expand Down Expand Up @@ -51,6 +71,29 @@
subject.expires_on.should == nil
end
end
describe "#registrar" do
it do
subject.registrar.should == nil
end
end
describe "#registrant_contacts" do
it do
subject.registrant_contacts.should be_a(Array)
subject.registrant_contacts.should == []
end
end
describe "#admin_contacts" do
it do
subject.admin_contacts.should be_a(Array)
subject.admin_contacts.should == []
end
end
describe "#technical_contacts" do
it do
subject.technical_contacts.should be_a(Array)
subject.technical_contacts.should == []
end
end
describe "#nameservers" do
it do
subject.nameservers.should be_a(Array)
Expand Down
Expand Up @@ -21,6 +21,26 @@
described_class.new(part)
end

describe "#domain" do
it do
subject.domain.should == "t.co"
end
end
describe "#domain_id" do
it do
subject.domain_id.should == "D740225-CO"
end
end
describe "#referral_whois" do
it do
lambda { subject.referral_whois }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#referral_url" do
it do
lambda { subject.referral_url }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#status" do
it do
subject.status.should == ["serverDeleteProhibited", "serverTransferProhibited"]
Expand Down Expand Up @@ -54,6 +74,73 @@
subject.expires_on.should == Time.parse("2013-04-25 23:59:59 UTC")
end
end
describe "#registrar" do
it do
subject.registrar.should be_a(Whois::Record::Registrar)
subject.registrar.id.should == "13"
subject.registrar.name.should == "MELBOURNE IT LTD"
end
end
describe "#registrant_contacts" do
it do
subject.registrant_contacts.should be_a(Array)
subject.registrant_contacts.should have(1).items
subject.registrant_contacts[0].should be_a(Whois::Record::Contact)
subject.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
subject.registrant_contacts[0].id.should == "TWITTERREG2012"
subject.registrant_contacts[0].name.should == "Twitter, Inc."
subject.registrant_contacts[0].organization.should == "Twitter, Inc."
subject.registrant_contacts[0].address.should == "1355 Market Street\nSuite 900"
subject.registrant_contacts[0].city.should == "San Francisco"
subject.registrant_contacts[0].zip.should == "94103"
subject.registrant_contacts[0].state.should == "CA"
subject.registrant_contacts[0].country.should == "United States"
subject.registrant_contacts[0].country_code.should == "US"
subject.registrant_contacts[0].phone.should == "+1.4152229670"
subject.registrant_contacts[0].fax.should == "+1.4152220922"
subject.registrant_contacts[0].email.should == "domains@twitter.com"
end
end
describe "#admin_contacts" do
it do
subject.admin_contacts.should be_a(Array)
subject.admin_contacts.should have(1).items
subject.admin_contacts[0].should be_a(Whois::Record::Contact)
subject.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
subject.admin_contacts[0].id.should == "TWITTERADMIN2012"
subject.admin_contacts[0].name.should == "Domain Admin"
subject.admin_contacts[0].organization.should == "Twitter, Inc."
subject.admin_contacts[0].address.should == "1355 Market Street\nSuite 900"
subject.admin_contacts[0].city.should == "San Francisco"
subject.admin_contacts[0].zip.should == "94103"
subject.admin_contacts[0].state.should == "CA"
subject.admin_contacts[0].country.should == "United States"
subject.admin_contacts[0].country_code.should == "US"
subject.admin_contacts[0].phone.should == "+1.4152229670"
subject.admin_contacts[0].fax.should == "+1.4152220922"
subject.admin_contacts[0].email.should == "domains@twitter.com"
end
end
describe "#technical_contacts" do
it do
subject.technical_contacts.should be_a(Array)
subject.technical_contacts.should have(1).items
subject.technical_contacts[0].should be_a(Whois::Record::Contact)
subject.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
subject.technical_contacts[0].id.should == "TWITTERTECH2012"
subject.technical_contacts[0].name.should == "Tech Admin"
subject.technical_contacts[0].organization.should == "Twitter, Inc."
subject.technical_contacts[0].address.should == "1355 Market Street\nSuite 900"
subject.technical_contacts[0].city.should == "San Francisco"
subject.technical_contacts[0].zip.should == "94103"
subject.technical_contacts[0].state.should == "CA"
subject.technical_contacts[0].country.should == "United States"
subject.technical_contacts[0].country_code.should == "US"
subject.technical_contacts[0].phone.should == "+1.4152229670"
subject.technical_contacts[0].fax.should == "+1.4152220922"
subject.technical_contacts[0].email.should == "domains-tech@twitter.com"
end
end
describe "#nameservers" do
it do
subject.nameservers.should be_a(Array)
Expand Down

0 comments on commit c442604

Please sign in to comment.