Class: DnsMadeEasy::Zone::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsmadeeasy/zone/serializer.rb

Overview

Emits deterministic, normalized zone-file text.

Constant Summary collapse

RECORD_FORMAT =

Fixed columns: owner (30), TTL (5, blank when it matches $TTL), "IN " (3), record type (7), then the payload.

'%-30s %5s %-3s%-7s %s'

Instance Method Summary collapse

Constructor Details

#initialize(zone_file, omit_apex_ns: true) ⇒ Serializer

Returns a new instance of Serializer.



13
14
15
16
# File 'lib/dnsmadeeasy/zone/serializer.rb', line 13

def initialize(zone_file, omit_apex_ns: true)
  @zone_file = zone_file
  @omit_apex_ns = omit_apex_ns
end

Instance Method Details

#to_sObject



18
19
20
21
22
23
24
25
26
# File 'lib/dnsmadeeasy/zone/serializer.rb', line 18

def to_s
  lines = [
    "$ORIGIN #{zone_file.origin}",
    "$TTL #{zone_file.ttl}",
    ''
  ]
  lines.concat(serialized_records)
  "#{lines.join("\n")}\n"
end