class VagrantPlugins::ProviderLibvirt::Util::Xml
Attributes
Public Class Methods
Source
# File lib/vagrant-libvirt/util/xml.rb, line 11 def initialize(xmlstr) @xml = compact_content(XmlSimple.xml_in(xmlstr, {'NormaliseSpace' => 2})) end
Public Instance Methods
Source
# File lib/vagrant-libvirt/util/xml.rb, line 19 def ==(other) @xml == other.xml end
Source
# File lib/vagrant-libvirt/util/xml.rb, line 15 def to_str XmlSimple.xml_out(@xml) end
Private Instance Methods
Source
# File lib/vagrant-libvirt/util/xml.rb, line 28 def compact_content(node) if node.is_a?(Array) node.map! do |element| compact_content(element) end elsif node.is_a?(Hash) if node['content'] and node['content'].empty? node.delete('content') end node.each do |k, v| node[k] = compact_content(v) end else return node end end
content elements that are empty are preserved by xml-simple and will result in the structures being considered different even if functionality the same strip any empty ones to avoid.