simianarmy-feedzirra 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
data/lib/feedzirra.rb CHANGED
@@ -30,5 +30,5 @@ require 'feedzirra/parser/atom'
30
30
  require 'feedzirra/parser/atom_feed_burner'
31
31
 
32
32
  module Feedzirra
33
- VERSION = "0.0.13"
33
+ VERSION = "0.0.16"
34
34
  end
@@ -96,7 +96,7 @@ module Feedzirra
96
96
  curl.on_success do |c|
97
97
  responses[url] = decode_content(c)
98
98
  end
99
- curl.on_failure do |c|
99
+ curl.on_failure do |c, err|
100
100
  responses[url] = c.response_code
101
101
  end
102
102
  end
@@ -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
 
@@ -27,6 +27,11 @@ module Feedzirra
27
27
  element :updated
28
28
  element :modified, :as => :updated
29
29
  elements :category, :as => :categories, :value => :term
30
+ elements :link, :as => :links, :value => :href
31
+
32
+ def url
33
+ @url || links.first
34
+ end
30
35
  end
31
36
 
32
37
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simianarmy-feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Mauger