21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-09 12:08:38 +02:00
chexpire/app/services/whois/parser.rb

33 lines
761 B
Ruby
Raw Normal View History

# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# License: GNU AGPL-3+ (see full text in LICENSE file)
2018-05-30 12:04:07 +02:00
require "null_logger"
require "whois/errors"
require "whois/parser/afilias"
2018-06-05 16:42:04 +02:00
require "whois/parser/afnic"
2019-02-28 00:15:03 +01:00
require "whois/parser/cira"
2019-02-28 21:54:57 +01:00
require "whois/parser/neustar"
2018-06-05 16:39:08 +02:00
require "whois/parser/verisign"
2018-05-30 12:04:07 +02:00
module Whois
module Parser
2019-02-28 21:54:57 +01:00
PARSERS = [
Afilias,
AFNIC,
CIRA,
Neustar,
Verisign,
].freeze
2018-05-30 12:04:07 +02:00
class << self
def for(domain, logger: NullLogger.new)
parser_class = PARSERS.find { |k| k.supports?(domain) }
fail UnsupportedDomainError, "Unsupported domain '#{domain}'" if parser_class.nil?
parser_class.new(domain, logger: logger)
end
end
end
end