lib/feedjira/parser/atom.rb in feedjira-2.0.0 vs lib/feedjira/parser/atom.rb in feedjira-2.1.0
- old
+ new
@@ -2,19 +2,20 @@
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 => {:rel => "self"}
- elements :link, :as => :links, :value => :href
- elements :link, :as => :hubs, :value => :href, :with => {:rel => "hub"}
- elements :entry, :as => :entries, :class => AtomEntry
+ element :subtitle, as: :description
+ element :link, as: :url, value: :href, with: { type: 'text/html' }
+ element :link, as: :feed_url, value: :href, with: { rel: 'self' }
+ 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
+ def self.able_to_parse?(xml)
+ %r{\<feed[^\>]+xmlns\s?=\s?[\"\'](http://www\.w3\.org/2005/Atom|http://purl\.org/atom/ns\#)[\"\'][^\>]*\>} =~ xml # rubocop:disable Metrics/LineLength
end
def url
@url || (links - [feed_url]).last || links.last
end