21
1
Fork 0
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:
Colin Darie 2018-06-05 16:42:04 +02:00
parent 9c040f9fc4
commit ab0b961ee5
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 17 additions and 10 deletions

View file

@ -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)

View file

@ -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>.+)$/

View file

@ -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")

View file

@ -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