UnderpantsGnome-feedzirra 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,3 +1,5 @@
1
+ "Changes made from Paul's tree":#changes
2
+
1
3
  h1. Feedzirra
2
4
 
3
5
  "http://github.com/pauldix/feedzirra/tree/master":http://github.com/pauldix/feedzirra/tree/master
@@ -166,9 +168,10 @@ Here are some more specific TODOs.
166
168
  * Clean up the fetching code inside feed.rb so it doesn't suck so hard.
167
169
  * Readdress how feeds determine if they can parse a document. Maybe I should use namespaces instead?
168
170
 
169
- h2. Updates from the original
171
+ h2(#changes). Updates from Paul's tree
170
172
 
171
173
  * Add in Media RSS support that should handle the spec with multiple content entries.
174
+ * Add in the missing support for nested iTunes Categories
172
175
 
173
176
  h2. LICENSE
174
177
 
data/lib/feedzirra.rb CHANGED
@@ -21,7 +21,8 @@ require 'feedzirra/feed'
21
21
  require 'feedzirra/parser/rss_entry'
22
22
  require 'feedzirra/parser/mrss_content'
23
23
  require 'feedzirra/parser/itunes_rss_owner'
24
- require 'feedzirra/parser/itunes_rss_item'
24
+ require 'feedzirra/parser/itunes_rss_entry'
25
+ require 'feedzirra/parser/itunes_rss_category'
25
26
  require 'feedzirra/parser/atom_entry'
26
27
  require 'feedzirra/parser/atom_feed_burner_entry'
27
28
 
@@ -31,5 +32,5 @@ require 'feedzirra/parser/atom'
31
32
  require 'feedzirra/parser/atom_feed_burner'
32
33
 
33
34
  module Feedzirra
34
- VERSION = "0.0.14"
35
+ VERSION = "0.0.15"
35
36
  end
@@ -1,9 +1,9 @@
1
1
  module Feedzirra
2
2
  class NoParserAvailable < StandardError; end
3
-
3
+
4
4
  class Feed
5
5
  USER_AGENT = "feedzirra http://github.com/pauldix/feedzirra/tree/master"
6
-
6
+
7
7
  # Takes a raw XML feed and attempts to parse it. If no parser is available a Feedzirra::NoParserAvailable exception is raised.
8
8
  #
9
9
  # === Parameters
@@ -21,7 +21,7 @@ module Feedzirra
21
21
  end
22
22
 
23
23
  # Determines the correct parser class to use for parsing the feed.
24
- #
24
+ #
25
25
  # === Parameters
26
26
  # [xml<String>] The XML that you would like determine the parser for.
27
27
  # === Returns
@@ -37,7 +37,7 @@ module Feedzirra
37
37
  # [klass<Constant>] The class/constant that you want to register.
38
38
  # === Returns
39
39
  # A updated array of feed parser class names.
40
- def self.add_feed_class(klass)
40
+ def self.add_feed_class(klass)
41
41
  feed_classes.unshift klass
42
42
  end
43
43
 
@@ -46,10 +46,15 @@ module Feedzirra
46
46
  # === Returns
47
47
  # A array of class names.
48
48
  def self.feed_classes
49
- @feed_classes ||= [Feedzirra::Parser::RSS, Feedzirra::Parser::AtomFeedBurner, Feedzirra::Parser::Atom]
49
+ @feed_classes ||= [
50
+ Feedzirra::Parser::ITunesRSS,
51
+ Feedzirra::Parser::RSS,
52
+ Feedzirra::Parser::AtomFeedBurner,
53
+ Feedzirra::Parser::Atom
54
+ ]
50
55
  end
51
-
52
- # Makes all entry types look for the passed in element to parse. This is actually just a call to
56
+
57
+ # Makes all entry types look for the passed in element to parse. This is actually just a call to
53
58
  # element (a SAXMachine call) in the class
54
59
  #
55
60
  # === Parameters
@@ -62,7 +67,7 @@ module Feedzirra
62
67
  klass.send(:element, element_tag, options)
63
68
  end
64
69
  end
65
-
70
+
66
71
  # Fetches and returns the raw XML for each URL provided.
67
72
  #
68
73
  # === Parameters
@@ -75,7 +80,7 @@ module Feedzirra
75
80
  # :on_failure - Block that gets executed after a failed request.
76
81
  # === Returns
77
82
  # A String of XML if a single URL is passed.
78
- #
83
+ #
79
84
  # A Hash if multiple URL's are passed. The key will be the URL, and the value the XML.
80
85
  def self.fetch_raw(urls, options = {})
81
86
  url_queue = [*urls]
@@ -122,13 +127,13 @@ module Feedzirra
122
127
  url_queue = [*urls]
123
128
  multi = Curl::Multi.new
124
129
  responses = {}
125
-
130
+
126
131
  # I broke these down so I would only try to do 30 simultaneously because
127
132
  # I was getting weird errors when doing a lot. As one finishes it pops another off the queue.
128
133
  url_queue.slice!(0, 30).each do |url|
129
134
  add_url_to_multi(multi, url, url_queue, responses, options)
130
135
  end
131
-
136
+
132
137
  multi.perform
133
138
  return urls.is_a?(String) ? responses.values.first : responses
134
139
  end
@@ -145,7 +150,7 @@ module Feedzirra
145
150
  gz = Zlib::GzipReader.new(StringIO.new(c.body_str))
146
151
  xml = gz.read
147
152
  gz.close
148
- rescue Zlib::GzipFile::Error
153
+ rescue Zlib::GzipFile::Error
149
154
  # Maybe this is not gzipped?
150
155
  xml = c.body_str
151
156
  end
@@ -174,15 +179,15 @@ module Feedzirra
174
179
  feed_queue = [*feeds]
175
180
  multi = Curl::Multi.new
176
181
  responses = {}
177
-
182
+
178
183
  feed_queue.slice!(0, 30).each do |feed|
179
184
  add_feed_to_multi(multi, feed, feed_queue, responses, options)
180
185
  end
181
-
186
+
182
187
  multi.perform
183
188
  responses.size == 1 ? responses.values.first : responses.values
184
189
  end
185
-
190
+
186
191
  # An abstraction for adding a feed by URL to the passed Curb::multi stack.
187
192
  #
188
193
  # === Parameters
@@ -205,12 +210,12 @@ module Feedzirra
205
210
  curl.headers["Accept-encoding"] = 'gzip, deflate' if options.has_key?(:compress)
206
211
  curl.follow_location = true
207
212
  curl.userpwd = options[:http_authentication].join(':') if options.has_key?(:http_authentication)
208
-
213
+
209
214
  curl.on_success do |c|
210
215
  add_url_to_multi(multi, url_queue.shift, url_queue, responses, options) unless url_queue.empty?
211
216
  xml = decode_content(c)
212
217
  klass = determine_feed_parser_for_xml(xml)
213
-
218
+
214
219
  if klass
215
220
  begin
216
221
  feed = klass.parse(xml)
@@ -228,7 +233,7 @@ module Feedzirra
228
233
  options[:on_failure].call(url, c.response_code, c.header_str, c.body_str) if options.has_key?(:on_failure)
229
234
  end
230
235
  end
231
-
236
+
232
237
  curl.on_failure do |c|
233
238
  add_url_to_multi(multi, url_queue.shift, url_queue, responses, options) unless url_queue.empty?
234
239
  responses[url] = c.response_code
@@ -237,7 +242,7 @@ module Feedzirra
237
242
  end
238
243
  multi.add(easy)
239
244
  end
240
-
245
+
241
246
  # An abstraction for adding a feed by a Feed object to the passed Curb::multi stack.
242
247
  #
243
248
  # === Parameters
@@ -252,7 +257,7 @@ module Feedzirra
252
257
  # * :on_failure - Block that gets executed after a failed request.
253
258
  # === Returns
254
259
  # The updated Curl::Multi object with the request details added to it's stack.
255
- def self.add_feed_to_multi(multi, feed, feed_queue, responses, options)
260
+ def self.add_feed_to_multi(multi, feed, feed_queue, responses, options)
256
261
  easy = Curl::Easy.new(feed.feed_url) do |curl|
257
262
  curl.headers["User-Agent"] = (options[:user_agent] || USER_AGENT)
258
263
  curl.headers["If-Modified-Since"] = feed.last_modified.httpdate if feed.last_modified
@@ -291,7 +296,7 @@ module Feedzirra
291
296
  end
292
297
 
293
298
  # Determines the etag from the request headers.
294
- #
299
+ #
295
300
  # === Parameters
296
301
  # [header<String>] Raw request header returned from the request
297
302
  # === Returns
@@ -1,5 +1,5 @@
1
1
  module Feedzirra
2
-
2
+
3
3
  module Parser
4
4
  # iTunes is RSS 2.0 + some apple extensions
5
5
  # Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
@@ -34,17 +34,20 @@ module Feedzirra
34
34
  # TODO subcategories not supported correctly - they are at the same level
35
35
  # as the main categories
36
36
  elements :"itunes:category", :as => :itunes_categories, :value => :text
37
+ # elements :'itunes:category', :as => :itunes_categories,
38
+ # :class => ITunesRSSCategory
39
+
37
40
 
38
41
  elements :"itunes:owner", :as => :itunes_owners, :class => ITunesRSSOwner
39
42
 
40
- elements :item, :as => :entries, :class => ITunesRSSItem
43
+ elements :item, :as => :entries, :class => ITunesRSSEntry
41
44
 
42
45
  def self.able_to_parse?(xml)
43
46
  xml =~ /xmlns:itunes=\"http:\/\/www.itunes.com\/dtds\/podcast-1.0.dtd\"/
44
47
  end
45
48
 
46
49
  end
47
-
50
+
48
51
  end
49
-
52
+
50
53
  end
@@ -0,0 +1,17 @@
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 ITunesRSS
7
+ class ITunesRSSCategory
8
+ include SAXMachine
9
+ include FeedEntryUtilities
10
+
11
+ element :'itunes:category', :as => :name, :value => :text
12
+ elements :'itunes:category', :as => :sub_categories, :value => :text
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -1,16 +1,20 @@
1
1
  module Feedzirra
2
-
2
+
3
3
  module Parser
4
4
  # iTunes extensions to the standard RSS2.0 item
5
5
  # Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
6
- class ITunesRSSItem
6
+ class ITunesRSSEntry
7
7
  include SAXMachine
8
- include FeedUtilities
8
+ include FeedEntryUtilities
9
9
  element :author
10
10
  element :guid
11
+ element :guid, :as => :id
12
+ element :enclosure, :value => :url, :as => :guid
13
+ element :enclosure, :value => :url, :as => :id
11
14
  element :title
12
15
  element :link, :as => :url
13
16
  element :description, :as => :summary
17
+ element :description, :as => :content
14
18
  element :pubDate, :as => :published
15
19
 
16
20
  # If author is not present use author tag on the item
@@ -27,5 +31,5 @@ module Feedzirra
27
31
  element :enclosure, :value => :url, :as => :enclosure_url
28
32
  end
29
33
  end
30
-
34
+
31
35
  end
@@ -5,20 +5,20 @@ describe Feedzirra::Feed do
5
5
  before(:all) do
6
6
  Feedzirra::Feed.add_common_feed_entry_element("wfw:commentRss", :as => :comment_rss)
7
7
  end
8
-
8
+
9
9
  it "should parse the added element out of Atom feeds" do
10
10
  Feedzirra::Feed.parse(sample_wfw_feed).entries.first.comment_rss.should == "this is the new val"
11
11
  end
12
-
12
+
13
13
  it "should parse the added element out of Atom Feedburner feeds" do
14
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
18
  Feedzirra::Parser::RSSEntry.new.should respond_to(:comment_rss)
19
19
  end
20
20
  end
21
-
21
+
22
22
  describe "#parse" do # many of these tests are redundant with the specific feed type tests, but I put them here for completeness
23
23
  context "when there's an available parser" do
24
24
  it "should parse an rdf feed" do
@@ -47,17 +47,17 @@ describe Feedzirra::Feed do
47
47
  feed.title.should == "Paul Dix Explains Nothing"
48
48
  feed.entries.first.published.to_s.should == "Thu Jan 22 15:50:22 UTC 2009"
49
49
  feed.entries.size.should == 5
50
- end
50
+ end
51
51
 
52
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
55
  feed.entries.first.published.should == Time.parse("Wed, 15 Jun 2005 19:00:00 GMT")
56
-
56
+
57
57
  # Since the commit 621957879, iTunes feeds will be parsed as standard RSS, so this
58
58
  # entry should now not have a method for itunes_author.
59
- feed.entries.first.should_not respond_to(:itunes_author)
60
- feed.entries.size.should == 3
59
+ feed.entries.first.should respond_to(:itunes_author)
60
+ feed.entries.size.should == 4
61
61
  end
62
62
  end
63
63
 
@@ -98,8 +98,8 @@ describe Feedzirra::Feed do
98
98
  Feedzirra::Feed.determine_feed_parser_for_xml(sample_rss_feed).should == Feedzirra::Parser::RSS
99
99
  end
100
100
 
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
101
+ it "should return a Feedzirra::Parser::ITunesRSS object for an itunes feed" do
102
+ Feedzirra::Feed.determine_feed_parser_for_xml(sample_itunes_feed).should == Feedzirra::Parser::ITunesRSS
103
103
  end
104
104
 
105
105
  end
@@ -113,7 +113,7 @@ describe Feedzirra::Feed do
113
113
  true
114
114
  end
115
115
  end
116
-
116
+
117
117
  new_feed_type.should be_able_to_parse(feed_text)
118
118
  Feedzirra::Feed.add_feed_class(new_feed_type)
119
119
  Feedzirra::Feed.determine_feed_parser_for_xml(feed_text).should == new_feed_type
@@ -165,7 +165,7 @@ describe Feedzirra::Feed do
165
165
  @curl_easy = stub('curl_easy')
166
166
  @curl = stub('curl', :headers => {}, :follow_location= => true, :on_failure => true)
167
167
  @curl.stub!(:on_success).and_yield(@cmock)
168
-
168
+
169
169
  Curl::Multi.stub!(:new).and_return(@multi)
170
170
  Curl::Easy.stub!(:new).and_yield(@curl).and_return(@curl_easy)
171
171
  end
@@ -179,7 +179,7 @@ describe Feedzirra::Feed do
179
179
  Feedzirra::Feed.fetch_raw(@paul_feed[:url])
180
180
  @curl.headers['User-Agent'].should == Feedzirra::Feed::USER_AGENT
181
181
  end
182
-
182
+
183
183
  it "should set if modified since as an option if passed" do
184
184
  Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.parse("Wed, 28 Jan 2009 04:10:32 GMT"))
