X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a41d500b9f65ec9f4e848effd38dc1ae117e7594..85bf0af4886f155e8521a6ccffedfa845133b611:/app/models/changeset.rb?ds=sidebyside diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 990eae407..aa674ea7f 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -80,19 +80,21 @@ class Changeset < ApplicationRecord self.closed_at = Time.now.getutc if is_open? end - def self.from_xml(xml, create = false) + def self.from_xml(xml, create: false) p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse + pt = doc.find_first("//osm/changeset") - doc.find("//osm/changeset").each do |pt| - return Changeset.from_xml_node(pt, create) + if pt + Changeset.from_xml_node(pt, :create => create) + else + raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.") end - raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.") rescue LibXML::XML::Error, ArgumentError => e raise OSM::APIBadXMLError.new("changeset", xml, e.message) end - def self.from_xml_node(pt, create = false) + def self.from_xml_node(pt, create: false) cs = Changeset.new if create cs.created_at = Time.now.getutc