mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-05 02:05:09 +02:00
Rename Whois FR parser in AFNIC
This commit is contained in:
parent
9c040f9fc4
commit
ab0b961ee5
|
@ -1,11 +1,11 @@
|
|||
require "null_logger"
|
||||
require "whois/errors"
|
||||
require "whois/parser/fr"
|
||||
require "whois/parser/afnic"
|
||||
require "whois/parser/verisign"
|
||||
|
||||
module Whois
|
||||
module Parser
|
||||
PARSERS = [Fr, Verisign].freeze
|
||||
PARSERS = [AFNIC, Verisign].freeze
|
||||
|
||||
class << self
|
||||
def for(domain, logger: NullLogger.new)
|
||||
|
|
|
@ -4,8 +4,15 @@ require_relative "base"
|
|||
|
||||
module Whois
|
||||
module Parser
|
||||
class Fr < Base
|
||||
SUPPORTED_TLD = %w[.fr].freeze
|
||||
class AFNIC < Base
|
||||
SUPPORTED_TLD = %w[
|
||||
.fr
|
||||
.re
|
||||
.tf
|
||||
.yt
|
||||
.pm
|
||||
.wf
|
||||
].freeze
|
||||
COMMENT_REGEX = /^%+ +(?<text>.+)$/
|
||||
FIELD_REGEX = /^(?<name>[^:]+)\s*:\s+(?<value>.+)$/
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
require "test_helper"
|
||||
require "whois/parser/fr"
|
||||
require "whois/parser/afnic"
|
||||
require "whois/response"
|
||||
require "whois/errors"
|
||||
|
||||
module Whois
|
||||
class FrTest < ActiveSupport::TestCase
|
||||
class AFNICTest < ActiveSupport::TestCase
|
||||
test "should parse a whois response" do
|
||||
parser = Parser::Fr.new("domain.fr")
|
||||
parser = Parser::AFNIC.new("domain.fr")
|
||||
domain_fr = file_fixture("whois/domain.fr.txt").read
|
||||
response = parser.parse(domain_fr)
|
||||
assert_kind_of Response, response
|
||||
|
@ -19,7 +19,7 @@ module Whois
|
|||
end
|
||||
|
||||
test "should raises DomainNotFoundError when domain is not registered" do
|
||||
parser = Parser::Fr.new("willneverexist.fr")
|
||||
parser = Parser::AFNIC.new("willneverexist.fr")
|
||||
not_found_fr = file_fixture("whois/willneverexist.fr.txt").read
|
||||
|
||||
assert_raises DomainNotFoundError do
|
||||
|
@ -28,7 +28,7 @@ module Whois
|
|||
end
|
||||
|
||||
test "should raises InvalidDateError when a date is not in the expected format" do
|
||||
parser = Parser::Fr.new("domain.fr")
|
||||
parser = Parser::AFNIC.new("domain.fr")
|
||||
domain_fr = file_fixture("whois/domain.fr.txt").read
|
||||
domain_fr.gsub!("17/02/2019", "17-02-2019")
|
||||
|
|
@ -5,7 +5,7 @@ require "whois/errors"
|
|||
module Whois
|
||||
class ParserTest < ActiveSupport::TestCase
|
||||
test "should instanciate a parser class matching AFNIC tlds" do
|
||||
assert_kind_of Parser::Fr, Parser.for("example.fr")
|
||||
assert_kind_of Parser::AFNIC, Parser.for("example.fr")
|
||||
end
|
||||
|
||||
test "should instanciate a parser class matching Verisign tlds" do
|
||||
|
|
Loading…
Reference in a new issue