185
185
  @curl.headers["If-Modified-Since"].should == 'Wed, 28 Jan 2009 04:10:32 GMT'
@@ -189,7 +189,7 @@ describe Feedzirra::Feed do
189
189
  Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_none_match => 'ziEyTl4q9GH04BR4jgkImd0GvSE')
190
190
  @curl.headers["If-None-Match"].should == 'ziEyTl4q9GH04BR4jgkImd0GvSE'
191
191
  end
192
-
192
+
193
193
  it 'should set userpwd for http basic authentication if :http_authentication is passed' do
194
194
  @curl.should_receive(:userpwd=).with('username:password')
195
195
  Feedzirra::Feed.fetch_raw(@paul_feed[:url], :http_authentication => ['username', 'password'])
@@ -207,7 +207,7 @@ describe Feedzirra::Feed do
207
207
  it "should take multiple feed urls and return a hash of urls and response xml" do
208
208
  multi = stub('curl_multi', :add => true, :perform => true)
209
209
  Curl::Multi.stub!(:new).and_return(multi)
210
-
210
+
211
211
  paul_response = stub('paul_response', :header_str => '', :body_str => @paul_feed[:xml] )
212
212
  trotter_response = stub('trotter_response', :header_str => '', :body_str => @trotter_feed[:xml] )
