class DnsOne::Backend::File

Public Class Methods

new(file) click to toggle source
# File lib/dns_one/backend/file.rb, line 4
def initialize file
    @domain_map = {}
    load file
end

Public Instance Methods

allow_cache() click to toggle source
# File lib/dns_one/backend/file.rb, line 13
def allow_cache
    false
end
find(dom_name) click to toggle source
# File lib/dns_one/backend/file.rb, line 9
def find dom_name
    @domain_map[dom_name.downcase]
end

Private Instance Methods

load(file) click to toggle source
# File lib/dns_one/backend/file.rb, line 19
def load file
    ::File.open(file).each_line do |line|
        line.strip!
        domain_name, rec_set_name = line
            .split(/[,\s]+/)
        if domain_name and not domain_name.empty?
            @domain_map[domain_name.strip.downcase] = rec_set_name&.strip || ''
        else
            Global.logger.warn "Ignoring #{file} line: #{line}"
        end
    end
end