Class: Zonesync::Record
- Inherits:
-
Struct
- Object
- Struct
- Zonesync::Record
- Defined in:
- lib/zonesync/record.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rdata ⇒ Object
Returns the value of attribute rdata.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .from_dns_zonefile_record(record) ⇒ Object
- .non_meta(records) ⇒ Object
- .single_record_per_name?(type) ⇒ Boolean
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #checksum? ⇒ Boolean
- #conflicts_with?(other) ⇒ Boolean
- #identical_to?(other) ⇒ Boolean
- #manifest? ⇒ Boolean
- #short_name(origin) ⇒ Object
- #to_s ⇒ Object
- #to_sortable ⇒ Object
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment
4 5 6 |
# File 'lib/zonesync/record.rb', line 4 def comment @comment end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/zonesync/record.rb', line 4 def name @name end |
#rdata ⇒ Object
Returns the value of attribute rdata
4 5 6 |
# File 'lib/zonesync/record.rb', line 4 def rdata @rdata end |
#ttl ⇒ Object
Returns the value of attribute ttl
4 5 6 |
# File 'lib/zonesync/record.rb', line 4 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/zonesync/record.rb', line 4 def type @type end |
Class Method Details
.from_dns_zonefile_record(record) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/zonesync/record.rb', line 8 def self.from_dns_zonefile_record(record) new( name: record.host, type: record.type, ttl: record.ttl, rdata: record.rdata, comment: record.comment, ) end |
.non_meta(records) ⇒ Object
63 64 65 |
# File 'lib/zonesync/record.rb', line 63 def self.(records) records.reject { |r| r.manifest? || r.checksum? } end |
.single_record_per_name?(type) ⇒ Boolean
59 60 61 |
# File 'lib/zonesync/record.rb', line 59 def self.single_record_per_name?(type) type == "CNAME" || type == "SOA" end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 |
# File 'lib/zonesync/record.rb', line 35 def <=>(other) to_sortable <=> other.to_sortable end |
#checksum? ⇒ Boolean
30 31 32 33 |
# File 'lib/zonesync/record.rb', line 30 def checksum? type == "TXT" && name.match?(/^zonesync_checksum\./) end |
#conflicts_with?(other) ⇒ Boolean
54 55 56 57 |
# File 'lib/zonesync/record.rb', line 54 def conflicts_with?(other) return false unless name == other.name && type == other.type Record.single_record_per_name?(type) end |
#identical_to?(other) ⇒ Boolean
50 51 52 |
# File 'lib/zonesync/record.rb', line 50 def identical_to?(other) name == other.name && type == other.type && ttl == other.ttl && rdata == other.rdata end |
#manifest? ⇒ Boolean
25 26 27 28 |
# File 'lib/zonesync/record.rb', line 25 def manifest? type == "TXT" && name.match?(/^zonesync_manifest\./) end |
#short_name(origin) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/zonesync/record.rb', line 18 def short_name(origin) ret = name.sub(origin, "") ret = ret.sub(/\.$/, "") ret = "@" if ret == "" ret end |
#to_s ⇒ Object
44 45 46 47 48 |
# File 'lib/zonesync/record.rb', line 44 def to_s string = [name, ttl, type, rdata].join(" ") string << " ; #{comment}" if comment string end |
#to_sortable ⇒ Object
39 40 41 42 |
# File 'lib/zonesync/record.rb', line 39 def to_sortable is_soa = type == "SOA" ? 0 : 1 [is_soa, type, name, rdata, ttl.to_i] end |