213
213
 
@@ -216,10 +216,10 @@ describe Feedzirra::Feed do
216
216
 
217
217
  trotter_curl = stub('trotter_curl', :headers => {}, :follow_location= => true, :on_failure => true)
218
218
  trotter_curl.stub!(:on_success).and_yield(trotter_response)
219
-
219
+
220
220
  Curl::Easy.should_receive(:new).with(@paul_feed[:url]).ordered.and_yield(paul_curl)
221
221
  Curl::Easy.should_receive(:new).with(@trotter_feed[:url]).ordered.and_yield(trotter_curl)
222
-
222
+
223
223
  results = Feedzirra::Feed.fetch_raw([@paul_feed[:url], @trotter_feed[:url]])
224
224
  results.keys.should include(@paul_feed[:url])
225
225
  results.keys.should include(@trotter_feed[:url])
@@ -238,7 +238,7 @@ describe Feedzirra::Feed do
238
238
  @multi = Curl::Multi.new(@paul_feed[:url])
239
239
  @multi.stub!(:add)
240
240
  @easy_curl = Curl::Easy.new(@paul_feed[:url])
241
-
241
+
242
242
  Curl::Easy.should_receive(:new).and_yield(@easy_curl)
243
243
  end
244
244
 
@@ -246,12 +246,12 @@ describe Feedzirra::Feed do
246
246
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :user_agent => 'My cool application')
247
247
  @easy_curl.headers["User-Agent"].should == 'My cool application'
