Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple .ps TLD parser (whois.pnina.ps).
- Loading branch information
Showing
7 changed files
with
213 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# = Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# | ||
# Category:: Net | ||
# Package:: Whois | ||
# Author:: Simone Carletti <weppos@weppos.net> | ||
# License:: MIT License | ||
# | ||
#-- | ||
# | ||
#++ | ||
|
||
|
||
require 'whois/answer/parser/base' | ||
|
||
|
||
module Whois | ||
class Answer | ||
class Parser | ||
|
||
# | ||
# = whois.pnina.ps parser | ||
# | ||
# Parser for the whois.pnina.ps 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 WhoisPninaPs < Base | ||
|
||
property_supported :status do | ||
@status ||= if content_for_scanner =~ /Status:\s+(.+?)\n/ | ||
case $1.downcase | ||
when "active" then :registered | ||
when "not registered" then :available | ||
else | ||
Whois.bug!(ParserError, "Unknown status `#{$1}'.") | ||
end | ||
else | ||
Whois.bug!(ParserError, "Unable to parse status.") | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
@available ||= (status == :available) | ||
end | ||
|
||
property_supported :registered? do | ||
@registered ||= !available? | ||
end | ||
|
||
|
||
property_supported :created_on do | ||
@created_on ||= if content_for_scanner =~ /Created:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_not_supported :updated_on | ||
|
||
property_supported :expires_on do | ||
@expires_on ||= if content_for_scanner =~ /Expires:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
|
||
property_supported :nameservers do | ||
@nameservers ||= if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n/ | ||
$1.split("\n").map(&:strip) | ||
else | ||
[] | ||
end | ||
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,10 @@ | ||
TERMS OF USE: You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated. Whois database is provided by PNINA as a service to the internet community on behalf of PNINA members. (http://www.pnina.ps/) | ||
|
||
The data is for information purposes only. PNINA does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to PNINA and it's registrars (or PNINA or registrars computer systems). The compilation, repackaging, dissemination or other use of this Data is expressly prohibited. | ||
|
||
Domain Information | ||
Query: u34jedzcq.ps | ||
Status: Not Registered | ||
|
||
|
||
|
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,20 @@ | ||
TERMS OF USE: You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated. Whois database is provided by PNINA as a service to the internet community on behalf of PNINA members. (http://www.pnina.ps/) | ||
|
||
The data is for information purposes only. PNINA does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to PNINA and it's registrars (or PNINA or registrars computer systems). The compilation, repackaging, dissemination or other use of this Data is expressly prohibited. | ||
|
||
Domain Information | ||
Query: google.ps | ||
Status: Active | ||
Created: 19 May 2004 | ||
Expires: 19 May 2011 | ||
Name Servers: | ||
ns1.google.com | ||
ns2.google.com | ||
ns3.google.com | ||
|
||
Registrar Information | ||
Registrar Name: eMarkMonitor | ||
|
||
|
||
|
||
|
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,91 @@ | ||
require 'test_helper' | ||
require 'whois/answer/parser/whois.pnina.ps' | ||
|
||
class AnswerParserWhoisPninaPsTest < Whois::Answer::Parser::TestCase | ||
|
||
def setup | ||
@klass = Whois::Answer::Parser::WhoisPninaPs | ||
@host = "whois.pnina.ps" | ||
end | ||
|
||
|
||
def test_status | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = :registered | ||
assert_equal expected, parser.status | ||
assert_equal expected, parser.instance_eval { @status } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = :available | ||
assert_equal expected, parser.status | ||
assert_equal expected, parser.instance_eval { @status } | ||
end | ||
|
||
def test_available? | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = false | ||
assert_equal expected, parser.available? | ||
assert_equal expected, parser.instance_eval { @available } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = true | ||
assert_equal expected, parser.available? | ||
assert_equal expected, parser.instance_eval { @available } | ||
end | ||
|
||
def test_registered? | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = true | ||
assert_equal expected, parser.registered? | ||
assert_equal expected, parser.instance_eval { @registered } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = false | ||
assert_equal expected, parser.registered? | ||
assert_equal expected, parser.instance_eval { @registered } | ||
end | ||
|
||
|
||
def test_created_on | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = Time.parse("2004-05-19") | ||
assert_equal expected, parser.created_on | ||
assert_equal expected, parser.instance_eval { @created_on } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = nil | ||
assert_equal expected, parser.created_on | ||
assert_equal expected, parser.instance_eval { @created_on } | ||
end | ||
|
||
def test_updated_on | ||
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/registered.txt')).updated_on } | ||
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/available.txt')).updated_on } | ||
end | ||
|
||
def test_expires_on | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = Time.parse("2011-05-19") | ||
assert_equal expected, parser.expires_on | ||
assert_equal expected, parser.instance_eval { @expires_on } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = nil | ||
assert_equal expected, parser.expires_on | ||
assert_equal expected, parser.instance_eval { @expires_on } | ||
end | ||
|
||
|
||
def test_nameservers | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = %w( ns1.google.com ns2.google.com ns3.google.com ) | ||
assert_equal expected, parser.nameservers | ||
assert_equal expected, parser.instance_eval { @nameservers } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = %w() | ||
assert_equal expected, parser.nameservers | ||
assert_equal expected, parser.instance_eval { @nameservers } | ||
end | ||
|
||
end |