pauldix-feedzirra 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/feedzirra.rb +1 -1
- data/lib/feedzirra/parser/atom.rb +9 -0
- data/spec/feedzirra/parser/atom_spec.rb +8 -0
- metadata +1 -1
data/lib/feedzirra.rb
CHANGED
@@ -15,11 +15,20 @@ module Feedzirra
|
|
15
15
|
element :title
|
16
16
|
element :link, :as => :url, :value => :href, :with => {:type => "text/html"}
|
17
17
|
element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"}
|
18
|
+
elements :link, :as => :links, :value => :href
|
18
19
|
elements :entry, :as => :entries, :class => AtomEntry
|
19
20
|
|
20
21
|
def self.able_to_parse?(xml) #:nodoc:
|
21
22
|
xml =~ /(Atom)|(#{Regexp.escape("http://purl.org/atom")})/
|
22
23
|
end
|
24
|
+
|
25
|
+
def url
|
26
|
+
@url || links.last
|
27
|
+
end
|
28
|
+
|
29
|
+
def feed_url
|
30
|
+
@feed_url || links.first
|
31
|
+
end
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
@@ -24,6 +24,14 @@ describe Feedzirra::Parser::Atom do
|
|
24
24
|
@feed.url.should == "http://aws.typepad.com/aws/"
|
25
25
|
end
|
26
26
|
|
27
|
+
it "should parse the url even when it doesn't have the type='text/html' attribute" do
|
28
|
+
Feedzirra::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml")).url.should == "http://www.innoq.com/planet/"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should parse the feed_url even when it doesn't have the type='application/atom+xml' attribute" do
|
32
|
+
Feedzirra::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml")).feed_url.should == "http://www.innoq.com/planet/atom.xml"
|
33
|
+
end
|
34
|
+
|
27
35
|
it "should parse the feed_url" do
|
28
36
|
@feed.feed_url.should == "http://aws.typepad.com/aws/atom.xml"
|
29
37
|
end
|