lib/whois/parsers/base_nic_fr.rb in whois-parser-1.2.0 vs lib/whois/parsers/base_nic_fr.rb in whois-parser-2.0.0

- old
+ new

@@ -1,11 +1,11 @@ #-- # Ruby Whois # # An intelligent pure Ruby WHOIS client and parser. # -# Copyright (c) 2009-2018 Simone Carletti <weppos@weppos.net> +# Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net> #++ require_relative 'base' @@ -18,11 +18,11 @@ # @abstract class BaseNicFr < Base property_supported :status do if content_for_scanner =~ /status:\s+(.+)\n/ - case $1.downcase + case ::Regexp.last_match(1).downcase when "active" then :registered when "registered" then :registered when "redemption" then :redemption when "blocked" then :inactive # The 'frozen' status seems to be a status @@ -32,11 +32,11 @@ # The 'not_open' status seems to indicate a domain # that is already reserved and can't be registered directly. # This is the case of second level names. when "not_open" then :reserved else - Whois::Parser.bug!(ParserError, "Unknown status `#{$1}'.") + Whois::Parser.bug!(ParserError, "Unknown status `#{::Regexp.last_match(1)}'.") end else :available end end @@ -50,25 +50,25 @@ end property_supported :created_on do if content_for_scanner =~ /created:\s+(.+)\n/ - d, m, y = $1.split("/") + d, m, y = ::Regexp.last_match(1).split("/") parse_time("#{y}-#{m}-#{d}") end end property_supported :updated_on do if content_for_scanner =~ /last-update:\s+(.+)\n/ - d, m, y = $1.split("/") + d, m, y = ::Regexp.last_match(1).split("/") parse_time("#{y}-#{m}-#{d}") end end property_supported :expires_on do if content_for_scanner =~ /Expiry Date:\s+(.+)\n/ - d, m, y = $1.split("/") + d, m, y = ::Regexp.last_match(1).split("/") parse_time("#{y}-#{m}-#{d}") end end property_supported :registrant_contacts do @@ -85,12 +85,12 @@ property_supported :nameservers do content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map do |line| if line =~ /(.+) \[(.+)\]/ - name = $1 - ips = $2.split(/\s+/) + name = ::Regexp.last_match(1) + ips = ::Regexp.last_match(2).split(/\s+/) ipv4 = ips.find { |ip| Whois::Server.send(:valid_ipv4?, ip) } ipv6 = ips.find { |ip| Whois::Server.send(:valid_ipv6?, ip) } Parser::Nameserver.new(:name => name, :ipv4 => ipv4, :ipv6 => ipv6) else Parser::Nameserver.new(:name => line) @@ -106,18 +106,18 @@ end private - MULTIVALUE_KEYS = %w( address ) + MULTIVALUE_KEYS = %w[address] def parse_contact(element, type) return unless content_for_scanner =~ /#{element}:\s+(.+)\n/ - id = $1 + id = ::Regexp.last_match(1) content_for_scanner.scan(/nic-hdl:\s+#{id}\n((.+\n)+)\n/).any? || Whois::Parser.bug!(ParserError, "Unable to parse contact block for nic-hdl: #{id}") - values = build_hash($1.scan(/(.+?):\s+(.+?)\n/)) + values = build_hash(::Regexp.last_match(1).scan(/(.+?):\s+(.+?)\n/)) if values["type"] == "ORGANIZATION" name = nil organization = values["contact"] address = values["address"].join("\n")