Permalink
Browse files

Add .MO server and parser.

  • Loading branch information...
weppos committed Sep 19, 2012
1 parent 2574955 commit c9d57097832cb71d3ee1eff8cf2d2a8e4eef07eb
View
@@ -10,6 +10,8 @@
* SERVER: Added .DM TLD server (GH-43).
+* SERVER: Added .MO TLD server.
+
* NEW: Added full whois.register.com parser.
* NEW: whois.networksolutions.com parser now recognizes throttled responses (GH-182). [Thanks @JustinCampbell]
@@ -22,6 +24,8 @@
* NEW: Added full whois.nic.co parser.
+* NEW: Added full whois.monic.mo parser.
+
* FIXED: Fixed whois.register.com parser for enom formats (GH-181). [Thanks @JustinCampbell]
* FIXED: whois.jprs.js parser should support status `Suspended`.
@@ -209,7 +209,7 @@
Whois::Server.define :tld, ".ml", nil, { :adapter => :none }
Whois::Server.define :tld, ".mm", nil, { :adapter => :none }
Whois::Server.define :tld, ".mn", "whois.afilias-grs.info", { :adapter => :afilias }
-Whois::Server.define :tld, ".mo", nil, { :adapter => :web, :url => "http://www.monic.net.mo/" }
+Whois::Server.define :tld, ".mo", "whois.monic.mo"
Whois::Server.define :tld, ".mp", nil, { :adapter => :none }
Whois::Server.define :tld, ".mq", nil, { :adapter => :web, :url => "https://www.dom-enic.com/whois.html" }
Whois::Server.define :tld, ".mr", nil, { :adapter => :none }
@@ -1,12 +1,6 @@
# Scanners
-## Types
-
-- verisign : indented keyvalue with text
-- cnnic : keyvalue
-- biz : keyvalue + lastupdate + disclaimer
-
---
# afilias
@@ -76,7 +76,6 @@ class WhoisCentralnicCom < Base
end
end
-
property_supported :registrant_contacts do
build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
end
@@ -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
@@ -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 == []
@@ -0,0 +1,6 @@
+
+Whois Server Version 1.0
+
+This whois server contains domain data from the MO zone.
+
+No match for "U34JEDZCQ.MO".
@@ -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"
@@ -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
@@ -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.

0 comments on commit c9d5709

Please sign in to comment.