astro-feedzirra 0.0.8.20090419 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +169 -0
- data/README.textile +9 -2
- data/Rakefile +3 -0
- data/lib/feedzirra.rb +11 -10
- data/lib/feedzirra/feed.rb +37 -41
- data/lib/feedzirra/feed_entry_utilities.rb +6 -0
- data/lib/feedzirra/parser/atom.rb +26 -0
- data/lib/feedzirra/parser/atom_entry.rb +34 -0
- data/lib/feedzirra/parser/atom_feed_burner.rb +27 -0
- data/lib/feedzirra/parser/atom_feed_burner_entry.rb +35 -0
- data/lib/feedzirra/parser/itunes_rss.rb +50 -0
- data/lib/feedzirra/parser/itunes_rss_item.rb +32 -0
- data/lib/feedzirra/parser/itunes_rss_owner.rb +12 -0
- data/lib/feedzirra/parser/rss.rb +28 -0
- data/lib/feedzirra/parser/rss_entry.rb +40 -0
- data/lib/feedzirra/push_parser.rb +56 -0
- data/spec/feedzirra/feed_spec.rb +40 -32
- data/spec/feedzirra/feed_utilities_spec.rb +9 -9
- data/spec/feedzirra/{atom_entry_spec.rb → parser/atom_entry_spec.rb} +3 -3
- data/spec/feedzirra/{atom_feed_burner_entry_spec.rb → parser/atom_feed_burner_entry_spec.rb} +4 -4
- data/spec/feedzirra/{atom_feed_burner_spec.rb → parser/atom_feed_burner_spec.rb} +6 -6
- data/spec/feedzirra/{atom_spec.rb → parser/atom_spec.rb} +5 -5
- data/spec/feedzirra/{itunes_rss_item_spec.rb → parser/itunes_rss_item_spec.rb} +8 -4
- data/spec/feedzirra/{itunes_rss_owner_spec.rb → parser/itunes_rss_owner_spec.rb} +3 -3
- data/spec/feedzirra/{itunes_rss_spec.rb → parser/itunes_rss_spec.rb} +5 -5
- data/spec/feedzirra/{rss_entry_spec.rb → parser/rss_entry_spec.rb} +3 -3
- data/spec/feedzirra/{rss_spec.rb → parser/rss_spec.rb} +5 -5
- data/spec/feedzirra/push_parser_spec.rb +16 -0
- metadata +28 -25
- data/lib/feedzirra/atom.rb +0 -22
- data/lib/feedzirra/atom_entry.rb +0 -29
- data/lib/feedzirra/atom_feed_burner.rb +0 -22
- data/lib/feedzirra/atom_feed_burner_entry.rb +0 -30
- data/lib/feedzirra/itunes_rss.rb +0 -46
- data/lib/feedzirra/itunes_rss_item.rb +0 -28
- data/lib/feedzirra/itunes_rss_owner.rb +0 -8
- data/lib/feedzirra/rss.rb +0 -23
- data/lib/feedzirra/rss_entry.rb +0 -35
@@ -0,0 +1,27 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# == Summary
|
5
|
+
# Parser for dealing with Feedburner Atom feeds.
|
6
|
+
#
|
7
|
+
# == Attributes
|
8
|
+
# * title
|
9
|
+
# * feed_url
|
10
|
+
# * url
|
11
|
+
# * entries
|
12
|
+
class AtomFeedBurner
|
13
|
+
include SAXMachine
|
14
|
+
include FeedUtilities
|
15
|
+
element :title
|
16
|
+
element :link, :as => :url, :value => :href, :with => {:type => "text/html"}
|
17
|
+
element :link, :as => :feed_url, :value => :href, :with => {:type => "application/atom+xml"}
|
18
|
+
elements :entry, :as => :entries, :class => AtomFeedBurnerEntry
|
19
|
+
|
20
|
+
def self.able_to_parse?(xml) #:nodoc:
|
21
|
+
(xml =~ /Atom/ && xml =~ /feedburner/) || false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# == Summary
|
5
|
+
# Parser for dealing with Feedburner Atom feed entries.
|
6
|
+
#
|
7
|
+
# == Attributes
|
8
|
+
# * title
|
9
|
+
# * url
|
10
|
+
# * author
|
11
|
+
# * content
|
12
|
+
# * summary
|
13
|
+
# * published
|
14
|
+
# * categories
|
15
|
+
class AtomFeedBurnerEntry
|
16
|
+
include SAXMachine
|
17
|
+
include FeedEntryUtilities
|
18
|
+
element :title
|
19
|
+
element :name, :as => :author
|
20
|
+
element :link, :as => :url, :value => :href, :with => {:type => "text/html", :rel => "alternate"}
|
21
|
+
element :"feedburner:origLink", :as => :url
|
22
|
+
element :summary
|
23
|
+
element :content
|
24
|
+
element :published
|
25
|
+
element :id
|
26
|
+
element :issued, :as => :published
|
27
|
+
element :created, :as => :published
|
28
|
+
element :updated
|
29
|
+
element :modified, :as => :updated
|
30
|
+
elements :category, :as => :categories, :value => :term
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# iTunes is RSS 2.0 + some apple extensions
|
5
|
+
# Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
|
6
|
+
class ITunesRSS
|
7
|
+
include SAXMachine
|
8
|
+
include FeedUtilities
|
9
|
+
|
10
|
+
attr_accessor :feed_url
|
11
|
+
|
12
|
+
# RSS 2.0 elements that need including
|
13
|
+
element :copyright
|
14
|
+
element :description
|
15
|
+
element :language
|
16
|
+
element :managingEditor
|
17
|
+
element :title
|
18
|
+
element :link, :as => :url
|
19
|
+
|
20
|
+
# If author is not present use managingEditor on the channel
|
21
|
+
element :"itunes:author", :as => :itunes_author
|
22
|
+
element :"itunes:block", :as => :itunes_block
|
23
|
+
element :"itunes:image", :value => :href, :as => :itunes_image
|
24
|
+
element :"itunes:explicit", :as => :itunes_explicit
|
25
|
+
element :"itunes:keywords", :as => :itunes_keywords
|
26
|
+
# New URL for the podcast feed
|
27
|
+
element :"itunes:new-feed-url", :as => :itunes_new_feed_url
|
28
|
+
element :"itunes:subtitle", :as => :itunes_subtitle
|
29
|
+
# If summary is not present, use the description tag
|
30
|
+
element :"itunes:summary", :as => :itunes_summary
|
31
|
+
|
32
|
+
# iTunes RSS feeds can have multiple main categories...
|
33
|
+
# ...and multiple sub-categories per category
|
34
|
+
# TODO subcategories not supported correctly - they are at the same level
|
35
|
+
# as the main categories
|
36
|
+
elements :"itunes:category", :as => :itunes_categories, :value => :text
|
37
|
+
|
38
|
+
elements :"itunes:owner", :as => :itunes_owners, :class => ITunesRSSOwner
|
39
|
+
|
40
|
+
elements :item, :as => :entries, :class => ITunesRSSItem
|
41
|
+
|
42
|
+
def self.able_to_parse?(xml)
|
43
|
+
xml =~ /xmlns:itunes=\"http:\/\/www.itunes.com\/dtds\/podcast-1.0.dtd\"/
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# iTunes extensions to the standard RSS2.0 item
|
5
|
+
# Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
|
6
|
+
class ITunesRSSItem
|
7
|
+
include SAXMachine
|
8
|
+
include FeedEntryUtilities
|
9
|
+
element :author
|
10
|
+
element :guid
|
11
|
+
element :title
|
12
|
+
element :link, :as => :url
|
13
|
+
element :description, :as => :summary
|
14
|
+
element :pubDate, :as => :published
|
15
|
+
element :"content:encoded", :as => :content
|
16
|
+
|
17
|
+
# If author is not present use author tag on the item
|
18
|
+
element :"itunes:author", :as => :itunes_author
|
19
|
+
element :"itunes:block", :as => :itunes_block
|
20
|
+
element :"itunes:duration", :as => :itunes_duration
|
21
|
+
element :"itunes:explicit", :as => :itunes_explicit
|
22
|
+
element :"itunes:keywords", :as => :itunes_keywords
|
23
|
+
element :"itunes:subtitle", :as => :itunes_subtitle
|
24
|
+
# If summary is not present, use the description tag
|
25
|
+
element :"itunes:summary", :as => :itunes_summary
|
26
|
+
element :enclosure, :value => :length, :as => :enclosure_length
|
27
|
+
element :enclosure, :value => :type, :as => :enclosure_type
|
28
|
+
element :enclosure, :value => :url, :as => :enclosure_url
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# == Summary
|
5
|
+
# Parser for dealing with RSS feeds.
|
6
|
+
#
|
7
|
+
# == Attributes
|
8
|
+
# * title
|
9
|
+
# * feed_url
|
10
|
+
# * url
|
11
|
+
# * entries
|
12
|
+
class RSS
|
13
|
+
include SAXMachine
|
14
|
+
include FeedUtilities
|
15
|
+
element :title
|
16
|
+
element :link, :as => :url
|
17
|
+
elements :item, :as => :entries, :class => RSSEntry
|
18
|
+
|
19
|
+
attr_accessor :feed_url
|
20
|
+
|
21
|
+
def self.able_to_parse?(xml) #:nodoc:
|
22
|
+
xml =~ /\<rss|rdf/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
# == Summary
|
5
|
+
# Parser for dealing with RDF feed entries.
|
6
|
+
#
|
7
|
+
# == Attributes
|
8
|
+
# * title
|
9
|
+
# * url
|
10
|
+
# * author
|
11
|
+
# * content
|
12
|
+
# * summary
|
13
|
+
# * published
|
14
|
+
# * categories
|
15
|
+
class RSSEntry
|
16
|
+
include SAXMachine
|
17
|
+
include FeedEntryUtilities
|
18
|
+
element :title
|
19
|
+
element :link, :as => :url
|
20
|
+
|
21
|
+
element :"dc:creator", :as => :author
|
22
|
+
element :"content:encoded", :as => :content
|
23
|
+
element :description, :as => :summary
|
24
|
+
|
25
|
+
element :pubDate, :as => :published
|
26
|
+
element :"dc:date", :as => :published
|
27
|
+
element :"dc:Date", :as => :published
|
28
|
+
element :"dcterms:created", :as => :published
|
29
|
+
|
30
|
+
|
31
|
+
element :"dcterms:modified", :as => :updated
|
32
|
+
element :issued, :as => :published
|
33
|
+
elements :category, :as => :categories
|
34
|
+
|
35
|
+
element :guid, :as => :id
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
##
|
3
|
+
# Contrary to Feedzirra::Feed, Feedzirra::PushParser doesn't expect
|
4
|
+
# the whole document to be given in one String, but allows
|
5
|
+
# subsequent parsing of chunks.
|
6
|
+
class PushParser
|
7
|
+
##
|
8
|
+
# How many bytes to buffer before starting to parse, helps
|
9
|
+
# Feedzirra's content detection.
|
10
|
+
BUF_MIN_THRESHOLD = 1000
|
11
|
+
|
12
|
+
##
|
13
|
+
# Just resets instance variables
|
14
|
+
def initialize
|
15
|
+
@buf = ''
|
16
|
+
@parser = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Either buffer up til BUF_MIN_THRESHOLD or, if reached, actually
|
21
|
+
# parse a chunk
|
22
|
+
def push(chunk)
|
23
|
+
if @parser
|
24
|
+
@parser.parse(chunk)
|
25
|
+
else
|
26
|
+
@buf += chunk
|
27
|
+
if @buf.size > BUF_MIN_THRESHOLD
|
28
|
+
start_parsing
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Really start parsing, if BUF_MIN_THRESHOLD wasn't reached yet,
|
35
|
+
# finalize, and return the actual parser/document
|
36
|
+
def finish
|
37
|
+
# TODO: if we haven't started yet we won't even need a
|
38
|
+
# PushParser
|
39
|
+
start_parsing unless @parser
|
40
|
+
|
41
|
+
@parser.parse_finish
|
42
|
+
@parser
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def start_parsing
|
48
|
+
unless klass = Feed::determine_feed_parser_for_xml(@buf)
|
49
|
+
raise NoParserAvailable.new("No valid parser for XML.")
|
50
|
+
end
|
51
|
+
@parser = klass.new
|
52
|
+
@parser.parse(@buf)
|
53
|
+
@buf = nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/feedzirra/feed_spec.rb
CHANGED
@@ -11,11 +11,11 @@ describe Feedzirra::Feed do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should parse the added element out of Atom Feedburner feeds" do
|
14
|
-
Feedzirra::AtomEntry.new.should respond_to(:comment_rss)
|
14
|
+
Feedzirra::Parser::AtomEntry.new.should respond_to(:comment_rss)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should parse the added element out of RSS feeds" do
|
18
|
-
Feedzirra::RSSEntry.new.should respond_to(:comment_rss)
|
18
|
+
Feedzirra::Parser::RSSEntry.new.should respond_to(:comment_rss)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -49,11 +49,14 @@ describe Feedzirra::Feed do
|
|
49
49
|
feed.entries.size.should == 5
|
50
50
|
end
|
51
51
|
|
52
|
-
it "should parse an itunes feed" do
|
52
|
+
it "should parse an itunes feed as a standard RSS feed" do
|
53
53
|
feed = Feedzirra::Feed.parse(sample_itunes_feed)
|
54
54
|
feed.title.should == "All About Everything"
|
55
|
-
feed.entries.first.published.
|
56
|
-
|
55
|
+
feed.entries.first.published.should == Time.parse("Wed, 15 Jun 2005 19:00:00 GMT")
|
56
|
+
|
57
|
+
# Since the commit 621957879, iTunes feeds will be parsed as standard RSS, so this
|
58
|
+
# entry should now not have a method for itunes_author.
|
59
|
+
feed.entries.first.should_not respond_to(:itunes_author)
|
57
60
|
feed.entries.size.should == 3
|
58
61
|
end
|
59
62
|
end
|
@@ -75,28 +78,28 @@ describe Feedzirra::Feed do
|
|
75
78
|
end
|
76
79
|
|
77
80
|
describe "#determine_feed_parser_for_xml" do
|
78
|
-
it "should return the Feedzirra::Atom class for an atom feed" do
|
79
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_atom_feed).should == Feedzirra::Atom
|
81
|
+
it "should return the Feedzirra::Parser::Atom class for an atom feed" do
|
82
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_atom_feed).should == Feedzirra::Parser::Atom
|
80
83
|
end
|
81
84
|
|
82
|
-
it "should return the Feedzirra::AtomFeedBurner class for an atom feedburner feed" do
|
83
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_feedburner_atom_feed).should == Feedzirra::AtomFeedBurner
|
85
|
+
it "should return the Feedzirra::Parser::AtomFeedBurner class for an atom feedburner feed" do
|
86
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_feedburner_atom_feed).should == Feedzirra::Parser::AtomFeedBurner
|
84
87
|
end
|
85
88
|
|
86
|
-
it "should return the Feedzirra::RSS class for an rdf/rss 1.0 feed" do
|
87
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rdf_feed).should == Feedzirra::RSS
|
89
|
+
it "should return the Feedzirra::Parser::RSS class for an rdf/rss 1.0 feed" do
|
90
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rdf_feed).should == Feedzirra::Parser::RSS
|
88
91
|
end
|
89
92
|
|
90
|
-
it "should return the Feedzirra::RSS class for an rss feedburner feed" do
|
91
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rss_feed_burner_feed).should == Feedzirra::RSS
|
93
|
+
it "should return the Feedzirra::Parser::RSS class for an rss feedburner feed" do
|
94
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rss_feed_burner_feed).should == Feedzirra::Parser::RSS
|
92
95
|
end
|
93
96
|
|
94
|
-
it "should return the Feedzirra::RSS object for an rss 2.0 feed" do
|
95
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rss_feed).should == Feedzirra::RSS
|
97
|
+
it "should return the Feedzirra::Parser::RSS object for an rss 2.0 feed" do
|
98
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_rss_feed).should == Feedzirra::Parser::RSS
|
96
99
|
end
|
97
100
|
|
98
|
-
it "should return
|
99
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_itunes_feed).should == Feedzirra::
|
101
|
+
it "should return a Feedzirra::Parser::RSS object for an itunes feed" do
|
102
|
+
Feedzirra::Feed.determine_feed_parser_for_xml(sample_itunes_feed).should == Feedzirra::Parser::RSS
|
100
103
|
end
|
101
104
|
|
102
105
|
end
|
@@ -104,7 +107,7 @@ describe Feedzirra::Feed do
|
|
104
107
|
describe "when adding feed types" do
|
105
108
|
it "should prioritize added types over the built in ones" do
|
106
109
|
feed_text = "Atom asdf"
|
107
|
-
Feedzirra::Atom.should be_able_to_parse(feed_text)
|
110
|
+
Feedzirra::Parser::Atom.should be_able_to_parse(feed_text)
|
108
111
|
new_feed_type = Class.new do
|
109
112
|
def self.able_to_parse?(val)
|
110
113
|
true
|
@@ -160,7 +163,7 @@ describe Feedzirra::Feed do
|
|
160
163
|
@cmock = stub('cmock', :header_str => '', :body_str => @paul_feed[:xml] )
|
161
164
|
@multi = stub('curl_multi', :add => true, :perform => true)
|
162
165
|
@curl_easy = stub('curl_easy')
|
163
|
-
@curl = stub('curl', :headers => {}, :follow_location= => true, :on_failure => true)
|
166
|
+
@curl = stub('curl', :headers => {}, :follow_location= => true, :on_failure => true, :timeout= => true)
|
164
167
|
@curl.stub!(:on_success).and_yield(@cmock)
|
165
168
|
|
166
169
|
Curl::Multi.stub!(:new).and_return(@multi)
|
@@ -193,7 +196,7 @@ describe Feedzirra::Feed do
|
|
193
196
|
end
|
194
197
|
|
195
198
|
it 'should set accepted encodings' do
|
196
|
-
Feedzirra::Feed.fetch_raw(@paul_feed[:url])
|
199
|
+
Feedzirra::Feed.fetch_raw(@paul_feed[:url], :compress => true)
|
197
200
|
@curl.headers["Accept-encoding"].should == 'gzip, deflate'
|
198
201
|
end
|
199
202
|
|
@@ -206,12 +209,12 @@ describe Feedzirra::Feed do
|
|
206
209
|
Curl::Multi.stub!(:new).and_return(multi)
|
207
210
|
|
208
211
|
paul_response = stub('paul_response', :header_str => '', :body_str => @paul_feed[:xml] )
|
209
|
-
trotter_response = stub('trotter_response', :header_str => '', :body_str => @trotter_feed[:xml]
|
212
|
+
trotter_response = stub('trotter_response', :header_str => '', :body_str => @trotter_feed[:xml])
|
210
213
|
|
211
|
-
paul_curl = stub('paul_curl', :headers => {}, :follow_location= => true, :on_failure => true)
|
214
|
+
paul_curl = stub('paul_curl', :headers => {}, :follow_location= => true, :on_failure => true, :timeout= => true)
|
212
215
|
paul_curl.stub!(:on_success).and_yield(paul_response)
|
213
216
|
|
214
|
-
trotter_curl = stub('trotter_curl', :headers => {}, :follow_location= => true, :on_failure => true)
|
217
|
+
trotter_curl = stub('trotter_curl', :headers => {}, :follow_location= => true, :on_failure => true, :timeout= => true)
|
215
218
|
trotter_curl.stub!(:on_success).and_yield(trotter_response)
|
216
219
|
|
217
220
|
Curl::Easy.should_receive(:new).with(@paul_feed[:url]).ordered.and_yield(paul_curl)
|
@@ -253,7 +256,7 @@ describe Feedzirra::Feed do
|
|
253
256
|
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse("Jan 25 2009 04:10:32 GMT"))
|
254
257
|
@easy_curl.headers["If-Modified-Since"].should == 'Sun, 25 Jan 2009 04:10:32 GMT'
|
255
258
|
end
|
256
|
-
|
259
|
+
|
257
260
|
it 'should set follow location to true' do
|
258
261
|
@easy_curl.should_receive(:follow_location=).with(true)
|
259
262
|
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
|
@@ -265,7 +268,7 @@ describe Feedzirra::Feed do
|
|
265
268
|
end
|
266
269
|
|
267
270
|
it 'should set accepted encodings' do
|
268
|
-
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
|
271
|
+
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {:compress => true})
|
269
272
|
@easy_curl.headers["Accept-encoding"].should == 'gzip, deflate'
|
270
273
|
end
|
271
274
|
|
@@ -278,8 +281,8 @@ describe Feedzirra::Feed do
|
|
278
281
|
before(:each) do
|
279
282
|
@feed = mock('feed', :feed_url= => true, :etag= => true, :last_modified= => true)
|
280
283
|
Feedzirra::Feed.stub!(:decode_content).and_return(@paul_feed[:xml])
|
281
|
-
Feedzirra::Feed.stub!(:determine_feed_parser_for_xml).and_return(Feedzirra::AtomFeedBurner)
|
282
|
-
Feedzirra::AtomFeedBurner.stub!(:parse).and_return(@feed)
|
284
|
+
Feedzirra::Feed.stub!(:determine_feed_parser_for_xml).and_return(Feedzirra::Parser::AtomFeedBurner)
|
285
|
+
Feedzirra::Parser::AtomFeedBurner.stub!(:parse).and_return(@feed)
|
283
286
|
Feedzirra::Feed.stub!(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
|
284
287
|
Feedzirra::Feed.stub!(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
|
285
288
|
end
|
@@ -291,13 +294,13 @@ describe Feedzirra::Feed do
|
|
291
294
|
end
|
292
295
|
|
293
296
|
it 'should determine the xml parser class' do
|
294
|
-
Feedzirra::Feed.should_receive(:determine_feed_parser_for_xml).with(@paul_feed[:xml]).and_return(Feedzirra::AtomFeedBurner)
|
297
|
+
Feedzirra::Feed.should_receive(:determine_feed_parser_for_xml).with(@paul_feed[:xml]).and_return(Feedzirra::Parser::AtomFeedBurner)
|
295
298
|
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
|
296
299
|
@easy_curl.on_success.call(@easy_curl)
|
297
300
|
end
|
298
301
|
|
299
302
|
it 'should parse the xml' do
|
300
|
-
Feedzirra::AtomFeedBurner.should_receive(:parse).with(@paul_feed[:xml]).and_return(@feed)
|
303
|
+
Feedzirra::Parser::AtomFeedBurner.should_receive(:parse).with(@paul_feed[:xml]).and_return(@feed)
|
301
304
|
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
|
302
305
|
@easy_curl.on_success.call(@easy_curl)
|
303
306
|
end
|
@@ -394,6 +397,11 @@ describe Feedzirra::Feed do
|
|
394
397
|
|
395
398
|
it "should set if modified since as an option if passed"
|
396
399
|
|
400
|
+
it "should set timeout to the right value" do
|
401
|
+
@easy_curl.should_receive(:timeout=).with(8)
|
402
|
+
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {:timeout => 8})
|
403
|
+
end
|
404
|
+
|
397
405
|
it 'should set follow location to true' do
|
398
406
|
@easy_curl.should_receive(:follow_location=).with(true)
|
399
407
|
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
|
@@ -415,8 +423,8 @@ describe Feedzirra::Feed do
|
|
415
423
|
@new_feed = @feed.clone
|
416
424
|
@feed.stub!(:update_from_feed)
|
417
425
|
Feedzirra::Feed.stub!(:decode_content).and_return(@paul_feed[:xml])
|
418
|
-
Feedzirra::Feed.stub!(:determine_feed_parser_for_xml).and_return(Feedzirra::AtomFeedBurner)
|
419
|
-
Feedzirra::AtomFeedBurner.stub!(:parse).and_return(@new_feed)
|
426
|
+
Feedzirra::Feed.stub!(:determine_feed_parser_for_xml).and_return(Feedzirra::Parser::AtomFeedBurner)
|
427
|
+
Feedzirra::Parser::AtomFeedBurner.stub!(:parse).and_return(@new_feed)
|
420
428
|
Feedzirra::Feed.stub!(:etag_from_header).and_return('ziEyTl4q9GH04BR4jgkImd0GvSE')
|
421
429
|
Feedzirra::Feed.stub!(:last_modified_from_header).and_return('Wed, 28 Jan 2009 04:10:32 GMT')
|
422
430
|
end
|
@@ -424,7 +432,7 @@ describe Feedzirra::Feed do
|
|
424
432
|
it 'should process the next feed in the queue'
|
425
433
|
|
426
434
|
it 'should parse the updated feed' do
|
427
|
-
Feedzirra::AtomFeedBurner.should_receive(:parse).and_return(@new_feed)
|
435
|
+
Feedzirra::Parser::AtomFeedBurner.should_receive(:parse).and_return(@new_feed)
|
428
436
|
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
|
429
437
|
@easy_curl.on_success.call(@easy_curl)
|
430
438
|
end
|