lib/resync/xml.rb in resync-0.2.0 vs lib/resync/xml.rb in resync-0.2.1

- old
+ new

@@ -13,11 +13,13 @@ # # @param url [URI, String] the URI. # @raise [URI::InvalidURIError] if +url+ cannot be converted to a URI. def self.to_uri(url) return nil unless url - (url.is_a? URI) ? url : URI.parse(url) + return url if url.is_a? URI + stripped = url.respond_to?(:strip) ? url.strip : url.to_s.strip + URI.parse(stripped) end # Extracts a +REXML::Element+ from the specified object. # # @param xml [String, IO, REXML::Document, REXML::Element] A string or IO-like @@ -89,10 +91,11 @@ args end # Implements +::XML::Mapping::SingleAttributeNode#extract_attr_value+. def extract_attr_value(xml) - URI(default_when_xpath_err { @path.first(xml).text }) + val = default_when_xpath_err { @path.first(xml).text } + URI(val.strip) end # Implements +::XML::Mapping::SingleAttributeNode#set_attr_value+. def set_attr_value(xml, value) @path.first(xml, ensure_created: true).text = value.to_s