21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-03 01:10:50 +02:00
chexpire/app/services/whois/parser/afilias.rb

87 lines
1.8 KiB
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-06-05 17:03:40 +02:00
module Whois
module Parser
class Afilias < Base
# https://afilias.info/products-services
# https://afilias.info/global-registry-services/ctlds
# https://afilias.info/global-registry-services/gtlds
2018-06-05 17:03:40 +02:00
SUPPORTED_TLD = %w[
.info
.ag
.bz
.gi
.au
.lc
.me
.mn
.sc
.vc
2018-06-05 17:03:40 +02:00
.org
.aero
.asia
.xxx
.post
.global
.vegas
.onl
.rich
.ltda
.srl
.adult
.porn
2018-06-05 17:03:40 +02:00
.ngo
.ong
.bet
.pet
.lotto
.poker
.lgbt
.vote
.voto
.organic
.green
.black
.red
.pink
.blue
.kim
.shiksha
.promo
2019-02-28 21:54:27 +01:00
.pro
2018-06-05 17:03:40 +02:00
].freeze
COMMENT_REGEX = /^(%|>)+ +(?<text>.+)$/
FIELD_REGEX = /^(?<name>[^:]+)\s*:\s+(?<value>.+)$/
def self.supports?(domain)
SUPPORTED_TLD.include?(tld(domain))
end
protected
def do_parse
raise_not_found if text_include?("NOT FOUND")
extract_values
end
private
def extract_values
domain_index = get_field!("Domain Name", value: domain.upcase).index
created_date = get_value!("Creation Date", after: domain_index)
response.created_at = parse_date(created_date)
expire_date = get_value!("Registry Expiry Date", after: domain_index)
response.expire_at = parse_date(expire_date)
updated_date = get_value!("Updated Date", after: domain_index)
response.updated_at = parse_date(updated_date)
end
end
end
end