feedzirra 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +0 -14
  4. data/README.md +2 -241
  5. data/feedzirra.gemspec +2 -8
  6. data/lib/feedzirra.rb +2 -15
  7. data/lib/feedzirra/version.rb +1 -1
  8. metadata +7 -182
  9. data/.rspec +0 -1
  10. data/.travis.yml +0 -8
  11. data/Guardfile +0 -5
  12. data/Rakefile +0 -6
  13. data/benchmarks/README.md +0 -90
  14. data/benchmarks/basic.rb +0 -31
  15. data/benchmarks/feed_list.txt +0 -10
  16. data/benchmarks/feed_xml/apple.xml +0 -149
  17. data/benchmarks/feed_xml/cnn.xml +0 -278
  18. data/benchmarks/feed_xml/daring_fireball.xml +0 -1697
  19. data/benchmarks/feed_xml/engadget.xml +0 -604
  20. data/benchmarks/feed_xml/feedzirra_commits.xml +0 -370
  21. data/benchmarks/feed_xml/gizmodo.xml +0 -2
  22. data/benchmarks/feed_xml/loop.xml +0 -441
  23. data/benchmarks/feed_xml/rails.xml +0 -1938
  24. data/benchmarks/feed_xml/white_house.xml +0 -951
  25. data/benchmarks/feed_xml/xkcd.xml +0 -2
  26. data/benchmarks/fetching_systems.rb +0 -23
  27. data/benchmarks/other_libraries.rb +0 -73
  28. data/lib/feedzirra/core_ext.rb +0 -3
  29. data/lib/feedzirra/core_ext/date.rb +0 -19
  30. data/lib/feedzirra/core_ext/string.rb +0 -9
  31. data/lib/feedzirra/core_ext/time.rb +0 -31
  32. data/lib/feedzirra/feed.rb +0 -459
  33. data/lib/feedzirra/feed_entry_utilities.rb +0 -66
  34. data/lib/feedzirra/feed_utilities.rb +0 -103
  35. data/lib/feedzirra/parser.rb +0 -20
  36. data/lib/feedzirra/parser/atom.rb +0 -61
  37. data/lib/feedzirra/parser/atom_entry.rb +0 -34
  38. data/lib/feedzirra/parser/atom_feed_burner.rb +0 -22
  39. data/lib/feedzirra/parser/atom_feed_burner_entry.rb +0 -35
  40. data/lib/feedzirra/parser/google_docs_atom.rb +0 -28
  41. data/lib/feedzirra/parser/google_docs_atom_entry.rb +0 -29
  42. data/lib/feedzirra/parser/itunes_rss.rb +0 -50
  43. data/lib/feedzirra/parser/itunes_rss_item.rb +0 -41
  44. data/lib/feedzirra/parser/itunes_rss_owner.rb +0 -12
  45. data/lib/feedzirra/parser/rss.rb +0 -24
  46. data/lib/feedzirra/parser/rss_entry.rb +0 -37
  47. data/lib/feedzirra/parser/rss_feed_burner.rb +0 -23
  48. data/lib/feedzirra/parser/rss_feed_burner_entry.rb +0 -43
  49. data/spec/feedzirra/feed_entry_utilities_spec.rb +0 -62
  50. data/spec/feedzirra/feed_spec.rb +0 -762
  51. data/spec/feedzirra/feed_utilities_spec.rb +0 -273
  52. data/spec/feedzirra/parser/atom_entry_spec.rb +0 -86
  53. data/spec/feedzirra/parser/atom_feed_burner_entry_spec.rb +0 -47
  54. data/spec/feedzirra/parser/atom_feed_burner_spec.rb +0 -56
  55. data/spec/feedzirra/parser/atom_spec.rb +0 -76
  56. data/spec/feedzirra/parser/google_docs_atom_entry_spec.rb +0 -22
  57. data/spec/feedzirra/parser/google_docs_atom_spec.rb +0 -31
  58. data/spec/feedzirra/parser/itunes_rss_item_spec.rb +0 -63
  59. data/spec/feedzirra/parser/itunes_rss_owner_spec.rb +0 -18
  60. data/spec/feedzirra/parser/itunes_rss_spec.rb +0 -58
  61. data/spec/feedzirra/parser/rss_entry_spec.rb +0 -85
  62. data/spec/feedzirra/parser/rss_feed_burner_entry_spec.rb +0 -85
  63. data/spec/feedzirra/parser/rss_feed_burner_spec.rb +0 -57
  64. data/spec/feedzirra/parser/rss_spec.rb +0 -57
  65. data/spec/sample_feeds/AmazonWebServicesBlog.xml +0 -797
  66. data/spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml +0 -63
  67. data/spec/sample_feeds/AtomFeedWithSpacesAroundEquals.xml +0 -61
  68. data/spec/sample_feeds/FeedBurnerUrlNoAlternate.xml +0 -28
  69. data/spec/sample_feeds/GoogleDocsList.xml +0 -188
  70. data/spec/sample_feeds/HREFConsideredHarmful.xml +0 -314
  71. data/spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml +0 -22
  72. data/spec/sample_feeds/ITunesWithSpacesInAttributes.xml +0 -63
  73. data/spec/sample_feeds/PaulDixExplainsNothing.xml +0 -175
  74. data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +0 -175
  75. data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +0 -19
  76. data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +0 -174
  77. data/spec/sample_feeds/SamRuby.xml +0 -583
  78. data/spec/sample_feeds/TechCrunch.xml +0 -1515
  79. data/spec/sample_feeds/TechCrunchFirstEntry.xml +0 -9
  80. data/spec/sample_feeds/TechCrunchFirstEntryDescription.xml +0 -3
  81. data/spec/sample_feeds/TenderLovemaking.xml +0 -516
  82. data/spec/sample_feeds/TenderLovemakingFirstEntry.xml +0 -66
  83. data/spec/sample_feeds/TrotterCashionHome.xml +0 -611
  84. data/spec/sample_feeds/TypePadNews.xml +0 -368
  85. data/spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml +0 -31
  86. data/spec/sample_feeds/itunes.xml +0 -67
  87. data/spec/sample_feeds/pet_atom.xml +0 -497
  88. data/spec/spec_helper.rb +0 -88
