mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Nameserver deserializer
This commit is contained in:
parent
b39de0885a
commit
7459d7e0c5
4 changed files with 53 additions and 21 deletions
37
lib/deserializers/xml/nameserver.rb
Normal file
37
lib/deserializers/xml/nameserver.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Deserializers
|
||||
module Xml
|
||||
class Nameserver
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame
|
||||
end
|
||||
|
||||
def call
|
||||
{
|
||||
hostname: frame.css('hostName').text,
|
||||
ipv4: frame.css('hostAddr[ip="v4"]').map(&:text).compact,
|
||||
ipv6: frame.css('hostAddr[ip="v6"]').map(&:text).compact
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
class Nameservers
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame
|
||||
end
|
||||
|
||||
def call
|
||||
res = []
|
||||
frame.css('hostAttr').each do |ns|
|
||||
ns = Deserializers::Xml::Nameserver.new(ns).call
|
||||
res << ns.delete_if { |_k, v| v.blank? }
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue