21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-01 08:20:49 +02:00
chexpire/app/services/whois/parser.rb
2018-08-02 00:29:53 +02:00

25 lines
642 B
Ruby

# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# License: GNU AGPL-3+ (see full text in LICENSE file)
require "null_logger"
require "whois/errors"
require "whois/parser/afnic"
require "whois/parser/pir"
require "whois/parser/verisign"
module Whois
module Parser
PARSERS = [AFNIC, Verisign, PIR].freeze
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