@@ -1,273 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Feedzirra::FeedUtilities do
4
- before(:each) do
5
- @klass = Class.new do
6
- include SAXMachine
7
- include Feedzirra::FeedUtilities
8
- end
9
- end
10
-
11
- describe "preprocessing" do
12
- context "when the flag is not set" do
13
- it "does not call the preprocessing method" do
14
- @klass.preprocess_xml = false
15
- @klass.should_not_receive :preprocess
16
- @klass.parse sample_rss_feed
17
- end
18
- end
19
-
20
- context "when the flag is set" do
21
- it "calls the preprocessing method" do
22
- @klass.preprocess_xml = true
23
- @klass.should_receive(:preprocess).
24
- and_return sample_rss_feed
25
- @klass.parse sample_rss_feed
26
- end
27
- end
28
- end
29
-
30
- describe "instance methods" do
31
- it "should provide an updated? accessor" do
32
- feed = @klass.new
33
- feed.should_not be_updated
34
- feed.updated = true
35
- feed.should be_updated
36
- end
37
-
38
- it "should provide a new_entries accessor" do
39
- feed = @klass.new
40
- feed.new_entries.should == []
41
- feed.new_entries = [:foo]
42
- feed.new_entries.should == [:foo]
43
- end
44
-
45
- it "should provide an etag accessor" do
46
- feed = @klass.new
47
- feed.etag = "foo"
48
- feed.etag.should == "foo"
49
- end
50
-
51
- it "should provide a last_modified accessor" do
52
- feed = @klass.new
53
- time = Time.now
54
- feed.last_modified = time
55
- feed.last_modified.should == time
56
- feed.last_modified.class.should == Time
57
- end
58
-
59
- it "should return new_entries? as true when entries are put into new_entries" do
60
- feed = @klass.new
61
- feed.new_entries << :foo
62
- feed.should have_new_entries
63
- end
64
-
65
- it "should return a last_modified value from the entry with the most recent published date if the last_modified date hasn't been set" do
66
- feed = Feedzirra::Parser::Atom.new
67
- entry =Feedzirra::Parser::AtomEntry.new
68
- entry.published = Time.now.to_s
69
- feed.entries << entry
70
- feed.last_modified.should == entry.published
71
- end
72
-
73
- it "should not throw an error if one of the entries has published date of nil" do
74
- feed = Feedzirra::Parser::Atom.new
75
- entry = Feedzirra::Parser::AtomEntry.new
76
- entry.published = Time.now.to_s
77
- feed.entries << entry
78
- feed.entries << Feedzirra::Parser::AtomEntry.new
79
- feed.last_modified.should == entry.published
80
- end
81
- end
82
-
83
- describe "#update_from_feed" do
84
- describe "updating feed attributes" do
85
- before(:each) do
86
- # I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
87
- # method would only be called against a feed item.
88
- @feed = Feedzirra::Parser::Atom.new
89
- @feed.title = "A title"
90
- @feed.url = "http://pauldix.net"
91
- @feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
92
- @feed.updated = false
93
- @updated_feed = @feed.dup
94
- end
95
-
96
- it "should update the title if changed" do
97
- @updated_feed.title = "new title"
98
- @feed.update_from_feed(@updated_feed)
99
- @feed.title.should == @updated_feed.title
100
- @feed.should be_updated
101
- end
102
-
103
- it "should not update the title if the same" do
104
- @feed.update_from_feed(@updated_feed)
105
- @feed.should_not be_updated
106
- end
107
-
108
- it "should update the feed_url if changed" do
109
- @updated_feed.feed_url = "a new feed url"
110
- @feed.update_from_feed(@updated_feed)
111
- @feed.feed_url.should == @updated_feed.feed_url
112
- @feed.should be_updated
113
- end
114
-
115
- it "should not update the feed_url if the same" do
116
- @feed.update_from_feed(@updated_feed)
117
- @feed.should_not be_updated
118
- end
119
-
120
- it "should update the url if changed" do
121
- @updated_feed.url = "a new url"
122
- @feed.update_from_feed(@updated_feed)
123
- @feed.url.should == @updated_feed.url
124
- end
125
-
126
- it "should not update the url if not changed" do
127
- @feed.update_from_feed(@updated_feed)
128
- @feed.should_not be_updated
129
- end
130
- end
131
-
132
- describe "updating entries" do
133
- before(:each) do
134
- # I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
135
- # method would only be called against a feed item.
136
- @feed = Feedzirra::Parser::Atom.new
137
- @feed.title = "A title"
138
- @feed.url = "http://pauldix.net"
139
- @feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
140
- @feed.updated = false
141
- @updated_feed = @feed.dup
142
- @old_entry = Feedzirra::Parser::AtomEntry.new
143
- @old_entry.url = "http://pauldix.net/old.html"
144
- @old_entry.published = Time.now.to_s
145
- @old_entry.entry_id = "entry_id_old"
146
- @new_entry = Feedzirra::Parser::AtomEntry.new
147
- @new_entry.url = "http://pauldix.net/new.html"
148
- @new_entry.published = (Time.now + 10).to_s
149
- @new_entry.entry_id = "entry_id_new"
150
- @feed.entries << @old_entry
151
- @updated_feed.entries << @new_entry
152
- @updated_feed.entries << @old_entry
153
- end
154
-
155
- it "should update last-modified from the latest entry date" do
156
- @feed.update_from_feed(@updated_feed)
157
- @feed.last_modified.should == @new_entry.published
158
- end
159
-
160
- it "should put new entries into new_entries" do
161
- @feed.update_from_feed(@updated_feed)
162
- @feed.new_entries.should == [@new_entry]
163
- end
164
-
165
- it "should also put new entries into the entries collection" do
166
- @feed.update_from_feed(@updated_feed)
167
- @feed.entries.should include(@new_entry)
168
- @feed.entries.should include(@old_entry)
169
- end
170
- end
171
-
172
- describe "#update_from_feed" do
173
- let(:recent_entry_id) { 'entry_id' }
174
- let(:old_entry_id) { nil }
175
-
176
- before(:each) do
177
- # I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
178
- # method would only be called against a feed item.
179
- @feed = Feedzirra::Parser::Atom.new
180
- @feed.title = "A title"
181
- @feed.url = "http://pauldix.net"
182
- @feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
183
- @feed.updated = false
184
- @updated_feed = @feed.dup
185
-
186
- @old_entry = Feedzirra::Parser::AtomEntry.new
187
- @old_entry.url = "http://pauldix.net/old.html"
188
- @old_entry.entry_id = old_entry_id
189
- @old_entry.published = (Time.now - 10).to_s
190
-
191
- @entry = Feedzirra::Parser::AtomEntry.new
192
- @entry.published = (Time.now + 10).to_s
193
- @entry.entry_id = recent_entry_id
194
- @entry.url = "http://pauldix.net/entry.html"
195
-
196
- # only difference is a changed url
197
- @entry_changed_url = @entry.dup
198
- @entry_changed_url.url = "http://pauldix.net/updated.html"
199
-
200
- # entry with changed url must be first
201
- @feed.entries << @entry
202
- @feed.entries << @old_entry
203
- @updated_feed.entries << @entry_changed_url
204
- @updated_feed.entries << @old_entry
205
- end
206
-
207
- context "changing the url of an existing entry" do
208
- it "should not put the complete feed into new_entries" do
209
- @feed.update_from_feed(@updated_feed)
210
- @feed.new_entries.should_not include(@entry_changed_url)
211
- @feed.new_entries.should_not include(@old_entry)
212
- @feed.new_entries.size.should == 0
213
- @feed.new_entries.size.should_not == 2
214
- end
215
- end
216
-
217
- context "feed not have entry id and only difference is a url" do
218
- let(:recent_entry_id) { nil }
219
- let(:old_entry_id) { nil }
220
-
221
- it "should put the complete feed into new_entries" do
222
- @feed.update_from_feed(@updated_feed)
223
- @feed.new_entries.should include(@entry_changed_url)
224
- @feed.new_entries.should include(@old_entry)
225
- @feed.new_entries.size.should == 2
226
- @feed.new_entries.size.should_not == 0
227
- end
228
- end
229
- end
230
-
231
- describe 'updating with a feed' do
232
- let(:id_one) { '1' }
233
- let(:id_two) { '2' }
234
-
235
- let(:url_one) { 'http://example.com/post_one.html' }
236
- let(:url_two) { 'http://example.com/post_two.html' }
237
-
238
- let(:entry_one) { double 'Entry One', entry_id: id_one, url: url_one }
239
- let(:entry_two) { double 'Entry Two', entry_id: id_two, url: url_two }
240
-
241
- let(:feed_one) { Feedzirra::Parser::Atom.new }
242
- let(:feed_two) { double 'Feed Two', entries: [entry_two] }
243
-
244
- before do
245
- stub_const("Feedzirra::FeedUtilities::UPDATABLE_ATTRIBUTES", [])
246
- feed_one.entries << entry_one
247
- end
248
-
249
- it 'finds entries with unique ids and urls' do
250
- feed_one.update_from_feed feed_two
251
- feed_one.new_entries.should eq [entry_two]
252
- end
253
-
254
- context 'when the entries have the same id' do
255
- let(:id_two) { id_one }
256
-
257
- it 'does not find a new entry' do
258
- feed_one.update_from_feed feed_two
259
- feed_one.new_entries.should eq []
260
- end
261
- end
262
-
263
- context 'when the entries have the same url' do
264
- let(:url_two) { url_one }
265
-
266
- it 'does not find a new entry' do
267
- feed_one.update_from_feed feed_two
268
- feed_one.new_entries.should eq []
269
- end
270
- end
271
- end
272
- end
273
- end
@@ -1,86 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
-
3
- describe Feedzirra::Parser::AtomEntry do
4
- before(:each) do
5
- # I don't really like doing it this way because these unit test should only rely on AtomEntry,
6
- # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
7
- @entry = Feedzirra::Parser::Atom.parse(sample_atom_feed).entries.first
8
- end
9
-
10
- it "should parse the title" do
11
- @entry.title.should == "AWS Job: Architect & Designer Position in Turkey"
12
- end
13
-
14
- it "should parse the url" do
15
- @entry.url.should == "http://aws.typepad.com/aws/2009/01/aws-job-architect-designer-position-in-turkey.html"
16
- end
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
-
22
- it "should parse the author" do
23
- @entry.author.should == "AWS Editor"
24
- end
25
-
26
- it "should parse the content" do
27
- @entry.content.should == sample_atom_entry_content
28
- end
29
-
30
- it "should provide a summary" do
31
- @entry.summary.should == "Late last year an entrepreneur from Turkey visited me at Amazon HQ in Seattle. We talked about his plans to use AWS as part of his new social video portal startup. I won't spill any beans before he's ready to..."
32
- end
33
-
34
- it "should parse the published date" do
35
- @entry.published.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
36
- end
37
-
38
- it "should parse the categories" do
39
- @entry.categories.should == ['Turkey', 'Seattle']
40
- end
41
-
42
- it "should parse the updated date" do
43
- @entry.updated.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
44
- end
45
-
46
- it "should parse the id" do
47
- @entry.id.should == "tag:typepad.com,2003:post-61484736"
48
- end
49
-
50
- it "should support each" do
51
- @entry.respond_to? :each
52
- end
53
-
54
- it "should be able to list out all fields with each" do
55
- all_fields = []
56
- @entry.each do |field, value|
57
- all_fields << field
58
- end
59
- all_fields.sort == ['author', 'categories', 'content', 'id', 'published', 'summary', 'title', 'url']
60
- end
61
-
62
- it "should be able to list out all values with each" do
63
- title_value = ''
64
- @entry.each do |field, value|
65
- title_value = value if field == 'title'
66
- end
67
- title_value.should == "AWS Job: Architect & Designer Position in Turkey"
68
- end
69
-
70
- it "should support checking if a field exists in the entry" do
71
- @entry.include?('title') && @entry.include?('author')
72
- end
73
-
74
- it "should allow access to fields with hash syntax" do
75
- @entry['title'] == @entry.title
76
- @entry['title'].should == "AWS Job: Architect & Designer Position in Turkey"
77
- @entry['author'] == @entry.author
78
- @entry['author'].should == "AWS Editor"
79
- end
80
-
81
- it "should allow setting field values with hash syntax" do
82
- @entry['title'] = "Foobar"
83
- @entry.title.should == "Foobar"
84
- end
85
-
86
- end
@@ -1,47 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
-
3
- describe Feedzirra::Parser::AtomFeedBurnerEntry do
4
- before(:each) do
5
- # I don't really like doing it this way because these unit test should only rely on AtomEntry,
6
- # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
7
- @entry = Feedzirra::Parser::AtomFeedBurner.parse(sample_feedburner_atom_feed).entries.first
8
- end
9
-
10
- it "should parse the title" do
11
- @entry.title.should == "Making a Ruby C library even faster"
12
- end
13
-
14
- it "should be able to fetch a url via the 'alternate' rel if no origLink exists" do
15
- entry = Feedzirra::Parser::AtomFeedBurner.parse(File.read("#{File.dirname(__FILE__)}/../../sample_feeds/PaulDixExplainsNothingAlternate.xml")).entries.first
16
- entry.url.should == 'http://feeds.feedburner.com/~r/PaulDixExplainsNothing/~3/519925023/making-a-ruby-c-library-even-faster.html'
17
- end
18
-
19
- it "should parse the url" do
20
- @entry.url.should == "http://www.pauldix.net/2009/01/making-a-ruby-c-library-even-faster.html"
21
- end
22
-
23
- it "should parse the url when there is no alternate" do
24
- entry = Feedzirra::Parser::AtomFeedBurner.parse(File.read("#{File.dirname(__FILE__)}/../../sample_feeds/FeedBurnerUrlNoAlternate.xml")).entries.first
25
- entry.url.should == 'http://example.com/QQQQ.html'
26
- end
27
-
28
- it "should parse the author" do
29
- @entry.author.should == "Paul Dix"
30
- end
31
-
32
- it "should parse the content" do
33
- @entry.content.should == sample_feedburner_atom_entry_content
34
- end
35
-
36
- it "should provide a summary" do
37
- @entry.summary.should == "Last week I released the first version of a SAX based XML parsing library called SAX-Machine. It uses Nokogiri, which uses libxml, so it's pretty fast. However, I felt that it could be even faster. The only question was how..."
38
- end
39
-
40
- it "should parse the published date" do
41
- @entry.published.should == Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
42
- end
43
-
44
- it "should parse the categories" do
45
- @entry.categories.should == ['Ruby', 'Another Category']
46
- end
47
- end
@@ -1,56 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
-
3
- describe Feedzirra::Parser::AtomFeedBurner do
4
- describe "#will_parse?" do
5
- it "should return true for a feedburner atom feed" do
6
- Feedzirra::Parser::AtomFeedBurner.should be_able_to_parse(sample_feedburner_atom_feed)
7
- end
8
-
9
- it "should return false for an rdf feed" do
10
- Feedzirra::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_rdf_feed)
11
- end
12
-
13
- it "should return false for a regular atom feed" do
14
- Feedzirra::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_atom_feed)
15
- end
16
-
17
- it "should return false for an rss feedburner feed" do
18
- Feedzirra::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_rss_feed_burner_feed)
19
- end
20
- end
21
-
22
- describe "parsing" do
23
- before(:each) do
24
- @feed = Feedzirra::Parser::AtomFeedBurner.parse(sample_feedburner_atom_feed)
25
- end
26
-
27
- it "should parse the title" do
28
- @feed.title.should == "Paul Dix Explains Nothing"
29
- end
30
-
31
- it "should parse the description" do
32
- @feed.description.should == "Entrepreneurship, programming, software development, politics, NYC, and random thoughts."
33
- end
34
-
35
- it "should parse the url" do
36
- @feed.url.should == "http://www.pauldix.net/"
37
- end
38
-
39
- it "should parse the feed_url" do
40
- @feed.feed_url.should == "http://feeds.feedburner.com/PaulDixExplainsNothing"
41
- end
42
-
43
- it "should parse no hub urls" do
44
- @feed.hubs.count.should == 0
45
- end
46
-
47
- it "should parse hub urls" do
48
- feed_with_hub = Feedzirra::Parser::AtomFeedBurner.parse(load_sample("TypePadNews.xml"))
49
- feed_with_hub.hubs.count.should == 1
50
- end
51
-
52
- it "should parse entries" do
53
- @feed.entries.size.should == 5
54
- end
55
- end
56
- end