Sha256: 7ce23d16a461e81a80f5e35c796eab4dd9fa0cdbe5e74229d544ad336596139a
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
require "zonesync/record" require "zonesync/zonefile" require "zonesync/manifest" module Zonesync class Provider < Struct.new(:credentials) def self.from credentials return credentials if credentials.is_a?(Provider) Zonesync.const_get(credentials[:provider]).new(credentials) end def records zonefile.records.map do |record| Record.from_dns_zonefile_record(record) end end def diffable_records records.select do |record| manifest.diffable?(record) end.sort end def manifest @manifest ||= Manifest.new(records, zonefile) end private def zonefile @zonefile ||= begin body = read if body !~ /\sSOA\s/ # insert dummy SOA to trick parser if needed body.sub!(/\n([^$])/, "\n@ 1 SOA example.com example.com ( 2000010101 1 1 1 1 )\n\\1") end Zonefile.load(body) end end def read record raise NotImplementedError end def write text raise NotImplementedError end def remove record raise NotImplementedError end def change old_record, new_record raise NotImplementedError end def add record raise NotImplementedError end end require "zonesync/cloudflare" require "zonesync/route53" class Memory < Provider def read credentials[:string] end def write string credentials[:string] = string end end class Filesystem < Provider def read File.read(credentials[:path]) end def write string File.write(credentials[:path], string) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zonesync-0.9.0 | lib/zonesync/provider.rb |
zonesync-0.8.0 | lib/zonesync/provider.rb |