lib/dyndnsd/generator/bind.rb in dyndnsd-1.6.1 vs lib/dyndnsd/generator/bind.rb in dyndnsd-2.0.0.rc1

- old
+ new

@@ -8,28 +8,28 @@ @dns = config['dns'] @email_addr = config['email_addr'] @additional_zone_content = config['additional_zone_content'] end - def generate(zone) + def generate(db) out = [] out << "$TTL #{@ttl}" out << "$ORIGIN #{@domain}." - out << "" - out << "@ IN SOA #{@dns} #{@email_addr} ( #{zone['serial']} 3h 5m 1w 1h )" + out << '' + out << "@ IN SOA #{@dns} #{@email_addr} ( #{db['serial']} 3h 5m 1w 1h )" out << "@ IN NS #{@dns}" - out << "" - zone['hosts'].each do |hostname,ips| - (ips.is_a?(Array) ? ips : [ips]).each do |ip| + out << '' + db['hosts'].each do |hostname, ips| + ips.each do |ip| ip = IPAddr.new(ip).native - type = ip.ipv6? ? "AAAA" : "A" + type = ip.ipv6? ? 'AAAA' : 'A' name = hostname.chomp('.' + @domain) out << "#{name} IN #{type} #{ip}" end end - out << "" + out << '' out << @additional_zone_content - out << "" + out << '' out.join("\n") end end end end