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
Mikkel Mondrup Kristensen
authored and
Mikkel Mondrup Kristensen
committed
Jan 11, 2010
1 parent
a67969e
commit bd53e07
Showing
6 changed files
with
199 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# | ||
# = Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# | ||
# Category:: Net | ||
# Package:: Whois | ||
# Author:: Mikkel Kristensen <mikkel@tdx.dk>, Simone Carletti <weppos@weppos.net> | ||
# License:: MIT License | ||
# | ||
#-- | ||
# | ||
#++ | ||
|
||
|
||
require 'whois/answer/parser/base' | ||
|
||
|
||
module Whois | ||
class Answer | ||
class Parser | ||
|
||
# | ||
# = whois.nic.nu | ||
# | ||
# Parser for the whois.nic.nu server. | ||
# | ||
# NOTE: This parser is just a stub and provides only a few basic methods | ||
# to check for domain availability and get domain status. | ||
# Please consider to contribute implementing missing methods. | ||
# See WhoisNicIt parser for an explanation of all available methods | ||
# and examples. | ||
# | ||
class WhoisNicNu < Base | ||
|
||
property_supported :status do | ||
@status ||= if content.to_s =~ /Record status:\s+(.*)\n/ | ||
$1.downcase.to_sym | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
@available ||= !!(content.to_s =~ /NO MATCH for domain/) | ||
end | ||
|
||
property_supported :registered? do | ||
!available? | ||
end | ||
|
||
|
||
property_supported :created_on do | ||
@created_on ||= if content.to_s =~ /Record created on (.*).\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_not_supported :updated_on | ||
|
||
property_supported :expires_on do | ||
@expires_on ||= if content.to_s =~ /Record expires on (.*).\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :updated_on do | ||
@updated_on ||= if content.to_s =~ /Record last updated on (.*?).\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :nameservers do | ||
@nameservers ||= content.to_s.scan(/Domain servers in listed order:(.*)Owner and Administrative Contact information for domains/m).to_s.split || [] | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
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,59 @@ | ||
require 'test_helper' | ||
require 'whois/answer/parser/whois.nic.nu.rb' | ||
|
||
class AnswerParserWhoisNicNuTest < Whois::Answer::Parser::TestCase | ||
|
||
def setup | ||
@klass = Whois::Answer::Parser::WhoisNicNu | ||
@host = "whois.nic.nu" | ||
end | ||
|
||
|
||
def test_status | ||
assert_equal :active, | ||
@klass.new(load_part('/registered.txt')).status | ||
assert_equal nil, | ||
@klass.new(load_part('/available.txt')).status | ||
end | ||
|
||
def test_available? | ||
assert !@klass.new(load_part('/registered.txt')).available? | ||
assert @klass.new(load_part('/available.txt')).available? | ||
end | ||
|
||
def test_registered? | ||
assert @klass.new(load_part('/registered.txt')).registered? | ||
assert !@klass.new(load_part('/available.txt')).registered? | ||
end | ||
|
||
|
||
def test_created_on | ||
assert_equal Time.parse("1999-06-07"), | ||
@klass.new(load_part('/registered.txt')).created_on | ||
assert_equal nil, | ||
@klass.new(load_part('/available.txt')).created_on | ||
end | ||
|
||
def test_updated_on | ||
assert_equal Time.parse("2009-05-11"), | ||
@klass.new(load_part('/registered.txt')).updated_on | ||
assert_equal nil, | ||
@klass.new(load_part('/available.txt')).updated_on | ||
end | ||
|
||
def test_expires_on | ||
assert_equal Time.parse("2010-06-07"), | ||
@klass.new(load_part('/registered.txt')).expires_on | ||
assert_equal nil, | ||
@klass.new(load_part('/available.txt')).expires_on | ||
end | ||
|
||
|
||
def test_nameservers | ||
assert_equal %w(ns1.google.com ns2.google.com ns3.google.com ns4.google.com), | ||
@klass.new(load_part('/registered.txt')).nameservers | ||
assert_equal %w(), | ||
@klass.new(load_part('/available.txt')).nameservers | ||
end | ||
|
||
end |
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,19 @@ | ||
------------------------------------------------------------------------ | ||
Database last updated: 2010-Jan-08 15:01:41 GMT | ||
------------------------------------------------------------------------ | ||
Galba:~ mmk$ whois u34jedzcq.nu | ||
------------------------------------------------------------------------ | ||
.NU Domain Ltd Whois service | ||
|
||
NO MATCH for domain "u34jedzcq.nu" (ASCII): | ||
|
||
Visit http://www.nunames.nu to determine if this domain has been | ||
registered within the last 48 hours. | ||
|
||
Owner and Administrative Contact information for domains | ||
registered in .nu is available upon request from support@nic.nu | ||
|
||
Copyright by .NU Domain Ltd - http://www.nunames.nu | ||
------------------------------------------------------------------------ | ||
Database last updated: 2010-Jan-08 15:01:41 GMT | ||
------------------------------------------------------------------------ |
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,35 @@ | ||
------------------------------------------------------------------------ | ||
.NU Domain Ltd Whois service | ||
|
||
Domain Name (ASCII): google.nu | ||
|
||
Technical Contact: | ||
Domain Administrator dns-admin@google.com | ||
Google, Inc. | ||
1600 Amphitheatre Parkway | ||
Mountain View | ||
CA 94043 | ||
US | ||
Phone: +1 650 318 0200 (voice) +1 650 618 1499 (fax) | ||
|
||
Record last updated on 11-May-2009. | ||
Record expires on 07-Jun-2010. | ||
Record created on 07-Jun-1999. | ||
Record status: Active | ||
Registrar of record: eMarkMonitor, Inc. | ||
ReferralServer: whois://whois.markmonitor.com | ||
Referral URL: http://www.markmonitor.com | ||
|
||
Domain servers in listed order: | ||
ns1.google.com | ||
ns2.google.com | ||
ns3.google.com | ||
ns4.google.com | ||
|
||
Owner and Administrative Contact information for domains | ||
registered in .nu is available upon request from support@nic.nu | ||
|
||
Copyright by .NU Domain Ltd - http://www.nunames.nu | ||
------------------------------------------------------------------------ | ||
Database last updated: 2010-Jan-08 15:01:41 GMT | ||
------------------------------------------------------------------------ |