248
248
  end
249
-
249
+
250
250
  it "should set user agent to default if it's not passed as an option" do
251
251
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
252
252
  @easy_curl.headers["User-Agent"].should == Feedzirra::Feed::USER_AGENT
253
253
  end
254
-
254
+
255
255
  it "should set if modified since as an option if passed" do
256
256
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse("Jan 25 2009 04:10:32 GMT"))
257
257
  @easy_curl.headers["If-Modified-Since"].should == 'Sun, 25 Jan 2009 04:10:32 GMT'
@@ -261,12 +261,12 @@ describe Feedzirra::Feed do
261
261
  @easy_curl.should_receive(:follow_location=).with(true)
262
262
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
263
263
  end
264
-
264
+
265
265
  it 'should set userpwd for http basic authentication if :http_authentication is passed' do
266
266
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :http_authentication => ['myusername', 'mypassword'])
267
267
  @easy_curl.userpwd.should == 'myusername:mypassword'
268
268
  end
269
-
269
+
270
270
  it 'should set accepted encodings' do
271
271
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {:compress => true})
272
272
  @easy_curl.headers["Accept-encoding"].should == 'gzip, deflate'
@@ -276,7 +276,7 @@ describe Feedzirra::Feed do
276
276
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_none_match => 'ziEyTl4q9GH04BR4jgkImd0GvSE')
277
277
  @easy_curl.headers["If-None-Match"].should == 'ziEyTl4q9GH04BR4jgkImd0GvSE'
