simianarmy-feedzirra 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/feedzirra.rb +1 -1
- data/lib/feedzirra/feed.rb +1 -1
- data/lib/feedzirra/parser/atom.rb +9 -0
- data/lib/feedzirra/parser/atom_entry.rb +5 -0
- data/lib/feedzirra/parser/rss_entry.rb +2 -0
- data/spec/feedzirra/parser/atom_entry_spec.rb +4 -0
- data/spec/feedzirra/parser/atom_spec.rb +8 -0
- metadata +1 -1
data/lib/feedzirra.rb
CHANGED
data/lib/feedzirra/feed.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
|
|
@@ -19,10 +19,12 @@ module Feedzirra
|
|
19
19
|
element :link, :as => :url
|
20
20
|
|
21
21
|
element :"dc:creator", :as => :author
|
22
|
+
element :author, :as => :author
|
22
23
|
element :"content:encoded", :as => :content
|
23
24
|
element :description, :as => :summary
|
24
25
|
|
25
26
|
element :pubDate, :as => :published
|
27
|
+
element :pubdate, :as => :published
|
26
28
|
element :"dc:date", :as => :published
|
27
29
|
element :"dc:Date", :as => :published
|
28
30
|
element :"dcterms:created", :as => :published
|
@@ -15,6 +15,10 @@ describe Feedzirra::Parser::AtomEntry do
|
|
15
15
|
@entry.url.should == "http://aws.typepad.com/aws/2009/01/aws-job-architect-designer-position-in-turkey.html"
|
16
16
|
end
|
17
17
|
|
18
|
+
it "should parse the url even when" do
|
19
|
+
Feedzirra::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml")).entries.first.url.should == "http://www.innoq.com/blog/phaus/2009/07/ja.html"
|
20
|
+
end
|
21
|
+
|
18
22
|
it "should parse the author" do
|
19
23
|
@entry.author.should == "AWS Editor"
|
20
24
|
end
|
@@ -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
|