forked from weppos/whois
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
446 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#-- | ||
# Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net> | ||
#++ | ||
|
||
|
||
require 'whois/record/parser/base' | ||
|
||
|
||
module Whois | ||
class Record | ||
class Parser | ||
|
||
# Parser for the whois.monic.mo server. | ||
# | ||
# @see Whois::Record::Parser::Example | ||
# The Example parser for the list of all available methods. | ||
# | ||
class WhoisMonicMo < Base | ||
|
||
property_not_supported :disclaimer | ||
|
||
|
||
property_supported :domain do | ||
if content_for_scanner =~ /Domain Name:\s+(.+)\n/ | ||
$1.downcase | ||
end | ||
end | ||
|
||
property_not_supported :domain_id | ||
|
||
|
||
property_not_supported :referral_whois | ||
|
||
property_not_supported :referral_url | ||
|
||
|
||
property_supported :status do | ||
if available? | ||
:available | ||
else | ||
:registered | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
!!(content_for_scanner =~ /No match for/) | ||
end | ||
|
||
property_supported :registered? do | ||
!available? | ||
end | ||
|
||
|
||
property_not_supported :created_on | ||
|
||
property_not_supported :updated_on | ||
|
||
property_not_supported :expires_on | ||
|
||
|
||
property_supported :registrar do | ||
if content_for_scanner =~ /Registrar:\s+(.+)\n/ | ||
Record::Registrar.new( | ||
:name => $1 | ||
) | ||
end | ||
end | ||
|
||
property_not_supported :registrant_contacts | ||
|
||
property_not_supported :admin_contacts | ||
|
||
property_not_supported :technical_contacts | ||
|
||
|
||
property_supported :nameservers do | ||
content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name| | ||
Record::Nameserver.new(:name => name.downcase) | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
54 changes: 54 additions & 0 deletions
54
spec/fixtures/responses/whois.monic.mo/status_available.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#disclaimer | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#domain | ||
should: %s == nil | ||
|
||
#domain_id | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#referral_whois | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#referral_url | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#status | ||
should: %s == :available | ||
|
||
#available? | ||
should: %s == true | ||
|
||
#registered? | ||
should: %s == false | ||
|
||
|
||
#created_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#updated_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#expires_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#registrar | ||
should: %s == nil | ||
|
||
#registrant_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#admin_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#technical_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#nameservers | ||
should: %s CLASS(array) | ||
should: %s == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
Whois Server Version 1.0 | ||
|
||
This whois server contains domain data from the MO zone. | ||
|
||
No match for "U34JEDZCQ.MO". |
62 changes: 62 additions & 0 deletions
62
spec/fixtures/responses/whois.monic.mo/status_registered.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#disclaimer | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#domain | ||
should: %s == "umac.mo" | ||
|
||
#domain_id | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#referral_whois | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#referral_url | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#status | ||
should: %s == :registered | ||
|
||
#available? | ||
should: %s == false | ||
|
||
#registered? | ||
should: %s == true | ||
|
||
|
||
#created_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#updated_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#expires_on | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#registrar | ||
should: %s CLASS(registrar) | ||
should: %s.id == nil | ||
should: %s.name == "MONIC" | ||
should: %s.organization == nil | ||
should: %s.url == nil | ||
|
||
#registrant_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#admin_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
#technical_contacts | ||
should: %s raise_error(Whois::PropertyNotSupported) | ||
|
||
|
||
#nameservers | ||
should: %s CLASS(array) | ||
should: %s SIZE(2) | ||
should: %s[0] CLASS(nameserver) | ||
should: %s[0].name == "umacsn1.umac.mo" | ||
should: %s[1] CLASS(nameserver) | ||
should: %s[1].name == "umacsn2.umac.mo" |
11 changes: 11 additions & 0 deletions
11
spec/fixtures/responses/whois.monic.mo/status_registered.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
Whois Server Version 1.0 | ||
|
||
This whois server contains domain data from the MO zone. | ||
|
||
Domain Name: UMAC.MO | ||
Registrar: MONIC | ||
Whois Server: whois.monic.mo | ||
Referral URL: http;//www.monic.mo/ | ||
Name Server: UMACSN1.UMAC.MO | ||
Name Server: UMACSN2.UMAC.MO |
105 changes: 105 additions & 0 deletions
105
spec/whois/record/parser/responses/whois.monic.mo/status_available_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# 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/whois.monic.mo/status_available.expected | ||
# | ||
# and regenerate the tests with the following rake task | ||
# | ||
# $ rake spec:generate | ||
# | ||
|
||
require 'spec_helper' | ||
require 'whois/record/parser/whois.monic.mo.rb' | ||
|
||
describe Whois::Record::Parser::WhoisMonicMo, "status_available.expected" do | ||
|
||
subject do | ||
file = fixture("responses", "whois.monic.mo/status_available.txt") | ||
part = Whois::Record::Part.new(:body => File.read(file)) | ||
described_class.new(part) | ||
end | ||
|
||
describe "#disclaimer" do | ||
it do | ||
lambda { subject.disclaimer }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#domain" do | ||
it do | ||
subject.domain.should == nil | ||
end | ||
end | ||
describe "#domain_id" do | ||
it do | ||
lambda { subject.domain_id }.should raise_error(Whois::PropertyNotSupported) | ||
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 == :available | ||
end | ||
end | ||
describe "#available?" do | ||
it do | ||
subject.available?.should == true | ||
end | ||
end | ||
describe "#registered?" do | ||
it do | ||
subject.registered?.should == false | ||
end | ||
end | ||
describe "#created_on" do | ||
it do | ||
lambda { subject.created_on }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#updated_on" do | ||
it do | ||
lambda { subject.updated_on }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#expires_on" do | ||
it do | ||
lambda { subject.expires_on }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#registrar" do | ||
it do | ||
subject.registrar.should == nil | ||
end | ||
end | ||
describe "#registrant_contacts" do | ||
it do | ||
lambda { subject.registrant_contacts }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#admin_contacts" do | ||
it do | ||
lambda { subject.admin_contacts }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#technical_contacts" do | ||
it do | ||
lambda { subject.technical_contacts }.should raise_error(Whois::PropertyNotSupported) | ||
end | ||
end | ||
describe "#nameservers" do | ||
it do | ||
subject.nameservers.should be_a(Array) | ||
subject.nameservers.should == [] | ||
end | ||
end | ||
end |
Oops, something went wrong.