278
278
  end
279
-
279
+
280
280
  describe 'on success' do
281
281
  before(:each) do
282
282
  @feed = mock('feed', :feed_url= => true, :etag= => true, :last_modified= => true)
@@ -292,7 +292,7 @@ describe Feedzirra::Feed do
292
292
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
293
293
  @easy_curl.on_success.call(@easy_curl)
294
294
  end
295
-
295
+
296
296
  it 'should determine the xml parser class' do
297
297
  Feedzirra::Feed.should_receive(:determine_feed_parser_for_xml).with(@paul_feed[:xml]).and_return(Feedzirra::Parser::AtomFeedBurner)
298
298
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
@@ -304,7 +304,7 @@ describe Feedzirra::Feed do
304
304
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
305
305
  @easy_curl.on_success.call(@easy_curl)
306
306
  end
307
-
307
+
308
308
  describe 'when a compatible xml parser class is found' do
309
309
  it 'should set the last effective url to the feed url' do
310
310
  @easy_curl.should_receive(:last_effective_url).and_return(@paul_feed[:url])
@@ -329,11 +329,11 @@ describe Feedzirra::Feed do
329
329
  responses = {}
330
330
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], responses, {})
331
331
  @easy_curl.on_success.call(@easy_curl)
332
-
332
+
333
333
  responses.length.should == 1
334
334
  responses['http://feeds.feedburner.com/PaulDixExplainsNothing'].should == @feed
335
335
  end
336
-
336
+
337
337
  it 'should call proc if :on_success option is passed' do
338
338
  success = lambda { |url, feed| }
339
339
  success.should_receive(:call).with(@paul_feed[:url], @feed)
@@ -363,7 +363,7 @@ describe Feedzirra::Feed do
363
363
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, { :on_failure => failure })
364
364
  @easy_curl.on_failure.call(@easy_curl)
365
365
  end
366
-
366
+
367
367
  it 'should return the http code in the responses' do
368
368
  responses = {}
369
369
  Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], responses, {})
@@ -389,14 +389,14 @@ describe Feedzirra::Feed do
389
389
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, :user_agent => 'My cool application')
390
390
  @easy_curl.headers["User-Agent"].should == 'My cool application'
391
391
  end
392
-
392
+
393
393
  it "should set user agent to default if it's not passed as an option" do
394
394
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
395
395
  @easy_curl.headers["User-Agent"].should == Feedzirra::Feed::USER_AGENT
