Permalink
Browse files

Merge pull request #154 from kliuchnikau/by_zone_whois

Whois for .by (whois.cctld.by)
  • Loading branch information...
2 parents 5f48d7a + 1905708 commit 50475387af454d7a08e44998a4d83b3907982cc6 @weppos committed Mar 21, 2012
@@ -84,7 +84,7 @@
Whois::Server.define :tld, ".bs", nil, { :web => "http://www.nic.bs/cgi-bin/search.pl", :adapter => Whois::Server::Adapters::Web }
Whois::Server.define :tld, ".bt", nil, { :web => "http://www.nic.bt/", :adapter => Whois::Server::Adapters::Web }
Whois::Server.define :tld, ".bv", nil, { :adapter => Whois::Server::Adapters::None }
-Whois::Server.define :tld, ".by", nil, { :web => "http://www.tld.by/indexeng.html", :adapter => Whois::Server::Adapters::Web }
+Whois::Server.define :tld, ".by", 'whois.cctld.by'
Whois::Server.define :tld, ".bw", nil, { :adapter => Whois::Server::Adapters::None }
Whois::Server.define :tld, ".bz", "whois.afilias-grs.info", { :adapter => Whois::Server::Adapters::Afilias }
Whois::Server.define :tld, ".co.ca", "whois.co.ca"
@@ -0,0 +1,97 @@
+#--
+# 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/scanners/whois.cctld.by'
+
+module Whois
+ class Record
+ class Parser
+
+ #
+ # = whois.cctld.by parser
+ #
+ # Parser for the whois.cctld.by server.
+ #
+ # @author Aliaksei Kliuchnikau <aliaksei.kliuchnikau@gmail.com>
+ class WhoisCctldBy < Base
+ include Scanners::Ast
+
+ property_not_supported :disclaimer
+
+ property_supported :domain do
+ node("Domain Name", &:downcase)
+ 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("Creation Date") { |value| Time.parse(value) }
+ end
+
+ property_supported :updated_on do
+ node("Updated Date") { |value| Time.parse(value) }
+ end
+
+ property_supported :expires_on do
+ node("Expiration Date") { |value| Time.parse(value) }
+ end
+
+ property_supported :registrar do
+ node("Registrar") do |registrar|
+ Record::Registrar.new(:id => registrar,
+ :name => registrar,
+ :organization => registrar
+ )
+ end
+ end
+
+ property_not_supported :registrant_contacts
+
+ property_not_supported :admin_contacts
+
+ property_not_supported :technical_contacts
+
+ property_supported :nameservers do
+ Array.wrap(node("Name Server")).map do |name|
+ Nameserver.new(name.downcase)
+ end
+ end
+
+ # Initializes a new {Scanners::WhoisCctldBy} instance
+ # passing the {#content_for_scanner}
+ # and calls +parse+ on it.
+ #
+ # @return [Hash]
+ def parse
+ Scanners::WhoisCctldBy.new(content_for_scanner).parse
+ end
+ end
+ end
+ end
+end
@@ -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/scanners/base'
+
+module Whois
+ class Record
+ module Scanners
+
+ #
+ # = whois.cctld.by scanner
+ #
+ # Scanner for the whois.cctld.by server.
+ #
+ # @author Aliaksei Kliuchnikau <aliaksei.kliuchnikau@gmail.com>
+ class WhoisCctldBy < Base
+
+ self.tokenizers += [
+ :skip_empty_line,
+ :scan_available,
+ :scan_keyvalue,
+ :skip_empty_line,
+ :skip_dash_line,
+ :skip_provider_signature,
+ ]
+
+ tokenizer :scan_available do
+ if @input.scan(/^Object does not exist/)
+ @ast["status:available"] = true
+ end
+ end
+
+ tokenizer :skip_dash_line do
+ @input.skip(/^-+\n/)
+ end
+
+ tokenizer :skip_provider_signature do
+ @input.scan(/^(.+)\n/)
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,48 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#domain
+ should: %s == nil
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_url
+ 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 == nil
+
+#registrant_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#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 @@
+Object does not exist
@@ -0,0 +1,58 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#domain
+ should: %s == "active.by"
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_url
+ 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("2003-02-02 15:50:44 UTC")
+
+#updated_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2010-12-20 08:36:13 UTC")
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2013-12-21 10:07:40 UTC")
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == "Active Technologies LLC"
+ should: %s.name == "Active Technologies LLC"
+ should: %s.organization == "Active Technologies LLC"
+
+#registrant_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#admin_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#technical_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(2)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "ns1.activeby.net"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "ns2.activeby.net"
@@ -0,0 +1,11 @@
+Domain Name: active.by
+Domain Name Administrator: HIDDEN! Details are available at http://www.cctld.by/whois
+Registrar: Active Technologies LLC
+Name Server: ns1.activeby.net
+Name Server: ns2.activeby.net
+Updated Date: 2010-12-20T08:36:13.0Z
+Creation Date: 2003-02-02T15:50:44.0Z
+Expiration Date: 2013-12-21T10:07:40.0Z
+
+-------------------------------------------
+Service provided by Reliable Software, Inc.
@@ -0,0 +1,105 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.cctld.by/status_available.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.cctld.by.rb'
+
+describe Whois::Record::Parser::WhoisCctldBy, "status_available.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.cctld.by/status_available.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#disclaimer" do
+ it do
+ lambda { @parser.disclaimer }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#domain" do
+ it do
+ @parser.domain.should == nil
+ end
+ end
+ describe "#domain_id" do
+ it do
+ lambda { @parser.domain_id }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_whois" do
+ it do
+ lambda { @parser.referral_whois }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_url" do
+ it do
+ lambda { @parser.referral_url }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#status" do
+ it do
+ @parser.status.should == :available
+ end
+ end
+ describe "#available?" do
+ it do
+ @parser.available?.should == true
+ end
+ end
+ describe "#registered?" do
+ it do
+ @parser.registered?.should == false
+ end
+ end
+ describe "#created_on" do
+ it do
+ @parser.created_on.should == nil
+ end
+ end
+ describe "#updated_on" do
+ it do
+ @parser.updated_on.should == nil
+ end
+ end
+ describe "#expires_on" do
+ it do
+ @parser.expires_on.should == nil
+ end
+ end
+ describe "#registrar" do
+ it do
+ @parser.registrar.should == nil
+ end
+ end
+ describe "#registrant_contacts" do
+ it do
+ lambda { @parser.registrant_contacts }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#admin_contacts" do
+ it do
+ lambda { @parser.admin_contacts }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#technical_contacts" do
+ it do
+ lambda { @parser.technical_contacts }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#nameservers" do
+ it do
+ @parser.nameservers.should be_a(Array)
+ @parser.nameservers.should == []
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 5047538

Please sign in to comment.