Permalink
Browse files

Merge branch 'whois.nc'

  • Loading branch information...
2 parents b24bee9 + 92e7542 commit df7d9da82378123ab9356553e2ed650e1930665f @weppos committed Mar 16, 2012
View
@@ -12,7 +12,7 @@
* SERVER: Updated ipv4 allocations.
-* SERVER: Added .RS, .LK, .HR (GH-122) TLD server.
+* SERVER: Added .RS, .LK, .HR (GH-122), .NC (GH-109) TLD server.
* NEW: Added full whois.dreamhost.com parser.
@@ -26,6 +26,8 @@
* NEW: Added full whois.dns.hr parser (GH-122).
+* NEW: Added full whois.nc parser (GH-109).
+
* CHANGED: Placed "core_ext" under "whois" namespace (GH-149).
* CHANGED: Whois::Client#query is no longer case sensitive (GH-151).
@@ -221,7 +221,7 @@
Whois::Server.define :tld, ".my", "whois.domainregistry.my"
Whois::Server.define :tld, ".mz", nil, { :adapter => Whois::Server::Adapters::None }
Whois::Server.define :tld, ".na", "whois.na-nic.com.na"
-Whois::Server.define :tld, ".nc", nil, { :web => "http://www.domaine.nc/en/whois.html", :adapter => Whois::Server::Adapters::Web }
+Whois::Server.define :tld, ".nc", "whois.nc"
Whois::Server.define :tld, ".ne", nil, { :adapter => Whois::Server::Adapters::None }
Whois::Server.define :tld, ".nf", "whois.nic.net.nf"
Whois::Server.define :tld, ".ng", "whois.nic.net.ng"
@@ -0,0 +1,48 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/scanners/base'
+
+
+module Whois
+ class Record
+ class Parser
+ module Scanners
+
+ # Scanner for the whois.nc record.
+ #
+ # @since RELEASE
+ class WhoisNc < Base
+
+ self.tokenizers += [
+ :skip_empty_line,
+ :skip_more,
+ :scan_available,
+ :scan_keyvalue,
+ ]
+
+
+ MORES = ['Whois \.NC', 'more details on']
+
+ tokenizer :scan_available do
+ if @input.skip(/^No entries found .+\n/)
+ @ast["status:available"] = true
+ end
+ end
+
+ tokenizer :skip_more do
+ MORES.any? { |more| @input.skip(/^#{more}.*\n/) }
+ end
+
+ end
+
+ end
+ end
+ end
+end
@@ -38,15 +38,15 @@ class WhoisNicHu < Base
# FIXME: Requires UTF-8 Encoding (see #11)
tokenizer :scan_available do
if @input.match?(/Nincs (.*?) \/ No match\n/)
- @input.scan(/Nincs (.*?) \/ No match\n/)
+ @input.skip(/Nincs (.*?) \/ No match\n/)
@ast["status:available"] = true
end
end
# FIXME: Requires UTF-8 Encoding (see #11)
tokenizer :scan_in_progress do
if @input.match?(/(.*?) folyamatban \/ Registration in progress\n/)
- @input.scan(/(.*?) folyamatban \/ Registration in progress\n/)
+ @input.skip(/(.*?) folyamatban \/ Registration in progress\n/)
@ast["status:inprogress"] = true
end
end
@@ -0,0 +1,135 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+require 'whois/record/parser/scanners/whois.nc.rb'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.nc server.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ #
+ # @since RELEASE
+ class WhoisNc < Base
+ include Scanners::Ast
+
+ property_not_supported :disclaimer
+
+
+ property_supported :domain do
+ node("Domain")
+ 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
+ !!node("status:available")
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+
+ property_supported :created_on do
+ node("Created on") { |value| Time.parse(value) }
+ end
+
+ property_supported :updated_on do
+ node("Last updated on") { |value| Time.parse(value) }
+ end
+
+ property_supported :expires_on do
+ node("Expires on") { |value| Time.parse(value) }
+ end
+
+
+ property_not_supported :registrar
+
+
+ property_supported :registrant_contacts do
+ node("Registrant name") do |str|
+ address = []
+ index = 1
+ while line = node("Registrant address #{index}")
+ address << line
+ index += 1
+ end
+
+ zip, city = address[-2].match(/(\d+) (.+)/)[1, 2]
+
+ Record::Contact.new(
+ :type => Whois::Record::Contact::TYPE_REGISTRANT,
+ :id => nil,
+ :name => node("Registrant name"),
+ :organization => nil,
+ :address => address[0..-3].join("\n"),
+ :city => city,
+ :zip => zip,
+ :state => nil,
+ :country => address[-1],
+ :phone => nil,
+ :fax => nil,
+ :email => nil
+ )
+ end
+ end
+
+ property_not_supported :admin_contacts
+
+ property_not_supported :technical_contacts
+
+
+ property_supported :nameservers do
+ nameservers = []
+ index = 1
+ while line = node("Domain server #{index}")
+ nameservers << line
+ index += 1
+ end
+
+ nameservers.map do |name|
+ Record::Nameserver.new(:name => name)
+ end
+ end
+
+
+ # Initializes a new {Scanners::WhoisNc} instance
+ # passing the {#content_for_scanner}
+ # and calls +parse+ on it.
+ #
+ # @return [Hash]
+ def parse
+ Scanners::WhoisNc.new(content_for_scanner).parse
+ end
+
+ end
+
+ end
+ end
+end
@@ -0,0 +1,55 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#domain
+ should: %s == nil
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#status
+ should: %s == :available
+
+#available?
+ should: %s == true
+
+#registered?
+ should: %s == false
+
+
+#created_on
+ should: %s == nil
+
+#updated_on
+ should: %s == nil
+
+#expires_on
+ should: %s == nil
+
+
+#registrar
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s == []
+
+#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 .NC
+
+No entries found in the .nc database
+
+more details on http://www.whois.nc
@@ -0,0 +1,76 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#domain
+ should: %s == "domaine.nc"
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#status
+ should: %s == :registered
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+
+#created_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2006-05-14")
+
+#updated_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2012-02-13")
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2016-05-14")
+
+
+#registrar
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#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].name == "CCTLD"
+ should: %s[0].organization == nil
+ should: %s[0].address == "1 RUE MONCHOVET\n7 EME ETAGE\nLE WARUNA 1"
+ should: %s[0].city == "NOUMEA CEDEX"
+ should: %s[0].zip == "98841"
+ should: %s[0].state == nil
+ should: %s[0].country == "NEW CALEDONIA"
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#admin_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#technical_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(3)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "any-ns1.nc"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "ns1.nc"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "ns2.nc"
@@ -0,0 +1,24 @@
+
+Whois .NC
+
+Domain : domaine.nc
+Created on : 2006-05-14
+Expires on : 2016-05-14
+Last updated on : 2012-02-13
+
+Domain server 1 : any-ns1.nc
+Domain server 2 : ns1.nc
+Domain server 3 : ns2.nc
+
+Registrant name : CCTLD
+Registrant type : Societe (CCTLD.NC)
+Registrant address 1 : 1 RUE MONCHOVET
+Registrant address 2 : 7 EME ETAGE
+Registrant address 3 : LE WARUNA 1
+Registrant address 4 : 98841 NOUMEA CEDEX
+Registrant address 5 : NEW CALEDONIA
+
+Contact firstname : Pascal
+Contact lastname : Schiavo
+
+more details on http://www.whois.nc
Oops, something went wrong.

0 comments on commit df7d9da

Please sign in to comment.