396
396
  end
397
397
 
398
398
  it "should set if modified since as an option if passed"
399
-
399
+
400
400
  it 'should set follow location to true' do
401
401
  @easy_curl.should_receive(:follow_location=).with(true)
402
402
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
@@ -425,7 +425,7 @@ describe Feedzirra::Feed do
425
425
  end
426
426
 
427
427
  it 'should process the next feed in the queue'
428
-
428
+
429
429
  it 'should parse the updated feed' do
430
430
  Feedzirra::Parser::AtomFeedBurner.should_receive(:parse).and_return(@new_feed)
431
431
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
@@ -466,7 +466,7 @@ describe Feedzirra::Feed do
466
466
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, { :on_success => success })
467
467
  @easy_curl.on_success.call(@easy_curl)
468
468
  end
469
-
469
+
470
470
  it 'should call update from feed on the old feed with the updated feed' do
471
471
  @feed.should_receive(:update_from_feed).with(@new_feed)
472
472
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
@@ -491,7 +491,7 @@ describe Feedzirra::Feed do
491
491
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, { :on_success => success })
492
492
  @easy_curl.on_failure.call(@easy_curl)
493
493
  end
494
-
494
+
495
495
  it 'should return the http code in the responses' do
496
496
  responses = {}
497
497
  Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], responses, {})
@@ -523,7 +523,7 @@ describe Feedzirra::Feed do
523
523
  Zlib::GzipReader.should_receive(:new).with(string_io).and_return(string_io)
524
524
  Feedzirra::Feed.decode_content(@curl_easy)
525
525
  end
526
-
526
+
527
527
  it 'should deflate the response body using inflate if the Content-Encoding: is deflate' do
528
528
  @curl_easy.stub!(:header_str).and_return('Content-Encoding: deflate')
529
529
  Zlib::Inflate.should_receive(:inflate).with(@curl_easy.body_str)
@@ -540,7 +540,7 @@ describe Feedzirra::Feed do
540
540
  it 'should perform the updating using multicurl'
541
541
  it "should pass any request options through to add_feed_to_multi"
542
542
  it "should return a feed object if a single feed is passed in"
543
- it "should return an return an array of feed objects if multiple feeds are passed in"
543
+ it "should return an return an array of feed objects if multiple feeds are passed in"
544
544
  end
545
545
  end
546
546
  end
@@ -1,48 +1,48 @@
1
1
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
2
 
3
- describe Feedzirra::Parser::ITunesRSSItem do
3
+ describe Feedzirra::Parser::ITunesRSSEntry do
4
4
  before(:each) do
5
5
  # I don't really like doing it this way because these unit test should only rely on ITunesRssItem,
6
6
  # but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssItem
7
7
  @item = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed).entries.first
8
8
  end
9
-
9
+
10
10
  it "should parse the title" do
11
11
  @item.title.should == "Shake Shake Shake Your Spices"
12
12
  end
13
-
13
+
14
14
  it "should parse the author" do
15
15
  @item.itunes_author.should == "John Doe"
16
- end
16
+ end
17
17
 
18
18
  it "should parse the subtitle" do
19
19
  @item.itunes_subtitle.should == "A short primer on table spices"
20
- end
20
+ end
21
21
 
22
22
  it "should parse the summary" do
23
23
  @item.itunes_summary.should == "This week we talk about salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!"
24
- end
24
+ end
25
25
 
26
26
  it "should parse the enclosure" do
27
27
  @item.enclosure_length.should == "8727310"
28
28
  @item.enclosure_type.should == "audio/x-m4a"
29
29
  @item.enclosure_url.should == "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
30
- end
30
+ end
31
31
 
32
32
  it "should parse the guid" do
33
33
  @item.guid.should == "http://example.com/podcasts/archive/aae20050615.m4a"
34
- end
34
+ end
35
35
 
36
36
  it "should parse the published date" do
37
- @item.published.should == "Wed, 15 Jun 2005 19:00:00 GMT"
38
- end
37
+ @item.published.should == Time.parse('Wed Jun 15 19:00:00 UTC 2005')
38
+ end
39
39
 
40
40
  it "should parse the duration" do
41
41
  @item.itunes_duration.should == "7:04"
42
- end
42
+ end
43
43
 
44
44
  it "should parse the keywords" do
