feedzirra 0.1.3 → 0.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.travis.yml +7 -0
- data/Gemfile +9 -0
- data/Guardfile +6 -0
- data/HISTORY.md +19 -0
- data/{README.rdoc → README.md} +28 -26
- data/Rakefile +5 -50
- data/feedzirra.gemspec +29 -0
- data/lib/feedzirra.rb +3 -5
- data/lib/feedzirra/feed.rb +1 -3
- data/lib/feedzirra/feed_utilities.rb +14 -3
- data/lib/feedzirra/version.rb +1 -1
- data/spec/feedzirra/feed_entry_utilities_spec.rb +1 -1
- data/spec/feedzirra/feed_spec.rb +13 -11
- data/spec/feedzirra/feed_utilities_spec.rb +0 -2
- data/spec/feedzirra/parser/atom_entry_spec.rb +2 -2
- data/spec/feedzirra/parser/atom_feed_burner_entry_spec.rb +1 -1
- data/spec/feedzirra/parser/itunes_rss_item_spec.rb +1 -1
- data/spec/feedzirra/parser/rss_entry_spec.rb +1 -1
- data/spec/feedzirra/parser/rss_feed_burner_entry_spec.rb +1 -1
- data/spec/sample_feeds/AmazonWebServicesBlog.xml +796 -0
- data/spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml +63 -0
- data/spec/sample_feeds/FeedBurnerUrlNoAlternate.xml +27 -0
- data/spec/sample_feeds/GoogleDocsList.xml +187 -0
- data/spec/sample_feeds/HREFConsideredHarmful.xml +313 -0
- data/spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml +22 -0
- data/spec/sample_feeds/PaulDixExplainsNothing.xml +174 -0
- data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +174 -0
- data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +19 -0
- data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -0
- data/spec/sample_feeds/TechCrunch.xml +1514 -0
- data/spec/sample_feeds/TechCrunchFirstEntry.xml +9 -0
- data/spec/sample_feeds/TechCrunchFirstEntryDescription.xml +3 -0
- data/spec/sample_feeds/TenderLovemaking.xml +515 -0
- data/spec/sample_feeds/TenderLovemakingFirstEntry.xml +66 -0
- data/spec/sample_feeds/TrotterCashionHome.xml +610 -0
- data/spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml +30 -0
- data/spec/sample_feeds/itunes.xml +60 -0
- data/spec/sample_feeds/top5kfeeds.dat +2170 -0
- data/spec/sample_feeds/trouble_feeds.txt +16 -0
- data/spec/spec_helper.rb +7 -18
- metadata +99 -63
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# 0.2.0.rc1
|
2
|
+
* Remove ActiveSupport dependency
|
3
|
+
* No longer tethered to any version of Rails!
|
4
|
+
* Update curb (v0.8.0) and rspec (v2.10.0)
|
5
|
+
* Revert [3008ceb](https://github.com/pauldix/feedzirra/commit/3008ceb338df1f4c37a211d0aab8a6ad4f584dbc)
|
6
|
+
* Add Travis-CI integration
|
7
|
+
* General repository and gem maintenance
|
8
|
+
|
9
|
+
# 0.1.3
|
10
|
+
* ?
|
11
|
+
|
12
|
+
# 0.1.2
|
13
|
+
* ?
|
14
|
+
|
15
|
+
# 0.1.1
|
16
|
+
* make FeedEntries enumerable (patch by Daniel Gregoire)
|
17
|
+
|
18
|
+
# 0.1.0
|
19
|
+
* lower builder requirement to make it rails-3 friendly
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
# Feedzirra
|
2
2
|
|
3
|
-
I'd like feedback on the api and any bugs encountered on feeds in the wild. I've set up a
|
3
|
+
I'd like feedback on the api and any bugs encountered on feeds in the wild. I've set up a [google group here](http://groups.google.com/group/feedzirra).
|
4
4
|
|
5
|
-
|
5
|
+
## Description
|
6
6
|
|
7
|
-
Feedzirra is a feed library that is designed to get and update many feeds as quickly as possible. This includes using libcurl-multi through the
|
7
|
+
Feedzirra is a feed library that is designed to get and update many feeds as quickly as possible. This includes using libcurl-multi through the [curb](https://github.com/taf2/curb) gem for faster http gets, and libxml through [nokogiri](https://github.com/tenderlove/nokogiri) and [sax-machine](https://github.com/pauldix/sax-machine) for faster parsing.
|
8
8
|
|
9
9
|
Once you have fetched feeds using Feedzirra, they can be updated using the feed objects. Feedzirra automatically inserts etag and last-modified information from the http response headers to lower bandwidth usage, eliminate unnecessary parsing, and make things speedier in general.
|
10
10
|
|
@@ -14,13 +14,13 @@ The fetching and parsing logic have been decoupled so that either of them can be
|
|
14
14
|
|
15
15
|
The final feature of Feedzirra is the ability to define custom parsing classes. In truth, Feedzirra could be used to parse much more than feeds. Microformats, page scraping, and almost anything else are fair game.
|
16
16
|
|
17
|
-
|
17
|
+
## Speedup date parsing
|
18
18
|
|
19
|
-
In MRI the date parsing code is written in ruby and is optimized for readability over speed, to speed up this part you can install the
|
19
|
+
In MRI the date parsing code is written in ruby and is optimized for readability over speed, to speed up this part you can install the [home_run](https://github.com/jeremyevans/home_run) gem to replace it with an optimized C version.
|
20
20
|
|
21
|
-
|
21
|
+
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
[A gist of the following code](http://gist.github.com/57285)
|
24
24
|
|
25
25
|
require 'feedzirra'
|
26
26
|
|
@@ -70,24 +70,24 @@ In MRI the date parsing code is written in ruby and is optimized for readability
|
|
70
70
|
|
71
71
|
# defining custom behavior on failure or success. note that a return status of 304 (not updated) will call the on_success handler
|
72
72
|
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing",
|
73
|
-
:on_success => lambda
|
74
|
-
:on_failure => lambda
|
73
|
+
:on_success => lambda [|url, feed| puts feed.title ],
|
74
|
+
:on_failure => lambda [|url, response_code, response_header, response_body| puts response_body ])
|
75
75
|
# if a collection was passed into fetch_and_parse, the handlers will be called for each one
|
76
76
|
|
77
77
|
# the behavior for the handlers when using Feedzirra::Feed.update is slightly different. The feed passed into on_success will be
|
78
78
|
# the updated feed with the standard updated accessors. on failure it will be the original feed object passed into update
|
79
79
|
|
80
80
|
# fetching a feed via a proxy (optional)
|
81
|
-
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing",
|
81
|
+
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing", [:proxy_url => '10.0.0.1', :proxy_port => 3084])
|
82
82
|
|
83
|
-
|
83
|
+
## Extending
|
84
84
|
|
85
|
-
|
85
|
+
### Adding a feed parsing class
|
86
86
|
|
87
87
|
# Adds a new feed parsing class, this class will be used first
|
88
88
|
Feedzirra::Feed.add_feed_class MyFeedClass
|
89
89
|
|
90
|
-
|
90
|
+
### Adding attributes to all feeds types / all entries types
|
91
91
|
|
92
92
|
# Add the generator attribute to all feed types
|
93
93
|
Feedzirra::Feed.add_common_feed_element('generator')
|
@@ -96,10 +96,10 @@ In MRI the date parsing code is written in ruby and is optimized for readability
|
|
96
96
|
# Add some GeoRss information
|
97
97
|
Feedzirra::Feed.add_common_feed_entry_element('geo:lat', :as => :lat)
|
98
98
|
Feedzirra::Feed.fetch_and_parse("http://www.earthpublisher.com/georss.php").entries.each do |e|
|
99
|
-
p "lat: #
|
99
|
+
p "lat: #[e.lat}, long: #{e.long]"
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
### Adding attributes to only one class
|
103
103
|
|
104
104
|
If you want to add attributes for only on class you simply have to declare them in the class
|
105
105
|
|
@@ -113,29 +113,29 @@ If you want to add attributes for only on class you simply have to declare them
|
|
113
113
|
|
114
114
|
# Fetch a feed containing GeoRss info and print them
|
115
115
|
Feedzirra::Feed.fetch_and_parse("http://www.earthpublisher.com/georss.php").entries.each do |e|
|
116
|
-
p "lat: #
|
116
|
+
p "lat: #[e.lat}, long: #{e.long]"
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
## Benchmarks
|
120
120
|
|
121
|
-
One of the goals of Feedzirra is speed. This includes not only parsing, but fetching multiple feeds as quickly as possible. I ran a benchmark getting 20 feeds 10 times using Feedzirra, rFeedParser, and FeedNormalizer. For more details the
|
121
|
+
One of the goals of Feedzirra is speed. This includes not only parsing, but fetching multiple feeds as quickly as possible. I ran a benchmark getting 20 feeds 10 times using Feedzirra, rFeedParser, and FeedNormalizer. For more details the [benchmark code can be found in the project in spec/benchmarks/feedzirra_benchmarks.rb](https://github.com/pauldix/feedzirra/blob/7fb5634c5c16e9c6ec971767b462c6518cd55f5d/spec/benchmarks/feedzirra_benchmarks.rb)
|
122
122
|
|
123
123
|
feedzirra 5.170000 1.290000 6.460000 ( 18.917796)
|
124
124
|
rfeedparser 104.260000 12.220000 116.480000 (244.799063)
|
125
125
|
feed-normalizer 66.250000 4.010000 70.260000 (191.589862)
|
126
126
|
|
127
|
-
The result of that benchmark is a bit sketchy because of the network variability. Running 10 times against the same 20 feeds was meant to smooth some of that out. However, there is also a
|
127
|
+
The result of that benchmark is a bit sketchy because of the network variability. Running 10 times against the same 20 feeds was meant to smooth some of that out. However, there is also a [benchmark comparing parsing speed in spec/benchmarks/parsing_benchmark.rb](https://github.com/pauldix/feedzirra/blob/7fb5634c5c16e9c6ec971767b462c6518cd55f5d/spec/benchmarks/parsing_benchmark.rb) on an atom feed.
|
128
128
|
|
129
129
|
feedzirra 0.500000 0.030000 0.530000 ( 0.658744)
|
130
130
|
rfeedparser 8.400000 1.110000 9.510000 ( 11.839827)
|
131
131
|
feed-normalizer 5.980000 0.160000 6.140000 ( 7.576140)
|
132
132
|
|
133
|
-
There's also a
|
133
|
+
There's also a [benchmark that shows the results of using Feedzirra to perform updates on feeds](https://github.com/pauldix/feedzirra/blob/45d64319544c61a4c9eb9f7f825c73b9f9030cb3/spec/benchmarks/updating_benchmarks.rb) you've already pulled in. I tested against 179 feeds. The first is the initial pull and the second is an update 65 seconds later. I'm not sure how many of them support etag and last-modified, so performance may be better or worse depending on what feeds you're requesting.
|
134
134
|
|
135
135
|
feedzirra fetch and parse 4.010000 0.710000 4.720000 ( 15.110101)
|
136
136
|
feedzirra update 0.660000 0.280000 0.940000 ( 5.152709)
|
137
137
|
|
138
|
-
|
138
|
+
## TODO
|
139
139
|
|
140
140
|
This thing needs to hammer on many different feeds in the wild. I'm sure there will be bugs. I want to find them and crush them. I didn't bother using the test suite for feedparser. i wanted to start fresh.
|
141
141
|
|
@@ -149,14 +149,16 @@ Here are some more specific TODOs.
|
|
149
149
|
* Make the feed_spec actually mock stuff out so it doesn't hit the net.
|
150
150
|
* Readdress how feeds determine if they can parse a document. Maybe I should use namespaces instead?
|
151
151
|
|
152
|
-
|
152
|
+
## LICENSE
|
153
153
|
|
154
154
|
(The MIT License)
|
155
155
|
|
156
|
-
Copyright (c) 2009:
|
157
|
-
|
158
|
-
{Paul Dix}[http://pauldix.net]
|
156
|
+
Copyright (c) 2009-2012:
|
159
157
|
|
158
|
+
- [Paul Dix](http://pauldix.net)
|
159
|
+
- [Julien Kirch](http://archiloque.net/)
|
160
|
+
- [Ezekiel Templin](http://zeke.templ.in/)
|
161
|
+
|
160
162
|
Permission is hereby granted, free of charge, to any person obtaining
|
161
163
|
a copy of this software and associated documentation files (the
|
162
164
|
'Software'), to deal in the Software without restriction, including
|
data/Rakefile
CHANGED
@@ -1,51 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
require 'rdoc/task'
|
6
|
-
require 'rspec'
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
7
3
|
require 'rspec/core/rake_task'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def recent_specs(touched_since)
|
13
|
-
recent_specs = FileList['app/**/*'].map do |path|
|
14
|
-
|
15
|
-
if File.mtime(path) > touched_since
|
16
|
-
spec = File.join('spec', File.dirname(path).split("/")[1..-1].join('/'),
|
17
|
-
"#{File.basename(path, ".*")}_spec.rb")
|
18
|
-
spec if File.exists?(spec)
|
19
|
-
end
|
20
|
-
end.compact
|
21
|
-
|
22
|
-
recent_specs += FileList['spec/**/*_spec.rb'].select do |path|
|
23
|
-
File.mtime(path) > touched_since
|
24
|
-
end
|
25
|
-
recent_specs.uniq
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec::Core::RakeTask.new do |t|
|
29
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'Run recent specs'
|
33
|
-
RSpec::Core::RakeTask.new("spec:recent") do |t|
|
34
|
-
t.pattern = recent_specs(Time.now - 600) # 10 min.
|
35
|
-
end
|
36
|
-
|
37
|
-
RSpec::Core::RakeTask.new('spec:rcov') do |t|
|
38
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
39
|
-
t.rcov = true
|
40
|
-
t.rcov_opts = ['--exclude', 'spec,/usr/lib/ruby,/usr/local,/var/lib,/Library', '--text-report']
|
41
|
-
end
|
42
|
-
|
43
|
-
RDoc::Task.new do |rd|
|
44
|
-
rd.title = 'Feedzirra'
|
45
|
-
rd.rdoc_dir = 'rdoc'
|
46
|
-
rd.rdoc_files.include('README.rdoc', 'lib/feedzirra.rb', 'lib/feedzirra/**/*.rb')
|
47
|
-
rd.options = ["--quiet", "--opname", "index.html", "--line-numbers", "--inline-source", '--main', 'README.rdoc']
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Run all the tests"
|
51
|
-
task :default => :spec
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
task :test => :spec
|
6
|
+
task :default => :test
|
data/feedzirra.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/feedzirra/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'feedzirra'
|
6
|
+
s.version = Feedzirra::VERSION
|
7
|
+
|
8
|
+
s.authors = ['Paul Dix', 'Julien Kirch', "Ezekiel Templin"]
|
9
|
+
s.date = Date.today
|
10
|
+
s.email = 'feedzirra@googlegroups.com'
|
11
|
+
s.homepage = 'http://github.com/pauldix/feedzirra'
|
12
|
+
|
13
|
+
s.summary = 'A feed fetching and parsing library'
|
14
|
+
s.description = 'A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all.'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.platform = Gem::Platform::RUBY
|
21
|
+
|
22
|
+
s.add_dependency 'nokogiri', '~> 1.5.2'
|
23
|
+
s.add_dependency 'sax-machine', '~> 0.1.0'
|
24
|
+
s.add_dependency 'curb', '~> 0.8.0'
|
25
|
+
s.add_dependency 'loofah', '~> 1.2.1'
|
26
|
+
s.add_dependency 'gorillib', '~> 0.1.9'
|
27
|
+
|
28
|
+
s.add_development_dependency 'rspec', '~> 2.10.0'
|
29
|
+
end
|
data/lib/feedzirra.rb
CHANGED
@@ -3,11 +3,7 @@ require 'curb'
|
|
3
3
|
require 'sax-machine'
|
4
4
|
require 'loofah'
|
5
5
|
require 'uri'
|
6
|
-
|
7
|
-
require 'active_support/basic_object'
|
8
|
-
require 'active_support/core_ext/module'
|
9
|
-
require 'active_support/core_ext/object'
|
10
|
-
require 'active_support/time'
|
6
|
+
require 'gorillib/datetime/parse'
|
11
7
|
|
12
8
|
require 'feedzirra/core_ext'
|
13
9
|
|
@@ -16,4 +12,6 @@ module Feedzirra
|
|
16
12
|
autoload :FeedUtilities, 'feedzirra/feed_utilities'
|
17
13
|
autoload :Feed, 'feedzirra/feed'
|
18
14
|
autoload :Parser, 'feedzirra/parser'
|
15
|
+
|
16
|
+
class NoParserAvailable < StandardError; end
|
19
17
|
end
|
data/lib/feedzirra/feed.rb
CHANGED
@@ -50,12 +50,23 @@ module Feedzirra
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def find_new_entries_for(feed)
|
53
|
-
# this
|
54
|
-
|
53
|
+
# this implementation is a hack, which is why it's so ugly.
|
54
|
+
# it's to get around the fact that not all feeds have a published date.
|
55
|
+
# however, they're always ordered with the newest one first.
|
56
|
+
# So we go through the entries just parsed and insert each one as a new entry
|
57
|
+
# until we get to one that has the same url as the the newest for the feed
|
58
|
+
return feed.entries if self.entries.length == 0
|
59
|
+
latest_entry = self.entries.first
|
60
|
+
found_new_entries = []
|
61
|
+
feed.entries.each do |entry|
|
62
|
+
break if entry.url == latest_entry.url
|
63
|
+
found_new_entries << entry
|
64
|
+
end
|
65
|
+
found_new_entries
|
55
66
|
end
|
56
67
|
|
57
68
|
def existing_entry?(test_entry)
|
58
69
|
entries.any? { |entry| entry.url == test_entry.url }
|
59
70
|
end
|
60
71
|
end
|
61
|
-
end
|
72
|
+
end
|
data/lib/feedzirra/version.rb
CHANGED
@@ -11,7 +11,7 @@ describe Feedzirra::FeedUtilities do
|
|
11
11
|
it "should parse an ISO 8601 formatted datetime into Time" do
|
12
12
|
time = @klass.new.parse_datetime("2008-02-20T8:05:00-010:00")
|
13
13
|
time.class.should == Time
|
14
|
-
time.
|
14
|
+
time.should == Time.parse_safely("Wed Feb 20 18:05:00 UTC 2008")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
data/spec/feedzirra/feed_spec.rb
CHANGED
@@ -43,35 +43,35 @@ describe Feedzirra::Feed do
|
|
43
43
|
it "should parse an rdf feed" do
|
44
44
|
feed = Feedzirra::Feed.parse(sample_rdf_feed)
|
45
45
|
feed.title.should == "HREF Considered Harmful"
|
46
|
-
feed.entries.first.published.
|
46
|
+
feed.entries.first.published.should == Time.parse_safely("Tue Sep 02 19:50:07 UTC 2008")
|
47
47
|
feed.entries.size.should == 10
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should parse an rss feed" do
|
51
51
|
feed = Feedzirra::Feed.parse(sample_rss_feed)
|
52
52
|
feed.title.should == "Tender Lovemaking"
|
53
|
-
feed.entries.first.published.
|
53
|
+
feed.entries.first.published.should == Time.parse_safely("Thu Dec 04 17:17:49 UTC 2008")
|
54
54
|
feed.entries.size.should == 10
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should parse an atom feed" do
|
58
58
|
feed = Feedzirra::Feed.parse(sample_atom_feed)
|
59
59
|
feed.title.should == "Amazon Web Services Blog"
|
60
|
-
feed.entries.first.published.
|
60
|
+
feed.entries.first.published.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
|
61
61
|
feed.entries.size.should == 10
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should parse an feedburner atom feed" do
|
65
65
|
feed = Feedzirra::Feed.parse(sample_feedburner_atom_feed)
|
66
66
|
feed.title.should == "Paul Dix Explains Nothing"
|
67
|
-
feed.entries.first.published.
|
67
|
+
feed.entries.first.published.should == Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
|
68
68
|
feed.entries.size.should == 5
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should parse an itunes feed as a standard RSS feed" do
|
72
72
|
feed = Feedzirra::Feed.parse(sample_itunes_feed)
|
73
73
|
feed.title.should == "All About Everything"
|
74
|
-
feed.entries.first.published.should == Time.
|
74
|
+
feed.entries.first.published.should == Time.parse_safely("Wed, 15 Jun 2005 19:00:00 GMT")
|
75
75
|
|
76
76
|
# Since the commit 621957879, iTunes feeds will be parsed as standard RSS, so this
|
77
77
|
# entry should now not have a method for itunes_author.
|
@@ -91,7 +91,7 @@ describe Feedzirra::Feed do
|
|
91
91
|
it "should parse an feedburner rss feed" do
|
92
92
|
feed = Feedzirra::Feed.parse(sample_rss_feed_burner_feed)
|
93
93
|
feed.title.should == "TechCrunch"
|
94
|
-
feed.entries.first.published.
|
94
|
+
feed.entries.first.published.should == Time.parse_safely("Wed Nov 02 17:25:27 UTC 2011")
|
95
95
|
feed.entries.size.should == 20
|
96
96
|
end
|
97
97
|
end
|
@@ -167,7 +167,7 @@ describe Feedzirra::Feed do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should return the last modified date from the header if it exists" do
|
170
|
-
Feedzirra::Feed.last_modified_from_header(@header).should == Time.
|
170
|
+
Feedzirra::Feed.last_modified_from_header(@header).should == Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should return nil if there is no last modified date in the header" do
|
@@ -204,7 +204,7 @@ describe Feedzirra::Feed do
|
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should set if modified since as an option if passed" do
|
207
|
-
Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.
|
207
|
+
Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT"))
|
208
208
|
@curl.headers["If-Modified-Since"].should == 'Wed, 28 Jan 2009 04:10:32 GMT'
|
209
209
|
end
|
210
210
|
|
@@ -258,6 +258,7 @@ describe Feedzirra::Feed do
|
|
258
258
|
|
259
259
|
describe "#add_url_to_multi" do
|
260
260
|
before(:each) do
|
261
|
+
allow_message_expectations_on_nil
|
261
262
|
@multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
|
262
263
|
@multi.stub!(:add)
|
263
264
|
@easy_curl = Curl::Easy.new(@paul_feed[:url])
|
@@ -276,7 +277,7 @@ describe Feedzirra::Feed do
|
|
276
277
|
end
|
277
278
|
|
278
279
|
it "should set if modified since as an option if passed" do
|
279
|
-
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.
|
280
|
+
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse_safely("Jan 25 2009 04:10:32 GMT"))
|
280
281
|
@easy_curl.headers["If-Modified-Since"].should == 'Sun, 25 Jan 2009 04:10:32 GMT'
|
281
282
|
end
|
282
283
|
|
@@ -400,6 +401,7 @@ describe Feedzirra::Feed do
|
|
400
401
|
|
401
402
|
describe "#add_feed_to_multi" do
|
402
403
|
before(:each) do
|
404
|
+
allow_message_expectations_on_nil
|
403
405
|
@multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
|
404
406
|
@multi.stub!(:add)
|
405
407
|
@easy_curl = Curl::Easy.new(@paul_feed[:url])
|
@@ -419,7 +421,7 @@ describe Feedzirra::Feed do
|
|
419
421
|
end
|
420
422
|
|
421
423
|
it "should set if modified since as an option if passed" do
|
422
|
-
modified_time = Time.
|
424
|
+
modified_time = Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
|
423
425
|
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {:if_modified_since => modified_time})
|
424
426
|
modified_time.should be > @feed.last_modified
|
425
427
|
|
@@ -540,7 +542,7 @@ describe Feedzirra::Feed do
|
|
540
542
|
it "should return an return an array of feed objects if multiple feeds are passed in"
|
541
543
|
|
542
544
|
it "should set if modified since as an option if passed" do
|
543
|
-
modified_time = Time.
|
545
|
+
modified_time = Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
|
544
546
|
Feedzirra::Feed.should_receive(:add_url_to_multi).with(anything, anything, anything, anything, {:if_modified_since => modified_time}).any_number_of_times
|
545
547
|
|
546
548
|
@feed = Feedzirra::Feed.fetch_and_parse(sample_feedburner_atom_feed, {:if_modified_since => modified_time})
|