forked from weppos/whois
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whois.publicdomainregistry.com.rb
102 lines (84 loc) · 2.86 KB
/
whois.publicdomainregistry.com.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#--
# 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.publicdomainregistry.com server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
# @author Justin Campbell <justin@cramerdev.me>
#
class WhoisPublicdomainregistryCom < Base
property_supported(:status) { :registered }
property_supported(:available?) { false }
property_supported(:registered?) { true }
property_supported(:updated_on) { nil }
property_supported :created_on do
if content_for_scanner =~ /Creation Date: (.+)$/
Time.parse($1)
end
end
property_supported :expires_on do
if content_for_scanner =~ /Expiration Date: (.+)$/
Time.parse($1)
end
end
property_supported :registrar do
Record::Registrar.new(
:name => "PublicDomainRegistry.com",
:organization => "Directi Internet Solutions Pvt. Ltd.",
:url => "http://publicdomainregistry.com"
)
end
property_supported :registrant_contacts do
build_contact('Registrant', Record::Contact::TYPE_REGISTRANT)
end
property_supported :admin_contacts do
build_contact('Administrative Contact', Record::Contact::TYPE_ADMIN)
end
property_supported :technical_contacts do
build_contact('Technical Contact', Record::Contact::TYPE_TECHNICAL)
end
property_supported :nameservers do
if content_for_scanner =~ /Domain servers in listed order:\n((?:[^\n]+\n)+)/
$1.split("\n").map do |line|
Record::Nameserver.new(:name => line.strip.downcase)
end
end
end
private
def build_contact(element, type)
content_match = content_for_scanner.match(/#{element}\:\n((\s+.*){4,9})/)
return unless content_match
contact = content_match[1]
return unless contact
contact = contact.lines.map(&:strip).join("\n")
match = contact.match(/
(?<organization>.+)\n
(?<name>.+)\s+\((?<email>.+@.+)\)\n
(?<address>(.|\n)+)\n
(?<city>.+)\n
(?<state>.+),(?<zip>.+)\n
(?<country_code>.+)\n?
(Tel\. (?<phone>.+)\n?)?
(Fax\. (?<fax>.+)\n?)?
/x)
return unless match
attributes = { :type => type }
match.names.each do |name|
attributes[name.to_sym] = match[name].strip if match[name]
end
Record::Contact.new attributes
end
end
end
end
end