lib/atomic/entry.rb in exempla-atomic-0.0.2 vs lib/atomic/entry.rb in exempla-atomic-0.0.3

- old
+ new

@@ -8,45 +8,41 @@ class << self def parse(xml) - namespaces = { "xmlns:atom" => "http://www.w3.org/2005/Atom", - "xmlns:app" => "http://www.w3.org/2007/app", - "xmlns:cirrus" => "http://www.glam.ac.uk/2009/cirrus" } - doc = Nokogiri.XML(xml) # puts("================================================================") # puts("XML Document") # puts("================================================================") # puts(doc) # puts("================================================================") - entry_xml = doc.xpath('//atom:entry', namespaces).first + entry_xml = doc.xpath('//atom:entry', NAMESPACES).first attributes = {} - attributes[:id] = entry_xml.xpath('atom:id', namespaces).first.text - attributes[:title] = entry_xml.xpath('atom:title', namespaces).first.text - attributes[:created_at] = entry_xml.xpath('atom:published', namespaces).first.text - attributes[:updated_at] = entry_xml.xpath('atom:updated', namespaces).first.text + attributes[:id] = entry_xml.xpath('atom:id', NAMESPACES).first.text + attributes[:title] = entry_xml.xpath('atom:title', NAMESPACES).first.text + attributes[:created_at] = entry_xml.xpath('atom:published', NAMESPACES).first.text + attributes[:updated_at] = entry_xml.xpath('atom:updated', NAMESPACES).first.text - content_xml = entry_xml.xpath('atom:content', namespaces).first + content_xml = entry_xml.xpath('atom:content', NAMESPACES).first if (content_xml['type'] == 'application/xml') attributes[:content] = {} - announcement_xml = content_xml.xpath('cirrus:announcement', namespaces).first + announcement_xml = content_xml.xpath('cirrus:announcement', NAMESPACES).first unless announcement_xml.nil? - attributes[:content][:message] = announcement_xml.xpath('cirrus:message', namespaces).first.text - attributes[:content][:starts_at] = announcement_xml.xpath('cirrus:starts-at', namespaces).first.text - attributes[:content][:ends_at] = announcement_xml.xpath('cirrus:ends-at', namespaces).first.text + attributes[:content][:message] = announcement_xml.xpath('cirrus:message', NAMESPACES).first.text + attributes[:content][:starts_at] = announcement_xml.xpath('cirrus:starts-at', NAMESPACES).first.text + attributes[:content][:ends_at] = announcement_xml.xpath('cirrus:ends-at', NAMESPACES).first.text end else attributes[:content] = content_xml.inner_html end attributes[:categories] = [] - entry_xml.xpath('atom:category', namespaces).each do |category_node| + entry_xml.xpath('atom:category', NAMESPACES).each do |category_node| attributes[:categories] << {:term => category_node['term'], :scheme => category_node['scheme']} end new(attributes) end