From b7ba26e5e33945c5b661c90316109289caa0d78d Mon Sep 17 00:00:00 2001 From: dachinatsvlishvili Date: Fri, 20 Aug 2021 23:16:19 +0400 Subject: [PATCH 1/3] Add whois.nic.ge --- lib/whois/parsers/whois.nic.ge.rb | 200 ++++++++++++++++++ .../whois.nic.ge/ge/status_available.expected | 29 +++ .../whois.nic.ge/ge/status_available.txt | 27 +++ .../ge/status_registered.expected | 102 +++++++++ .../whois.nic.ge/ge/status_registered.txt | 40 ++++ .../whois.nic.ge/ge/status_available_spec.rb | 70 ++++++ .../whois.nic.ge/ge/status_registered_spec.rb | 150 +++++++++++++ 7 files changed, 618 insertions(+) create mode 100644 lib/whois/parsers/whois.nic.ge.rb create mode 100644 spec/fixtures/responses/whois.nic.ge/ge/status_available.expected create mode 100644 spec/fixtures/responses/whois.nic.ge/ge/status_available.txt create mode 100644 spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected create mode 100644 spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt create mode 100644 spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb create mode 100644 spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb diff --git a/lib/whois/parsers/whois.nic.ge.rb b/lib/whois/parsers/whois.nic.ge.rb new file mode 100644 index 00000000..7a2d615b --- /dev/null +++ b/lib/whois/parsers/whois.nic.ge.rb @@ -0,0 +1,200 @@ +#-- +# Ruby Whois +# +# An intelligent pure Ruby WHOIS client and parser. +# +# Copyright (c) 2009-2018 Simone Carletti +#++ + + +require_relative 'base' + +module Whois + class Parsers + + # Parser for the whois.example.com server. + # + # In case you are not implementing all the methods, + # please add the following statement to the class docblock. + # + # @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. + class WhoisNicGe < Base + + include Scanners::Scannable + + self.scanner = Scanners::Verisign + + # Gets the registry disclaimer that comes with the record. + # + # Returns a String with the disclaimer if available, + # nil otherwise. + property_supported :disclaimer do + nil + end + + # Gets the domain name as stored by the registry. + # + # Returns a String with the domain name if available, + # nil otherwise. + property_supported :domain do + if content_for_scanner =~ /No match for\s\"(.+)\"\.\n/ + $1.downcase + else + node("Domain Name", &:downcase) + end + end + + # Gets the unique domain ID as stored by the registry. + # + # Returns a String with the domain ID if available, + # nil otherwise. + property_supported :domain_id do + raise Whois::AttributeNotSupported + end + + # Gets the record status or statuses. + # + # Returns a String/Array with the record status if available, + # nil otherwise. + property_supported :status do + if available? + :available + else + :registered + end + end + + # Checks whether this record is available. + # + # Returns true/false depending whether this record is available. + property_supported :available? do + !!(content_for_scanner =~ /^No match for/) + end + + # Checks whether this record is registered. + # + # Returns true/false depending this record is available. + property_supported :registered? do + !available? + end + + # Gets the date the record was created, + # according to the registry record. + # + # Returns a Time object representing the date the record was created or + # nil otherwise. + property_supported :created_on do + node("Creation Date") { |value| parse_time(value) } + end + + # Gets the date the record was last updated, + # according to the registry record. + # + # Returns a Time object representing the date the record was last updated or + # nil if not available. + property_supported :updated_on do + nil + end + + # Gets the date the record is set to expire, + # according to the registry record. + # + # Returns a Time object representing the date the record is set to expire or + # nil if not available. + property_supported :expires_on do + node("Registry Expiry Date") { |value| parse_time(value) } + end + + # Gets the registrar object containing the registrar details + # extracted from the registry record. + # + # Returns an instance of Parser::Registrar representing the registrar or + # nil if not available. + property_supported :registrar do + if node("Registrar") + Parser::Registrar.new( + name: node("Registrar"), + ) + end + end + + + # Gets the registrant contact object containing the details of the record owner + # extracted from the registry record. + # + # Returns an instance of Parser::Contact representing the registrant contact or + # nil if not available. + property_supported :registrant_contacts do + build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT) + end + + # Gets the administrative contact object containing the details of the record administrator + # extracted from the registry record. + # + # Returns an instance of Parser::Contact representing the administrative contact or + # nil if not available. + property_supported :admin_contacts do + build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE) + end + + # Gets the technical contact object containing the details of the technical representative + # extracted from the registry record. + # + # Returns an instance of Parser::Contact representing the technical contact or + # nil if not available. + property_supported :technical_contacts do + build_contact("Tech", Parser::Contact::TYPE_TECHNICAL) + end + + + # Gets the list of name server entries for this record, + # extracted from the registry record. + # + # @example + # nameserver + # # => [] + # + # @example + # nameserver + # # => [ + # # #, + # # # + # # ] + # + # @return [Array] + property_supported :nameservers do + Array.wrap(node("Name Server")).reject(&:empty?).reverse.map do |name| + Parser::Nameserver.new(name: name.downcase) + end + end + + private + + def build_contact(element, type) + if type == Parser::Contact::TYPE_REGISTRANT + node(element) do + Parser::Contact.new( + type: type, + name: node("#{element}"), + ) + end + elsif Parser::Contact::TYPE_ADMINISTRATIVE + Parser::Contact.new( + type: type, + name: node("Admin Name"), + email: node("Admin Email") + ) + elsif Parser::Contact::TYPE_TECHNICAL + Parser::Contact.new( + type: type, + name: node("Tech Name"), + email: node("Tech Email") + ) + end + end + end + + end +end diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_available.expected b/spec/fixtures/responses/whois.nic.ge/ge/status_available.expected new file mode 100644 index 00000000..0cc17beb --- /dev/null +++ b/spec/fixtures/responses/whois.nic.ge/ge/status_available.expected @@ -0,0 +1,29 @@ +#domain + %s == "u34jedzcq.ge" + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + +#created_on + %s == nil + +#updated_on + %s == nil + +#expires_on + %s == nil + + +#registrar + %s == nil + + +#nameservers + %s %CLASS{array} + %s == [] \ No newline at end of file diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_available.txt b/spec/fixtures/responses/whois.nic.ge/ge/status_available.txt new file mode 100644 index 00000000..8f3f0a06 --- /dev/null +++ b/spec/fixtures/responses/whois.nic.ge/ge/status_available.txt @@ -0,0 +1,27 @@ +No match for "U34JEDZCQ.GE". + + +TERMS OF USE: +The WHOIS service is provided solely for informational purposes. +You are not authorized to access or query our Whois +database through the use of electronic processes that are high-volume and +automated except as reasonably necessary to register domain names or +modify existing registrations; the Data is provided by NIC for +information purposes only, and to assist persons in obtaining information +about or related to a domain name registration record. NIC 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 NIC (or its computer systems). The compilation, +repackaging, dissemination or other use of this Data is expressly +prohibited without the prior written consent of NIC. You agree not to +use electronic processes that are automated and high-volume to access or +query the Whois database except as reasonably necessary to register +domain names or modify existing registrations. NIC reserves the right +to restrict your access to the Whois database in its sole discretion to ensure +operational stability. NIC may restrict or terminate your access to the +Whois database for failure to abide by these terms of use. NIC +reserves the right to modify these terms at any time. \ No newline at end of file diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected b/spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected new file mode 100644 index 00000000..42c7d05e --- /dev/null +++ b/spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected @@ -0,0 +1,102 @@ +#domain + %s == "google.ge" + +#domain_id + %s %ERROR{AttributeNotSupported} + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{2006-07-28} + +#expires_on + %s %CLASS{time} + %s %TIME{2022-07-29} + +#registrar + %s %CLASS{registrar} + %s.id == nil + %s.name == "proservice ltd" + %s.organization == nil + %s.url == nil + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].id == nil + %s[0].name == "Google LLC" + %s[0].organization == nil + %s[0].address == nil + %s[0].city == nil + %s[0].zip == nil + %s[0].state == nil + %s[0].country == nil + %s[0].country_code == nil + %s[0].phone == nil + %s[0].fax == nil + %s[0].email == nil + %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::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].id == nil + %s[0].name == "Google LLC" + %s[0].organization == nil + %s[0].address == nil + %s[0].city == nil + %s[0].zip == nil + %s[0].state == nil + %s[0].country == nil + %s[0].country_code == nil + %s[0].phone == nil + %s[0].fax == nil + %s[0].email == "dns-admin@google.com" + %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::Parser::Contact::TYPE_TECHNICAL + %s[0].id == nil + %s[0].name == "Google LLC" + %s[0].organization == nil + %s[0].address == nil + %s[0].city == nil + %s[0].zip == nil + %s[0].state == nil + %s[0].country == nil + %s[0].country_code == nil + %s[0].phone == nil + %s[0].fax == nil + %s[0].email == "dns-admin@google.com" + %s[0].created_on == nil + %s[0].updated_on == nil + + +#nameservers + %s %CLASS{array} + %s %SIZE{4} + %s[0] %CLASS{nameserver} + %s[0].name == "ns1.google.com" + %s[1] %CLASS{nameserver} + %s[1].name == "ns2.google.com" + %s[2] %CLASS{nameserver} + %s[2].name == "ns3.google.com" + %s[3] %CLASS{nameserver} + %s[3].name == "ns4.google.com" \ No newline at end of file diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt b/spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt new file mode 100644 index 00000000..ce368e7f --- /dev/null +++ b/spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt @@ -0,0 +1,40 @@ + Domain Name: GOOGLE.GE + Creation Date: 2006-07-28 + Registry Expiry Date: 2022-07-29 + Registrar: proservice ltd + Domain Status: Ok + Registrant: Google LLC + Admin Name: Google LLC + Admin Email: dns-admin@google.com + Tech Name: Google LLC + Tech Email: dns-admin@google.com + Name Server: ns4.google.com + Name Server: ns3.google.com + Name Server: ns2.google.com + Name Server: ns1.google.com + + +TERMS OF USE: +The WHOIS service is provided solely for informational purposes. +You are not authorized to access or query our Whois +database through the use of electronic processes that are high-volume and +automated except as reasonably necessary to register domain names or +modify existing registrations; the Data is provided by NIC for +information purposes only, and to assist persons in obtaining information +about or related to a domain name registration record. NIC 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 NIC (or its computer systems). The compilation, +repackaging, dissemination or other use of this Data is expressly +prohibited without the prior written consent of NIC. You agree not to +use electronic processes that are automated and high-volume to access or +query the Whois database except as reasonably necessary to register +domain names or modify existing registrations. NIC reserves the right +to restrict your access to the Whois database in its sole discretion to ensure +operational stability. NIC may restrict or terminate your access to the +Whois database for failure to abide by these terms of use. NIC +reserves the right to modify these terms at any time. \ No newline at end of file diff --git a/spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb b/spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb new file mode 100644 index 00000000..75dc3889 --- /dev/null +++ b/spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb @@ -0,0 +1,70 @@ +# 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.nic.ge/ge/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.nic.ge.rb' + +describe Whois::Parsers::WhoisNicGe, "status_available.expected" do + + subject do + file = fixture("responses", "whois.nic.ge/ge/status_available.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq("u34jedzcq.ge") + end + end + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(true) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(false) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to eq(nil) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to eq(nil) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to eq(nil) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to eq(nil) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers).to eq([]) + end + end +end diff --git a/spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb b/spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb new file mode 100644 index 00000000..8430c2e1 --- /dev/null +++ b/spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb @@ -0,0 +1,150 @@ +# 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.nic.ge/ge/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.nic.ge.rb' + +describe Whois::Parsers::WhoisNicGe, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.nic.ge/ge/status_registered.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq("google.ge") + end + end + describe "#domain_id" do + it do + expect { subject.domain_id }.to raise_error(Whois::AttributeNotSupported) + end + end + describe "#status" do + it do + expect(subject.status).to eq(:registered) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(false) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(true) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to be_a(Time) + expect(subject.created_on).to eq(Time.parse("2006-07-28")) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to be_a(Time) + expect(subject.expires_on).to eq(Time.parse("2022-07-29")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq(nil) + expect(subject.registrar.name).to eq("proservice ltd") + expect(subject.registrar.organization).to eq(nil) + expect(subject.registrar.url).to eq(nil) + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts.size).to eq(1) + expect(subject.registrant_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.registrant_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_REGISTRANT) + expect(subject.registrant_contacts[0].id).to eq(nil) + expect(subject.registrant_contacts[0].name).to eq("Google LLC") + expect(subject.registrant_contacts[0].organization).to eq(nil) + expect(subject.registrant_contacts[0].address).to eq(nil) + expect(subject.registrant_contacts[0].city).to eq(nil) + expect(subject.registrant_contacts[0].zip).to eq(nil) + expect(subject.registrant_contacts[0].state).to eq(nil) + expect(subject.registrant_contacts[0].country).to eq(nil) + expect(subject.registrant_contacts[0].country_code).to eq(nil) + expect(subject.registrant_contacts[0].phone).to eq(nil) + expect(subject.registrant_contacts[0].fax).to eq(nil) + expect(subject.registrant_contacts[0].email).to eq(nil) + expect(subject.registrant_contacts[0].created_on).to eq(nil) + expect(subject.registrant_contacts[0].updated_on).to eq(nil) + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts.size).to eq(1) + expect(subject.admin_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.admin_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_ADMINISTRATIVE) + expect(subject.admin_contacts[0].id).to eq(nil) + expect(subject.admin_contacts[0].name).to eq("Google LLC") + expect(subject.admin_contacts[0].organization).to eq(nil) + expect(subject.admin_contacts[0].address).to eq(nil) + expect(subject.admin_contacts[0].city).to eq(nil) + expect(subject.admin_contacts[0].zip).to eq(nil) + expect(subject.admin_contacts[0].state).to eq(nil) + expect(subject.admin_contacts[0].country).to eq(nil) + expect(subject.admin_contacts[0].country_code).to eq(nil) + expect(subject.admin_contacts[0].phone).to eq(nil) + expect(subject.admin_contacts[0].fax).to eq(nil) + expect(subject.admin_contacts[0].email).to eq("dns-admin@google.com") + expect(subject.admin_contacts[0].created_on).to eq(nil) + expect(subject.admin_contacts[0].updated_on).to eq(nil) + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts.size).to eq(1) + expect(subject.technical_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.technical_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_TECHNICAL) + expect(subject.technical_contacts[0].id).to eq(nil) + expect(subject.technical_contacts[0].name).to eq("Google LLC") + expect(subject.technical_contacts[0].organization).to eq(nil) + expect(subject.technical_contacts[0].address).to eq(nil) + expect(subject.technical_contacts[0].city).to eq(nil) + expect(subject.technical_contacts[0].zip).to eq(nil) + expect(subject.technical_contacts[0].state).to eq(nil) + expect(subject.technical_contacts[0].country).to eq(nil) + expect(subject.technical_contacts[0].country_code).to eq(nil) + expect(subject.technical_contacts[0].phone).to eq(nil) + expect(subject.technical_contacts[0].fax).to eq(nil) + expect(subject.technical_contacts[0].email).to eq("dns-admin@google.com") + expect(subject.technical_contacts[0].created_on).to eq(nil) + expect(subject.technical_contacts[0].updated_on).to eq(nil) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(4) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("ns1.google.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("ns2.google.com") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("ns3.google.com") + expect(subject.nameservers[3]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[3].name).to eq("ns4.google.com") + end + end +end From 43bc487bffdb4efe89c6c29bf099714c2dc6bea6 Mon Sep 17 00:00:00 2001 From: dachinatsvlishvili Date: Fri, 20 Aug 2021 23:55:46 +0400 Subject: [PATCH 2/3] Add scanner --- .idea/.gitignore | 8 ++++ .idea/inspectionProfiles/Project_Default.xml | 6 +++ .idea/misc.xml | 4 ++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ .idea/whois-parser.iml | 17 ++++++++ ...ois.nic.ge.rb => whois.registration.ge.rb} | 5 ++- lib/whois/scanners/whois.registration.ge.rb | 43 +++++++++++++++++++ .../ge/status_available.expected | 0 .../ge/status_available.txt | 0 .../ge/status_registered.expected | 0 .../ge/status_registered.txt | 0 .../ge/status_available_spec.rb | 8 ++-- .../ge/status_registered_spec.rb | 8 ++-- 14 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/whois-parser.iml rename lib/whois/parsers/{whois.nic.ge.rb => whois.registration.ge.rb} (97%) create mode 100644 lib/whois/scanners/whois.registration.ge.rb rename spec/fixtures/responses/{whois.nic.ge => whois.registration.ge}/ge/status_available.expected (100%) rename spec/fixtures/responses/{whois.nic.ge => whois.registration.ge}/ge/status_available.txt (100%) rename spec/fixtures/responses/{whois.nic.ge => whois.registration.ge}/ge/status_registered.expected (100%) rename spec/fixtures/responses/{whois.nic.ge => whois.registration.ge}/ge/status_registered.txt (100%) rename spec/whois/parsers/responses/{whois.nic.ge => whois.registration.ge}/ge/status_available_spec.rb (81%) rename spec/whois/parsers/responses/{whois.nic.ge => whois.registration.ge}/ge/status_registered_spec.rb (95%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..73f69e09 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..b0db9b0f --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..ea3da0bd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..d959fbb2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/whois-parser.iml b/.idea/whois-parser.iml new file mode 100644 index 00000000..6f22de1e --- /dev/null +++ b/.idea/whois-parser.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/whois/parsers/whois.nic.ge.rb b/lib/whois/parsers/whois.registration.ge.rb similarity index 97% rename from lib/whois/parsers/whois.nic.ge.rb rename to lib/whois/parsers/whois.registration.ge.rb index 7a2d615b..43c3a652 100644 --- a/lib/whois/parsers/whois.nic.ge.rb +++ b/lib/whois/parsers/whois.registration.ge.rb @@ -8,6 +8,7 @@ require_relative 'base' +require 'whois/scanners/whois.registration.ge.rb' module Whois class Parsers @@ -20,11 +21,11 @@ class Parsers # @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. - class WhoisNicGe < Base + class WhoisRegistrationGe < Base include Scanners::Scannable - self.scanner = Scanners::Verisign + self.scanner = Scanners::WhoisRegistrationGe # Gets the registry disclaimer that comes with the record. # diff --git a/lib/whois/scanners/whois.registration.ge.rb b/lib/whois/scanners/whois.registration.ge.rb new file mode 100644 index 00000000..562a35f8 --- /dev/null +++ b/lib/whois/scanners/whois.registration.ge.rb @@ -0,0 +1,43 @@ +require_relative 'base' + +module Whois + module Scanners + + class WhoisRegistrationGe < Base + + self.tokenizers += [ + :skip_head, + :scan_available, + :scan_throttled, + :skip_empty_line, + :skip_blank_line, + :scan_keyvalue, + :skip_end, + ] + + tokenizer :scan_available do + if settings[:pattern_available] && @input.skip_until(settings[:pattern_available]) + @ast['status:available'] = true + end + end + + tokenizer :scan_throttled do + if settings[:pattern_throttled] && @input.skip_until(settings[:pattern_throttled]) + @ast['response:throttled'] = true + end + end + + tokenizer :skip_head do + if @input.skip_until(/Domain Name:/) + @input.scan(/\s?(.+)\n/) + @ast["Domain Name"] = @input[1].strip + end + end + + tokenizer :skip_end do + @input.terminate + end + + end + end +end diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_available.expected b/spec/fixtures/responses/whois.registration.ge/ge/status_available.expected similarity index 100% rename from spec/fixtures/responses/whois.nic.ge/ge/status_available.expected rename to spec/fixtures/responses/whois.registration.ge/ge/status_available.expected diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_available.txt b/spec/fixtures/responses/whois.registration.ge/ge/status_available.txt similarity index 100% rename from spec/fixtures/responses/whois.nic.ge/ge/status_available.txt rename to spec/fixtures/responses/whois.registration.ge/ge/status_available.txt diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected b/spec/fixtures/responses/whois.registration.ge/ge/status_registered.expected similarity index 100% rename from spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected rename to spec/fixtures/responses/whois.registration.ge/ge/status_registered.expected diff --git a/spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt b/spec/fixtures/responses/whois.registration.ge/ge/status_registered.txt similarity index 100% rename from spec/fixtures/responses/whois.nic.ge/ge/status_registered.txt rename to spec/fixtures/responses/whois.registration.ge/ge/status_registered.txt diff --git a/spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb b/spec/whois/parsers/responses/whois.registration.ge/ge/status_available_spec.rb similarity index 81% rename from spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb rename to spec/whois/parsers/responses/whois.registration.ge/ge/status_available_spec.rb index 75dc3889..02f609bd 100644 --- a/spec/whois/parsers/responses/whois.nic.ge/ge/status_available_spec.rb +++ b/spec/whois/parsers/responses/whois.registration.ge/ge/status_available_spec.rb @@ -3,7 +3,7 @@ # This file is autogenerated. Do not edit it manually. # If you want change the content of this file, edit # -# /spec/fixtures/responses/whois.nic.ge/ge/status_available.expected +# /spec/fixtures/responses/whois.registration.ge/ge/status_available.expected # # and regenerate the tests with the following rake task # @@ -11,12 +11,12 @@ # require 'spec_helper' -require 'whois/parsers/whois.nic.ge.rb' +require 'whois/parsers/whois.registration.ge.rb' -describe Whois::Parsers::WhoisNicGe, "status_available.expected" do +describe Whois::Parsers::WhoisRegistrationGe, "status_available.expected" do subject do - file = fixture("responses", "whois.nic.ge/ge/status_available.txt") + file = fixture("responses", "whois.registration.ge/ge/status_available.txt") part = Whois::Record::Part.new(body: File.read(file)) described_class.new(part) end diff --git a/spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb b/spec/whois/parsers/responses/whois.registration.ge/ge/status_registered_spec.rb similarity index 95% rename from spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb rename to spec/whois/parsers/responses/whois.registration.ge/ge/status_registered_spec.rb index 8430c2e1..83f8f0a8 100644 --- a/spec/whois/parsers/responses/whois.nic.ge/ge/status_registered_spec.rb +++ b/spec/whois/parsers/responses/whois.registration.ge/ge/status_registered_spec.rb @@ -3,7 +3,7 @@ # This file is autogenerated. Do not edit it manually. # If you want change the content of this file, edit # -# /spec/fixtures/responses/whois.nic.ge/ge/status_registered.expected +# /spec/fixtures/responses/whois.registration.ge/ge/status_registered.expected # # and regenerate the tests with the following rake task # @@ -11,12 +11,12 @@ # require 'spec_helper' -require 'whois/parsers/whois.nic.ge.rb' +require 'whois/parsers/whois.registration.ge.rb' -describe Whois::Parsers::WhoisNicGe, "status_registered.expected" do +describe Whois::Parsers::WhoisRegistrationGe, "status_registered.expected" do subject do - file = fixture("responses", "whois.nic.ge/ge/status_registered.txt") + file = fixture("responses", "whois.registration.ge/ge/status_registered.txt") part = Whois::Record::Part.new(body: File.read(file)) described_class.new(part) end From 8ef2d77de667f280bd49621a2f40e78b1372dfe9 Mon Sep 17 00:00:00 2001 From: dachinatsvlishvili Date: Fri, 20 Aug 2021 23:56:43 +0400 Subject: [PATCH 3/3] Cleanup --- .idea/.gitignore | 8 -------- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/misc.xml | 4 ---- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ .idea/whois-parser.iml | 17 ----------------- 6 files changed, 49 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/whois-parser.iml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e09..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index b0db9b0f..00000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ea3da0bd..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index d959fbb2..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/whois-parser.iml b/.idea/whois-parser.iml deleted file mode 100644 index 6f22de1e..00000000 --- a/.idea/whois-parser.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file