lib/boxcars/x_node.rb in boxcars-0.3.2 vs lib/boxcars/x_node.rb in boxcars-0.3.3

- old
+ new

@@ -8,11 +8,10 @@ def initialize(node) @node = node @valid_names = [] @children = {} - # @attributes = node.attributes.transform_values(&:value) @attributes = node.attributes.values.to_h { |a| [a.name.to_sym, a.value] } node.children.each do |child| next if child.text? @@ -28,11 +27,16 @@ end end def self.from_xml(xml) doc = Nokogiri::XML.parse(xml) - raise XmlError, "XML is not valid: #{doc.errors.map { |e| "#{e.line}:#{e.column} #{e.message}" }}" if doc.errors.any? - + if doc.errors.any? + Boxcars.debug("XML: #{xml}", :yellow) + # rubocop:disable Lint/Debugger + debugger if ENV.fetch("DEBUG_XML", false) + # rubocop:enable Lint/Debugger + raise XmlError, "XML is not valid: #{doc.errors.map { |e| "#{e.line}:#{e.column} #{e.message}" }}" + end XNode.new(doc.root) end def xml @node.to_xml