Sha256: e937282e374a192e02b5f42360c48e32f1db01bc0d366dee1ae2f83b4cf67210
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
module Feedjira module Parser # Parser for dealing with Atom feeds. class Atom include SAXMachine include FeedUtilities element :title element :subtitle, :as => :description element :link, :as => :url, :value => :href, :with => {:type => "text/html"} element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"} elements :link, :as => :links, :value => :href elements :link, :as => :hubs, :value => :href, :with => {:rel => "hub"} elements :entry, :as => :entries, :class => AtomEntry def self.able_to_parse?(xml) #:nodoc: /\<feed[^\>]+xmlns\s?=\s?[\"|\'](http:\/\/www\.w3\.org\/2005\/Atom|http:\/\/purl\.org\/atom\/ns\#)[\"|\'][^\>]*\>/ =~ xml end def url @url || links.last end def feed_url @feed_url ||= links.first end def self.preprocess(xml) Preprocessor.new(xml).to_xml end class Preprocessor def initialize(xml) @xml = xml end def to_xml process_nodes doc.to_xml end private def process_nodes nodes.each { |node| node.content = raw_html(node) unless node.cdata? } end def nodes doc.search 'entry > content[type="xhtml"]' end def raw_html(node) CGI.unescape_html node.inner_html end def doc @doc ||= Nokogiri::XML @xml end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
feedjira-1.1.0 | lib/feedjira/parser/atom.rb |
feedjira-1.0.0 | lib/feedjira/parser/atom.rb |
feedjira-0.9.0 | lib/feedjira/parser/atom.rb |