Sha256: f1723767aeb8897da7e7773caf9c3c46d5efed983d7859aa9c295362ad5e85b8
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require 'zt/conf' module Zt module Importers class BaseImporter attr_accessor :networks attr_accessor :nodes def initialize(networks, nodes) @networks = networks @nodes = nodes end def import abort('import called on non-functional superclass importer') end private def dnsify(input) zt_conf = Zt::Conf.instance.conf.zt tld_key = 'top_level_domains' tld = if zt_conf.key?(tld_key) && !zt_conf[tld_key].empty? zt_conf[tld_key] else 'zt' end clean = input.tr('-', '_') clean = clean.gsub(/([\W])/, '-') clean = clean.tr('_', '-') clean = clean.gsub(/(-+)/, '-') clean = "network-#{clean}" unless clean.match?(/^[A-Za-z]/) clean = clean.gsub(Regexp.new("-#{tld}$"), '') clean.gsub(/(-+)/, '-') end def qualify(zone) zt_conf = Zt::Conf.instance.conf.zt "#{dnsify(zone)}.#{zt_conf['top_level_domain']}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zt-0.1.1 | lib/zt/importers/_base_importer.rb |