Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/dns/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def dump
content << rr.dump
end

content.join("\n") << "\n"
dump_directives << content.join("\n") << "\n"
end

# Generates pretty output of the zone and its records.
Expand All @@ -75,7 +75,7 @@ def dump_pretty
last_type = rr.type
end

content.join("\n") << "\n"
dump_directives << content.join("\n") << "\n"
end

# Load the provided zone file data into a new DNS::Zone object.
Expand Down Expand Up @@ -185,6 +185,16 @@ def self.extract_entries(string)

private

# Dumps the $ORIGIN and $TTL directives of this zone (for use by #dump and #dump_pretty).
#
# @api private
def dump_directives
content = ""
content << "$ORIGIN #{origin}\n" unless origin.to_s.empty?
content << "$TTL #{ttl}\n" unless ttl.to_s.empty?
content
end

# Records sorted with more important types being at the top.
#
# @api private
Expand Down
1 change: 1 addition & 0 deletions test/zone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ZoneTest < DNS::Zone::TestCase

# basic zone file example
ZONE_FILE_BASIC_EXAMPLE =<<-EOL
$ORIGIN lividpenguin.com.
@ IN SOA ns0.lividpenguin.com. luke.lividpenguin.com. ( 2013101406 12h 15m 3w 3h )
@ IN NS ns0.lividpenguin.com.
@ IN MX 10 mail
Expand Down