Skip to content

Commit

Permalink
Add whois.uniregistry.net parser
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Mar 10, 2014
1 parent 6c78652 commit db8240e
Show file tree
Hide file tree
Showing 13 changed files with 705 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,8 @@

- NEW: Added whois.donuts.co parser.

- NEW: Added whois.uniregistry.net parser.

- CHANGED: Updated whois.nic.net.sa parser to the new response format.

- CHANGED: Updated whois.nic.cz parser to the new response format.
Expand Down
4 changes: 3 additions & 1 deletion lib/whois/core_ext.rb
Expand Up @@ -6,4 +6,6 @@
require 'whois/core_ext/array/wrap'
require 'whois/core_ext/class/attribute'
require 'whois/core_ext/object/blank'
end
end

require 'whois/core_ext/time/calculations'
32 changes: 32 additions & 0 deletions lib/whois/core_ext/time/calculations.rb
@@ -0,0 +1,32 @@
class Time

# Returns a new Time where one or more of the elements have been changed according
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
# <tt>:sec</tt>, <tt>:usec</tt>) reset cascadingly, so if only the hour is passed,
# then minute, sec, and usec is set to 0. If the hour and minute is passed, then
# sec and usec is set to 0. The +options+ parameter takes a hash with any of these
# keys: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:min</tt>,
# <tt>:sec</tt>, <tt>:usec</tt>.
#
# Time.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => Time.new(2012, 8, 1, 22, 35, 0)
# Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => Time.new(1981, 8, 1, 22, 35, 0)
# Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, hour: 0) # => Time.new(1981, 8, 29, 0, 0, 0)
def change(options)
new_year = options.fetch(:year, year)
new_month = options.fetch(:month, month)
new_day = options.fetch(:day, day)
new_hour = options.fetch(:hour, hour)
new_min = options.fetch(:min, options[:hour] ? 0 : min)
new_sec = options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec)
new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000))

