Class: DnsMadeEasy::Zone::Parser
- Inherits:
-
Object
- Object
- DnsMadeEasy::Zone::Parser
- Defined in:
- lib/dnsmadeeasy/zone/parser.rb
Overview
Parses standard zone-file text into provider-neutral records.
Constant Summary collapse
- SUPPORTED_RECORD_CLASSES =
ANAME is absent from the dns-zonefile grammar; ANAME lines are rewritten to CNAME before parsing and converted back afterwards.
{ 'DNS::Zonefile::A' => 'A', 'DNS::Zonefile::AAAA' => 'AAAA', 'DNS::Zonefile::CNAME' => 'CNAME', 'DNS::Zonefile::MX' => 'MX', 'DNS::Zonefile::NS' => 'NS', 'DNS::Zonefile::PTR' => 'PTR', 'DNS::Zonefile::SPF' => 'SPF', 'DNS::Zonefile::SRV' => 'SRV', 'DNS::Zonefile::TXT' => 'TXT' }.freeze
- ANAME_LINE =
/^(?<owner>[^\s;]\S*)\s+(?:\d+\s+)?(?:IN\s+)?ANAME\s+(?<target>\S+)/i
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(zone_text) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(zone_text) ⇒ Parser
Returns a new instance of Parser.
31 32 33 34 |
# File 'lib/dnsmadeeasy/zone/parser.rb', line 31 def initialize(zone_text) @zone_text = zone_text @aname_keys = [] end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/dnsmadeeasy/zone/parser.rb', line 36 def call zone = DNS::Zonefile.load(parseable_zone_text) records, errors = build_records(zone) return Failure(errors) if errors.any? Success(File.new(origin: zone_origin(zone), ttl: zone_ttl(zone), record_set: RecordSet.new(records: records))) rescue DNS::Zonefile::ParsingError, DNS::Zonefile::UnknownRecordType, Dry::Struct::Error => e Failure([e.]) end |