UnderpantsGnome-feedzirra 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -0
- data/lib/feedzirra.rb +5 -5
- data/lib/feedzirra/feed.rb +0 -1
- data/lib/feedzirra/parser/{itunes_rss_category.rb → itunes_category.rb} +2 -7
- data/lib/feedzirra/parser/mrss_content.rb +1 -10
- data/lib/feedzirra/parser/mrss_credit.rb +13 -0
- data/lib/feedzirra/parser/mrss_restriction.rb +13 -0
- data/lib/feedzirra/parser/rss.rb +38 -9
- data/lib/feedzirra/parser/rss_entry.rb +52 -18
- data/lib/feedzirra/parser/rss_image.rb +15 -0
- data/spec/feedzirra/feed_spec.rb +3 -3
- data/spec/feedzirra/parser/rss_entry_spec.rb +121 -8
- data/spec/feedzirra/parser/rss_spec.rb +66 -14
- metadata +5 -8
- data/lib/feedzirra/parser/itunes_rss.rb +0 -53
- data/lib/feedzirra/parser/itunes_rss_entry.rb +0 -35
- data/lib/feedzirra/parser/itunes_rss_owner.rb +0 -12
- data/spec/feedzirra/parser/itunes_rss_entry_spec.rb +0 -48
- data/spec/feedzirra/parser/itunes_rss_owner_spec.rb +0 -18
- data/spec/feedzirra/parser/itunes_rss_spec.rb +0 -65
data/README.textile
CHANGED
@@ -172,6 +172,8 @@ h2(#changes). Updates from Paul's tree
|
|
172
172
|
|
173
173
|
* Add in Media RSS support that should handle the spec with multiple content entries.
|
174
174
|
* Add in the missing support for nested iTunes Categories
|
175
|
+
* Combined iTunes into RSS, removed extra files
|
176
|
+
* Made element names more consistent across RSS and iTunes
|
175
177
|
|
176
178
|
h2. LICENSE
|
177
179
|
|
data/lib/feedzirra.rb
CHANGED
@@ -11,6 +11,7 @@ require 'active_support/basic_object'
|
|
11
11
|
require 'active_support/core_ext/object'
|
12
12
|
require 'active_support/core_ext/time'
|
13
13
|
|
14
|
+
|
14
15
|
require 'core_ext/date'
|
15
16
|
require 'core_ext/string'
|
16
17
|
|
@@ -19,18 +20,17 @@ require 'feedzirra/feed_entry_utilities'
|
|
19
20
|
require 'feedzirra/feed'
|
20
21
|
|
21
22
|
require 'feedzirra/parser/rss_entry'
|
23
|
+
require 'feedzirra/parser/rss_image'
|
22
24
|
require 'feedzirra/parser/mrss_content'
|
23
|
-
require 'feedzirra/parser/
|
24
|
-
require 'feedzirra/parser/
|
25
|
-
require 'feedzirra/parser/itunes_rss_category'
|
25
|
+
require 'feedzirra/parser/mrss_restriction'
|
26
|
+
require 'feedzirra/parser/itunes_category'
|
26
27
|
require 'feedzirra/parser/atom_entry'
|
27
28
|
require 'feedzirra/parser/atom_feed_burner_entry'
|
28
29
|
|
29
30
|
require 'feedzirra/parser/rss'
|
30
|
-
require 'feedzirra/parser/itunes_rss'
|
31
31
|
require 'feedzirra/parser/atom'
|
32
32
|
require 'feedzirra/parser/atom_feed_burner'
|
33
33
|
|
34
34
|
module Feedzirra
|
35
|
-
VERSION = "0.0.
|
35
|
+
VERSION = "0.0.16"
|
36
36
|
end
|
data/lib/feedzirra/feed.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
module Feedzirra
|
2
|
-
|
3
2
|
module Parser
|
4
|
-
|
5
|
-
|
6
|
-
class ITunesRSS
|
7
|
-
class ITunesRSSCategory
|
3
|
+
class RSS
|
4
|
+
class ITunesCategory
|
8
5
|
include SAXMachine
|
9
|
-
include FeedEntryUtilities
|
10
6
|
|
11
7
|
element :'itunes:category', :as => :name, :value => :text
|
12
8
|
elements :'itunes:category', :as => :sub_categories, :value => :text
|
13
9
|
end
|
14
10
|
end
|
15
11
|
end
|
16
|
-
|
17
12
|
end
|
@@ -1,17 +1,8 @@
|
|
1
1
|
module Feedzirra
|
2
2
|
module Parser
|
3
3
|
class RSSEntry
|
4
|
-
# == Summary
|
5
|
-
# Parser for dealing with multiple media:content entries.
|
6
|
-
#
|
7
|
-
# == Attributes
|
8
|
-
# * url
|
9
|
-
# * content_type
|
10
|
-
# * medium
|
11
|
-
# * duration
|
12
4
|
class MRSSContent
|
13
5
|
include SAXMachine
|
14
|
-
include FeedEntryUtilities
|
15
6
|
|
16
7
|
element :'media:content', :as => :url, :value => :url
|
17
8
|
element :'media:content', :as => :content_type, :value => :type
|
@@ -20,4 +11,4 @@ module Feedzirra
|
|
20
11
|
end
|
21
12
|
end
|
22
13
|
end
|
23
|
-
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
module Parser
|
3
|
+
class RSSEntry
|
4
|
+
class MRSSCredit
|
5
|
+
include SAXMachine
|
6
|
+
|
7
|
+
element :'media:credit', :as => :role, :value => :role
|
8
|
+
element :'media:credit', :as => :scheme, :value => :scheme
|
9
|
+
element :'media:credit', :as => :name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Feedzirra
|
2
|
+
module Parser
|
3
|
+
class RSSEntry
|
4
|
+
class MRSSRestriction
|
5
|
+
include SAXMachine
|
6
|
+
|
7
|
+
element :'media:restriction', :as => :value
|
8
|
+
element :'media:restriction', :as => :scope, :value => :type
|
9
|
+
element :'media:restriction', :as => :relationship, :value => :relationship
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/feedzirra/parser/rss.rb
CHANGED
@@ -1,28 +1,57 @@
|
|
1
1
|
module Feedzirra
|
2
|
-
|
3
2
|
module Parser
|
4
3
|
# == Summary
|
5
4
|
# Parser for dealing with RSS feeds.
|
6
5
|
#
|
7
|
-
# == Attributes
|
8
|
-
# * title
|
9
|
-
# * feed_url
|
10
|
-
# * url
|
11
|
-
# * entries
|
12
6
|
class RSS
|
13
7
|
include SAXMachine
|
14
8
|
include FeedUtilities
|
9
|
+
|
10
|
+
attr_accessor :feed_url
|
11
|
+
|
12
|
+
# RSS 2.0 required elements
|
15
13
|
element :title
|
16
14
|
element :link, :as => :url
|
15
|
+
element :description
|
17
16
|
elements :item, :as => :entries, :class => RSSEntry
|
18
17
|
|
19
|
-
|
18
|
+
# RSS 2.0 optional elements
|
19
|
+
element :language
|
20
|
+
element :copyright
|
21
|
+
element :managingEditor
|
22
|
+
element :webMaster
|
23
|
+
element :pubDate
|
24
|
+
element :lastBuildDate
|
25
|
+
element :category
|
26
|
+
element :generator
|
27
|
+
element :docs
|
28
|
+
element :cloud
|
29
|
+
element :ttl
|
30
|
+
element :image, :class => RSSImage
|
31
|
+
element :rating
|
32
|
+
element :textInput
|
33
|
+
element :skipHours
|
34
|
+
element :skipDays
|
35
|
+
|
36
|
+
# iTunes
|
37
|
+
element :'itunes:author', :as => :author
|
38
|
+
element :'itunes:block', :as => :itunes_block
|
39
|
+
element :'itunes:image', :as => :image, :value => :href
|
40
|
+
element :'itunes:explicit', :as => :explicit
|
41
|
+
element :'itunes:keywords', :as => :keywords
|
42
|
+
element :'itunes:new-feed-url', :as => :feed_url
|
43
|
+
element :'itunes:name', :as => :owner_name
|
44
|
+
element :'itunes:email', :as => :owner_email
|
45
|
+
element :'itunes:subtitle', :as => :subtitle
|
46
|
+
element :'itunes:summary', :as => :summary
|
47
|
+
|
48
|
+
elements :'itunes:category', :as => :categories, :value => :text
|
49
|
+
# elements :'itunes:category', :as => :itunes_categories,
|
50
|
+
# :class => ITunesCategory
|
20
51
|
|
21
52
|
def self.able_to_parse?(xml) #:nodoc:
|
22
53
|
xml =~ /\<rss|rdf/
|
23
54
|
end
|
24
55
|
end
|
25
|
-
|
26
56
|
end
|
27
|
-
|
28
57
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/mrss_content'
|
2
|
+
require File.dirname(__FILE__) + '/mrss_credit'
|
3
|
+
require File.dirname(__FILE__) + '/mrss_restriction'
|
2
4
|
|
3
5
|
module Feedzirra
|
4
|
-
|
5
6
|
module Parser
|
6
7
|
# == Summary
|
7
8
|
# Parser for dealing with RDF feed entries.
|
@@ -17,38 +18,71 @@ module Feedzirra
|
|
17
18
|
class RSSEntry
|
18
19
|
include SAXMachine
|
19
20
|
include FeedEntryUtilities
|
21
|
+
|
22
|
+
# RSS 2.0 elements
|
20
23
|
element :title
|
21
24
|
element :link, :as => :url
|
22
|
-
|
23
|
-
element :"dc:creator", :as => :author
|
24
|
-
element :"content:encoded", :as => :content
|
25
25
|
element :description, :as => :summary
|
26
|
-
|
26
|
+
element :author
|
27
|
+
elements :category, :as => :categories
|
28
|
+
element :comments
|
29
|
+
element :guid, :as => :id
|
27
30
|
element :pubDate, :as => :published
|
31
|
+
element :source
|
32
|
+
element :enclosure, :value => :length, :as => :enclosure_length
|
33
|
+
element :enclosure, :value => :type, :as => :enclosure_type
|
34
|
+
element :enclosure, :value => :url, :as => :enclosure_url
|
35
|
+
|
36
|
+
|
37
|
+
# RDF elements
|
28
38
|
element :"dc:date", :as => :published
|
29
39
|
element :"dc:Date", :as => :published
|
30
40
|
element :"dcterms:created", :as => :published
|
31
|
-
|
32
|
-
|
33
|
-
element :"dcterms:modified", :as => :updated
|
34
41
|
element :issued, :as => :published
|
35
|
-
|
36
|
-
|
37
|
-
element :
|
38
|
-
|
39
|
-
# TODO: uncomment this when the bug is resolved
|
40
|
-
# element :enclosure, :value => :length, :as => :enclosure_length
|
41
|
-
element :enclosure, :value => :type, :as => :enclosure_type
|
42
|
-
element :enclosure, :value => :url, :as => :enclosure_url
|
42
|
+
element :"content:encoded", :as => :content
|
43
|
+
element :"dc:creator", :as => :author
|
44
|
+
element :"dcterms:modified", :as => :updated
|
43
45
|
|
46
|
+
# MediaRSS support
|
44
47
|
element :'media:thumbnail', :as => :media_thumbnail, :value => :url
|
45
48
|
element :'media:thumbnail', :as => :media_thumbnail_width, :value => :width
|
46
49
|
element :'media:thumbnail', :as => :media_thumbnail_height, :value => :height
|
47
50
|
element :'media:description', :as => :media_description
|
51
|
+
|
52
|
+
element :'media:rating', :as => :rating
|
53
|
+
element :'media:rating', :value => :scheme, :as => :rating_scheme
|
54
|
+
|
55
|
+
element :'media:title', :as => :media_title
|
56
|
+
element :'media:keywords', :as => :media_keywords
|
57
|
+
|
58
|
+
element :'media:category', :as => :media_category
|
59
|
+
element :'media:category', :value => :scheme, :as => :media_category_scheme
|
60
|
+
element :'media:category', :value => :label, :as => :media_category_label
|
61
|
+
|
62
|
+
element :'media:hash', :as => :media_hash
|
63
|
+
element :'media:hash', :value => :algo, :as => :media_hash_algo
|
64
|
+
|
65
|
+
element :'media:player', :value => :url, :as => :media_player_url
|
66
|
+
element :'media:player', :value => :width, :as => :media_player_width
|
67
|
+
element :'media:player', :value => :height, :as => :media_player_height
|
68
|
+
|
69
|
+
elements :'media:credit', :as => :credits, :class => MRSSCredit
|
70
|
+
|
71
|
+
element :'media:copyright', :as => :copyright
|
72
|
+
element :'media:copyright', :as => :copyright_url, :value => :url
|
73
|
+
|
74
|
+
element :'media:restriction', :as => :media_restriction, :class => MRSSRestriction
|
75
|
+
|
48
76
|
elements :'media:content', :as => :media_content, :class => MRSSContent
|
49
77
|
|
78
|
+
# iTunes
|
79
|
+
element :'itunes:author', :as => :author
|
80
|
+
element :'itunes:block', :as => :itunes_block
|
81
|
+
element :'itunes:duration', :as => :duration
|
82
|
+
element :'itunes:explicit', :as => :explicit
|
83
|
+
element :'itunes:keywords', :as => :keywords
|
84
|
+
element :'itunes:subtitle', :as => :subtitle
|
85
|
+
element :'itunes:summary', :as => :summary
|
50
86
|
end
|
51
|
-
|
52
87
|
end
|
53
|
-
|
54
88
|
end
|
data/spec/feedzirra/feed_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe Feedzirra::Feed do
|
|
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.
|
59
|
+
feed.entries.first.should_not respond_to(:itunes_author)
|
60
60
|
feed.entries.size.should == 4
|
61
61
|
end
|
62
62
|
end
|
@@ -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::
|
102
|
-
Feedzirra::Feed.determine_feed_parser_for_xml(sample_itunes_feed).should == Feedzirra::Parser::
|
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
|
103
103
|
end
|
104
104
|
|
105
105
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
2
|
|
3
3
|
describe Feedzirra::Parser::RSSEntry do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
# I don't really like doing it this way because these unit test should only rely on RSSEntry,
|
6
6
|
# but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
|
7
7
|
@entry = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should parse the title" do
|
11
11
|
@entry.title.should == "Nokogiri’s Slop Feature"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should parse the url" do
|
15
15
|
@entry.url.should == "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should parse the author" do
|
19
19
|
@entry.author.should == "Aaron Patterson"
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should parse the content" do
|
23
23
|
@entry.content.should == sample_rss_entry_content
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "should provide a summary" do
|
27
27
|
@entry.summary.should == "Oops! When I released nokogiri version 1.0.7, I totally forgot to talk about Nokogiri::Slop() feature that was added. Why is it called \"slop\"? It lets you sloppily explore documents. Basically, it decorates your document with method_missing() that allows you to search your document via method calls.\nGiven this document:\n\ndoc = Nokogiri::Slop(<<-eohtml)\n<html>\n  <body>\n  [...]"
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should parse the published date" do
|
31
31
|
@entry.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
|
32
32
|
end
|
@@ -34,8 +34,121 @@ describe Feedzirra::Parser::RSSEntry do
|
|
34
34
|
it "should parse the categories" do
|
35
35
|
@entry.categories.should == ['computadora', 'nokogiri', 'rails']
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should parse the guid as id" do
|
39
39
|
@entry.id.should == "http://tenderlovemaking.com/?p=198"
|
40
40
|
end
|
41
|
+
|
42
|
+
describe "parsing an iTunes feed" do
|
43
|
+
before do
|
44
|
+
@item = Feedzirra::Parser::RSS.parse(sample_itunes_feed).entries.first
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should parse the title" do
|
48
|
+
@item.title.should == "Shake Shake Shake Your Spices"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should parse the author" do
|
52
|
+
@item.author.should == "John Doe"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should parse the subtitle" do
|
56
|
+
@item.subtitle.should == "A short primer on table spices"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse the summary" do
|
60
|
+
@item.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!"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse the enclosure" do
|
64
|
+
@item.enclosure_length.should == "8727310"
|
65
|
+
@item.enclosure_type.should == "audio/x-m4a"
|
66
|
+
@item.enclosure_url.should == "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should parse the id" do
|
70
|
+
@item.id.should == "http://example.com/podcasts/archive/aae20050615.m4a"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should parse the published date" do
|
74
|
+
@item.published.should == Time.parse('Wed Jun 15 19:00:00 UTC 2005')
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should parse the duration" do
|
78
|
+
@item.duration.should == "7:04"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should parse the keywords" do
|
82
|
+
@item.keywords.should == "salt, pepper, shaker, exciting"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "parsing Media RSS" do
|
87
|
+
before do
|
88
|
+
@item = Feedzirra::Parser::RSS.parse(sample_mrss_feed).entries.first
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should parse media:rating" do
|
92
|
+
@item.rating.should == 'adult'
|
93
|
+
@item.rating_scheme.should == 'urn:simple'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should parse media:title" do
|
97
|
+
@item.media_title.should == 'The Montauk Monster-Hells Visits New York!'
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should parse media:description" do
|
101
|
+
@item.media_description.should == 'The story began with a July 23 article in a local newspaper, The Independent. Jenna Hewitt, 26, of Montauk, and three friends said they found the ...'
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should parse media:keywords" do
|
105
|
+
@item.media_keywords.should == 'kitty, cat, big dog, yarn, fluffy'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should parse media:tumbnail" do
|
109
|
+
@item.media_content.size.should == 1
|
110
|
+
@item.media_description.should == 'The story began with a July 23 article in a local newspaper, The Independent. Jenna Hewitt, 26, of Montauk, and three friends said they found the ...'
|
111
|
+
@item.media_thumbnail.should == 'http://3.gvt0.com/vi/Y3rNEu4A8WM/default.jpg'
|
112
|
+
@item.media_thumbnail_width.should == '320'
|
113
|
+
@item.media_thumbnail_height.should == '240'
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should parse media:category" do
|
117
|
+
@item.media_category.should == 'Arts/Movies/Titles/A/Ace_Ventura_Series/Ace_Ventura_-_Pet_Detective'
|
118
|
+
@item.media_category_scheme.should == 'http://dmoz.org'
|
119
|
+
@item.media_category_label.should == 'Ace Ventura - Pet Detective'
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should parse media:hash" do
|
123
|
+
@item.media_hash.should == 'dfdec888b72151965a34b4b59031290a'
|
124
|
+
@item.media_hash_algo.should == 'md5'
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should parse media:player" do
|
128
|
+
@item.media_player_url.should == 'http://www.example.com/player?id=1111'
|
129
|
+
@item.media_player_width.should == '400'
|
130
|
+
@item.media_player_height.should == '200'
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should parse media:credit" do
|
134
|
+
@item.credits.size.should == 2
|
135
|
+
@item.credits.first.role.should == 'producer'
|
136
|
+
@item.credits.first.scheme.should == 'urn:ebu'
|
137
|
+
pending 'not sure why the name isn\'t getting set'
|
138
|
+
@item.credits.first.name.should == 'John Doe'
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should parse media:copyright" do
|
142
|
+
@item.copyright.should == '2009 Example Co.'
|
143
|
+
@item.copyright_url.should == 'http://example.com/copyright.html'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should parse media:restriction" do
|
147
|
+
pending 'need to figure out why this is getting String'
|
148
|
+
@item.media_restriction.type.should == 'MRSSRestriction'
|
149
|
+
@item.media_restriction.value.should == 'au us'
|
150
|
+
@item.media_restriction.scope.should == 'country'
|
151
|
+
@item.media_restriction.relationship.should == 'allow'
|
152
|
+
end
|
153
|
+
end
|
41
154
|
end
|
@@ -6,36 +6,88 @@ describe Feedzirra::Parser::RSS do
|
|
6
6
|
Feedzirra::Parser::RSS.should be_able_to_parse(sample_rss_feed)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
it "should return true for an rdf feed" do
|
10
|
+
Feedzirra::Parser::RSS.should be_able_to_parse(sample_rdf_feed)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return true for an iTunes feed" do
|
14
|
+
Feedzirra::Parser::RSS.should be_able_to_parse(sample_itunes_feed)
|
15
|
+
end
|
16
|
+
|
14
17
|
it "should return fase for an atom feed" do
|
15
18
|
Feedzirra::Parser::RSS.should_not be_able_to_parse(sample_atom_feed)
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
22
|
describe "parsing" do
|
20
|
-
before
|
21
|
-
@feed = Feedzirra::Parser::RSS.parse(
|
23
|
+
before do
|
24
|
+
@feed = Feedzirra::Parser::RSS.parse(sample_mrss_feed)
|
22
25
|
end
|
23
|
-
|
26
|
+
|
24
27
|
it "should parse the title" do
|
25
|
-
@feed.title.should == "
|
28
|
+
@feed.title.should == "Google Video - Hot videos"
|
26
29
|
end
|
27
|
-
|
30
|
+
|
28
31
|
it "should parse the url" do
|
29
|
-
@feed.url.should == "http://
|
32
|
+
@feed.url.should == "http://video.google.com/"
|
30
33
|
end
|
31
|
-
|
34
|
+
|
32
35
|
it "should provide an accessor for the feed_url" do
|
33
36
|
@feed.respond_to?(:feed_url).should == true
|
34
37
|
@feed.respond_to?(:feed_url=).should == true
|
35
38
|
end
|
36
|
-
|
39
|
+
|
37
40
|
it "should parse entries" do
|
38
|
-
@feed.entries.size.should ==
|
41
|
+
@feed.entries.size.should == 20
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse the image" do
|
45
|
+
pending 'setting NilClass for some reason'
|
46
|
+
@feed.image.class.should == 'RSSImage'
|
47
|
+
@feed.image.title.should == 'Google Video - Hot videos'
|
48
|
+
@feed.image.link.should == 'http://video.google.com/'
|
49
|
+
@feed.image.url.should == 'http://video.google.com/common/google_logo_small.jpg'
|
50
|
+
@feed.image.width.should == '100'
|
51
|
+
@feed.image.height.should == '37'
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "parsing an iTunes feed" do
|
55
|
+
before do
|
56
|
+
@feed = Feedzirra::Parser::RSS.parse(sample_itunes_feed)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse an image" do
|
60
|
+
@feed.image.should == "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse categories" do
|
64
|
+
@feed.categories.size == 2
|
65
|
+
@feed.categories[0].should == "Technology"
|
66
|
+
@feed.categories[1].should == "Gadgets"
|
67
|
+
@feed.categories[2].should == "TV & Film"
|
68
|
+
|
69
|
+
# @feed.categories[0].name.should == "Technology"
|
70
|
+
# @feed.categories[0].sub_categories.size.should == 1
|
71
|
+
# @feed.categories[0].sub_categories[0].should == "Gadgets"
|
72
|
+
# @feed.categories[1].name.should == "TV & Film"
|
73
|
+
# @feed.categories[1].sub_categories.size.should == 0
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse the summary" do
|
77
|
+
@feed.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"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should parse entries" do
|
81
|
+
@feed.entries.size.should == 4
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should parse the owner name" do
|
85
|
+
@feed.owner_name.should == 'John Doe'
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should parse the owner email" do
|
89
|
+
@feed.owner_email.should == 'john.doe@example.com'
|
90
|
+
end
|
39
91
|
end
|
40
92
|
end
|
41
93
|
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.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dix
|
@@ -89,13 +89,13 @@ files:
|
|
89
89
|
- lib/feedzirra/parser/atom_entry.rb
|
90
90
|
- lib/feedzirra/parser/atom_feed_burner.rb
|
91
91
|
- lib/feedzirra/parser/atom_feed_burner_entry.rb
|
92
|
-
- lib/feedzirra/parser/
|
93
|
-
- lib/feedzirra/parser/itunes_rss_entry.rb
|
94
|
-
- lib/feedzirra/parser/itunes_rss_owner.rb
|
95
|
-
- lib/feedzirra/parser/itunes_rss_category.rb
|
92
|
+
- lib/feedzirra/parser/itunes_category.rb
|
96
93
|
- lib/feedzirra/parser/rss.rb
|
97
94
|
- lib/feedzirra/parser/rss_entry.rb
|
95
|
+
- lib/feedzirra/parser/rss_image.rb
|
98
96
|
- lib/feedzirra/parser/mrss_content.rb
|
97
|
+
- lib/feedzirra/parser/mrss_credit.rb
|
98
|
+
- lib/feedzirra/parser/mrss_restriction.rb
|
99
99
|
- lib/feedzirra/feed_utilities.rb
|
100
100
|
- lib/feedzirra/feed_entry_utilities.rb
|
101
101
|
- README.textile
|
@@ -107,9 +107,6 @@ files:
|
|
107
107
|
- spec/feedzirra/parser/atom_entry_spec.rb
|
108
108
|
- spec/feedzirra/parser/atom_feed_burner_spec.rb
|
109
109
|
- spec/feedzirra/parser/atom_feed_burner_entry_spec.rb
|
110
|
-
- spec/feedzirra/parser/itunes_rss_spec.rb
|
111
|
-
- spec/feedzirra/parser/itunes_rss_entry_spec.rb
|
112
|
-
- spec/feedzirra/parser/itunes_rss_owner_spec.rb
|
113
110
|
- spec/feedzirra/parser/rss_spec.rb
|
114
111
|
- spec/feedzirra/parser/rss_entry_spec.rb
|
115
112
|
- spec/feedzirra/feed_utilities_spec.rb
|
@@ -1,53 +0,0 @@
|
|
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
|
-
# elements :'itunes:category', :as => :itunes_categories,
|
38
|
-
# :class => ITunesRSSCategory
|
39
|
-
|
40
|
-
|
41
|
-
elements :"itunes:owner", :as => :itunes_owners, :class => ITunesRSSOwner
|
42
|
-
|
43
|
-
elements :item, :as => :entries, :class => ITunesRSSEntry
|
44
|
-
|
45
|
-
def self.able_to_parse?(xml)
|
46
|
-
xml =~ /xmlns:itunes=\"http:\/\/www.itunes.com\/dtds\/podcast-1.0.dtd\"/
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,35 +0,0 @@
|
|
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 ITunesRSSEntry
|
7
|
-
include SAXMachine
|
8
|
-
include FeedEntryUtilities
|
9
|
-
element :author
|
10
|
-
element :guid
|
11
|
-
element :guid, :as => :id
|
12
|
-
element :enclosure, :value => :url, :as => :guid
|
13
|
-
element :enclosure, :value => :url, :as => :id
|
14
|
-
element :title
|
15
|
-
element :link, :as => :url
|
16
|
-
element :description, :as => :summary
|
17
|
-
element :description, :as => :content
|
18
|
-
element :pubDate, :as => :published
|
19
|
-
|
20
|
-
# If author is not present use author tag on the item
|
21
|
-
element :"itunes:author", :as => :itunes_author
|
22
|
-
element :"itunes:block", :as => :itunes_block
|
23
|
-
element :"itunes:duration", :as => :itunes_duration
|
24
|
-
element :"itunes:explicit", :as => :itunes_explicit
|
25
|
-
element :"itunes:keywords", :as => :itunes_keywords
|
26
|
-
element :"itunes:subtitle", :as => :itunes_subtitle
|
27
|
-
# If summary is not present, use the description tag
|
28
|
-
element :"itunes:summary", :as => :itunes_summary
|
29
|
-
element :enclosure, :value => :length, :as => :enclosure_length
|
30
|
-
element :enclosure, :value => :type, :as => :enclosure_type
|
31
|
-
element :enclosure, :value => :url, :as => :enclosure_url
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
-
|
3
|
-
describe Feedzirra::Parser::ITunesRSSEntry do
|
4
|
-
before(:each) do
|
5
|
-
# I don't really like doing it this way because these unit test should only rely on ITunesRssItem,
|
6
|
-
# but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssItem
|
7
|
-
@item = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed).entries.first
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should parse the title" do
|
11
|
-
@item.title.should == "Shake Shake Shake Your Spices"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should parse the author" do
|
15
|
-
@item.itunes_author.should == "John Doe"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should parse the subtitle" do
|
19
|
-
@item.itunes_subtitle.should == "A short primer on table spices"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should parse the summary" do
|
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
|
25
|
-
|
26
|
-
it "should parse the enclosure" do
|
27
|
-
@item.enclosure_length.should == "8727310"
|
28
|
-
@item.enclosure_type.should == "audio/x-m4a"
|
29
|
-
@item.enclosure_url.should == "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should parse the guid" do
|
33
|
-
@item.guid.should == "http://example.com/podcasts/archive/aae20050615.m4a"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should parse the published date" do
|
37
|
-
@item.published.should == Time.parse('Wed Jun 15 19:00:00 UTC 2005')
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should parse the duration" do
|
41
|
-
@item.itunes_duration.should == "7:04"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should parse the keywords" do
|
45
|
-
@item.itunes_keywords.should == "salt, pepper, shaker, exciting"
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
-
|
3
|
-
describe Feedzirra::Parser::ITunesRSSOwner do
|
4
|
-
before(:each) do
|
5
|
-
# I don't really like doing it this way because these unit test should only rely on RSSEntry,
|
6
|
-
# but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssOwner
|
7
|
-
@owner = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed).itunes_owners.first
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should parse the name" do
|
11
|
-
@owner.name.should == "John Doe"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should parse the email" do
|
15
|
-
@owner.email.should == "john.doe@example.com"
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
-
|
3
|
-
describe Feedzirra::Parser::ITunesRSS do
|
4
|
-
describe "#will_parse?" do
|
5
|
-
it "should return true for an itunes RSS feed" do
|
6
|
-
Feedzirra::Parser::ITunesRSS.should be_able_to_parse(sample_itunes_feed)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should return fase for an atom feed" do
|
10
|
-
Feedzirra::Parser::ITunesRSS.should_not be_able_to_parse(sample_atom_feed)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "parsing" do
|
15
|
-
before(:each) do
|
16
|
-
@feed = Feedzirra::Parser::ITunesRSS.parse(sample_itunes_feed)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should parse the subtitle" do
|
20
|
-
@feed.itunes_subtitle.should == "A show about everything"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should parse the author" do
|
24
|
-
@feed.itunes_author.should == "John Doe"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should parse an owner" do
|
28
|
-
@feed.itunes_owners.size.should == 1
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should parse an image" do
|
32
|
-
@feed.itunes_image.should == "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should parse categories" do
|
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 & Film"
|
42
|
-
@feed.itunes_categories[1].should == "Gadgets"
|
43
|
-
@feed.itunes_categories[2].should == "TV & Film"
|
44
|
-
# @feed.itunes_categories[1].sub_categories.size.should == 0
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should parse the summary" do
|
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"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should parse entries" do
|
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'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|