if utc?
::Time.utc(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
elsif zone
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
else
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
end
end unless method_defined? :change

end
5 changes: 2 additions & 3 deletions lib/whois/record/parser/base_cocca2.rb
Expand Up @@ -87,11 +87,10 @@ class BaseCocca2 < Base
end


private
private

def parse_time(value)
# Hack to remove usec. Do you know a better way?
Time.utc(*Time.parse(value).to_a)
Time.parse(value).change(usec: 0)
end

end
Expand Down
10 changes: 7 additions & 3 deletions lib/whois/record/parser/base_icann_compliant.rb
Expand Up @@ -57,19 +57,19 @@ class BaseIcannCompliant < Base

property_supported :created_on do
node('Creation Date') do |value|
Time.parse(value)
parse_time(value)
end
end

property_supported :updated_on do
node('Updated Date') do |value|
Time.parse(value)
parse_time(value)
end
end

property_supported :expires_on do
node('Registrar Registration Expiration Date') do |value|
Time.parse(value)
parse_time(value)
end
end

Expand Down Expand Up @@ -126,6 +126,10 @@ def build_contact(element, type)
end
end

def parse_time(value)
Time.parse(value)
end

def value_for_phone_property(element, property)
[
value_for_property(element, "#{property}"),
Expand Down
67 changes: 67 additions & 0 deletions lib/whois/record/parser/whois.uniregistry.net.rb
@@ -0,0 +1,67 @@
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
#++


require 'whois/record/parser/base_icann_compliant'


module Whois
class Record
class Parser

# Parser for the whois.donuts.com server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
class WhoisUniregistryNet < BaseIcannCompliant
self.scanner = Scanners::BaseIcannCompliant, {
pattern_available: />>> Domain \".+\" is available/
}


property_supported :domain_id do
node('Domain ID')
end


property_supported :expires_on do
node('Registry Expiry Date') do |value|
parse_time(value)
end
end


property_supported :registrar do
return unless node('Sponsoring Registrar')
Record::Registrar.new(
id: node('Sponsoring Registrar IANA ID'),
name: node('Sponsoring Registrar'),
organization: node('Sponsoring Registrar')
)
end


private

def build_contact(element, type)
if (contact = super)
contact.id = node("#{element} ID")
end
contact
end

def parse_time(value)
Time.parse(value).change(usec: 0)
end

end

end
end
end
@@ -0,0 +1,47 @@
#domain
%s == nil

#domain_id
%s == nil


#status
%s == :available

#available?
%s == true

#registered?
%s == false


#created_on
%s == nil

#updated_on
%s == nil

#expires_on
%s == nil


#registrar
%s == nil


#registrant_contacts
%s %CLASS{array}
%s == []

#admin_contacts
%s %CLASS{array}
%s == []

#technical_contacts
%s %CLASS{array}
%s == []


#nameservers
%s %CLASS{array}
%s == []
@@ -0,0 +1,39 @@


>>> Domain "u34jedzcq.tattoo" is available for registration

>>> Please visit http://uniregistry.com/registry/where-to-buy for a
>>> list of accredited registrars.


>>> Last update of WHOIS database: 2014-03-10T17:08:32.890Z <<<


The WHOIS information provided on this page is intended to provide you
with relevant contact information for a domain name registrant and the
identity of certain administrative and technical contacts associated
with the domain name.

The data in this record is provided by Uniregistry for informational
purposes only, and it does not guarantee its accuracy. Uniregistry is
authoritative for whois information in top-level domains it operates
under contract with the Internet Corporation for Assigned Names and
Numbers. Whois information from other top-level domains is provided by
a third-party under license to Uniregistry.

This service is intended only for query-based access. By using this
service, you agree that you will use any data presented only for lawful
purposes and that, under no circumstances will you use (a) data
acquired for the purpose of allowing, enabling, or otherwise supporting
the transmission by e-mail, telephone, facsimile or other
communications mechanism of mass unsolicited, commercial advertising
or solicitations to entities other than your existing customers; or
(b) this service to enable high volume, automated, electronic processes
that send queries or data to the systems of any Registrar or any
Registry except as reasonably necessary to register domain names or
modify existing domain name registrations.

Uniregistry reserves the right to modify these terms at any time. By
submitting this query, you agree to abide by this policy. All rights
reserved.

@@ -0,0 +1,118 @@
#domain
%s == "nic.tattoo"

#domain_id
%s == "DO_4810ec9890fdf872f2e23b58df485dc4-ISC"


#status
%s == :registered

#available?
%s == false

#registered?
%s == true


#created_on
%s %CLASS{time}
%s %TIME{2013-09-16 14:21:26 UTC}

#updated_on
%s %CLASS{time}
%s %TIME{2013-11-09 02:51:24 UTC}

#expires_on
%s %CLASS{time}
%s %TIME{2023-09-16 14:21:26 UTC}


#registrar
%s %CLASS{registrar}
%s.id == "9999"
%s.name == "Uniregistry, Corp."
%s.organization == "Uniregistry, Corp."
%s.url == nil


#registrant_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
%s[0].id == "uniregistry"
%s[0].name == "Uniregistry Registry Internal Resources"
%s[0].organization == "Uniregistry, Corp"
%s[0].address == "PO Box 1361"
%s[0].city == "Grand Cayman"
%s[0].zip == "KY1-1108"
%s[0].state == "George Town"
%s[0].country == nil
%s[0].country_code == "KY"
%s[0].phone == "+1.3457496263"
%s[0].fax == "+1.3457496263"
%s[0].email == "info+whois@uniregistry.com"
%s[0].created_on == nil
%s[0].updated_on == nil

#admin_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Record::Contact::TYPE_ADMINISTRATIVE
%s[0].id == "tattoo-admin"
%s[0].name == "Uniregistry admin contact"
%s[0].organization == "Uniregistry, Corp"
%s[0].address == "PO Box 1361"
%s[0].city == "Grand Cayman"
%s[0].zip == "KY1-1108"
%s[0].state == "George Town"
%s[0].country == nil
%s[0].country_code == "KY"
%s[0].phone == "+1.3457496263"
%s[0].fax == "+1.3457496263"
%s[0].email == "admin@nic.tattoo"
%s[0].created_on == nil
%s[0].updated_on == nil

#technical_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
%s[0].id == "tattoo-tech"
%s[0].name == "Uniregistry tech contact"
%s[0].organization == "Uniregistry, Corp"
%s[0].address == "PO Box 1361"
%s[0].city == "Grand Cayman"
%s[0].zip == "KY1-1108"
%s[0].state == "George Town"
%s[0].country == nil
%s[0].country_code == "KY"
%s[0].phone == "+1.3457496263"
%s[0].fax == "+1.3457496263"
%s[0].email == "tech@nic.tattoo"
%s[0].created_on == nil
%s[0].updated_on == nil


#nameservers
%s %CLASS{array}
%s %SIZE{4}
%s[0] %CLASS{nameserver}
%s[0].name == "a.ns.uniregistry.net"
%s[0].ipv4 == nil
%s[0].ipv6 == nil
%s[1] %CLASS{nameserver}
%s[1].name == "tld.isc-sns.info"
%s[1].ipv4 == nil
%s[1].ipv6 == nil
%s[2] %CLASS{nameserver}
%s[2].name == "tld.isc-sns.com"
%s[2].ipv4 == nil
%s[2].ipv6 == nil
%s[3] %CLASS{nameserver}
%s[3].name == "tld.isc-sns.net"
%s[3].ipv4 == nil
%s[3].ipv6 == nil

0 comments on commit db8240e

Please sign in to comment.