45
45
  @item.itunes_keywords.should == "salt, pepper, shaker, exciting"
46
- end
46
+ end
47
47
 
48
48
  end
@@ -15,36 +15,51 @@ describe Feedzirra::Parser::ITunesRSS do
15
15
  before(:each) do
16
16
  @feed = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed)
17
17
  end
18
-
18
+
19
19
  it "should parse the subtitle" do
20
20
  @feed.itunes_subtitle.should == "A show about everything"
21
21
  end
22
-
22
+
23
23
  it "should parse the author" do
24
24
  @feed.itunes_author.should == "John Doe"
25
25
  end
26
-
26
+
27
27
  it "should parse an owner" do
28
28
  @feed.itunes_owners.size.should == 1
29
29
  end
30
-
30
+
31
31
  it "should parse an image" do
32
32
  @feed.itunes_image.should == "http://example.com/podcasts/everything/AllAboutEverything.jpg"
33
33
  end
34
-
34
+
35
35
  it "should parse categories" do
36
- @feed.itunes_categories.size == 3
37
- @feed.itunes_categories[0] == "Technology"
38
- @feed.itunes_categories[1] == "Gadgets"
39
- @feed.itunes_categories[2] == "TV &amp; Film"
36
+ @feed.itunes_categories.size == 2
37
+ # @feed.itunes_categories[0].name.should == "Technology"
38
+ @feed.itunes_categories[0].should == "Technology"
39
+ # @feed.itunes_categories[0].sub_categories.size.should == 1
40
+ # @feed.itunes_categories[0].sub_categories[0].should == "Gadgets"
41
+ # @feed.itunes_categories[1].name.should == "TV &amp; Film"
42
+ @feed.itunes_categories[1].should == "Gadgets"
43
+ @feed.itunes_categories[2].should == "TV &#38; Film"
44
+ # @feed.itunes_categories[1].sub_categories.size.should == 0
40
45
  end
41
46
 
42
47
  it "should parse the summary" do
43
48
  @feed.itunes_summary.should == "All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Music Store"
44
49
  end
45
-
50
+
46
51
  it "should parse entries" do
47
- @feed.entries.size.should == 3
52
+ @feed.entries.size.should == 4
53
+ end
54
+
55
+ it "should assign an id even if no guid is present" do
56
+ @feed.entries.last.id.should == 'http://58.159.184.66/9darts/ipod/dai_throw.mp4'
57
+ @feed.entries.last.guid.should == 'http://58.159.184.66/9darts/ipod/dai_throw.mp4'
58
+ end
59
+
60
+ it "should not overwrite an existing id" do
61
+ # @feed.entries[2].id.should == 'http://example.com/podcasts/archive/aae20050601.mp3'
62
+ @feed.entries[2].guid.should == 'http://example.com/podcasts/archive/aae20050601.mp3'
48
63
  end
49
64
  end
50
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: UnderpantsGnome-feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -90,8 +90,9 @@ files:
90
90
  - lib/feedzirra/parser/atom_feed_burner.rb
91
91
  - lib/feedzirra/parser/atom_feed_burner_entry.rb
92
92
  - lib/feedzirra/parser/itunes_rss.rb
93
- - lib/feedzirra/parser/itunes_rss_item.rb
93
+ - lib/feedzirra/parser/itunes_rss_entry.rb
94
94
  - lib/feedzirra/parser/itunes_rss_owner.rb
95
+ - lib/feedzirra/parser/itunes_rss_category.rb
95
96
  - lib/feedzirra/parser/rss.rb
96
97
  - lib/feedzirra/parser/rss_entry.rb
97
98
  - lib/feedzirra/parser/mrss_content.rb
@@ -107,7 +108,7 @@ files:
107
108
  - spec/feedzirra/parser/atom_feed_burner_spec.rb
108
109
  - spec/feedzirra/parser/atom_feed_burner_entry_spec.rb
109
110
  - spec/feedzirra/parser/itunes_rss_spec.rb
110
- - spec/feedzirra/parser/itunes_rss_item_spec.rb
111
+ - spec/feedzirra/parser/itunes_rss_entry_spec.rb
111
112
  - spec/feedzirra/parser/itunes_rss_owner_spec.rb
112
113
  - spec/feedzirra/parser/rss_spec.rb
113
114
  - spec/feedzirra/parser/rss_entry_spec.rb