pauldix-feedzirra 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/Rakefile +39 -0
- data/lib/core_ext/string.rb +9 -0
- data/lib/feedzirra/atom.rb +9 -1
- data/lib/feedzirra/atom_entry.rb +11 -0
- data/lib/feedzirra/atom_feed_burner.rb +9 -1
- data/lib/feedzirra/atom_feed_burner_entry.rb +11 -0
- data/lib/feedzirra/feed.rb +168 -27
- data/lib/feedzirra/feed_entry_utilities.rb +1 -23
- data/lib/feedzirra/itunes_rss.rb +46 -0
- data/lib/feedzirra/itunes_rss_item.rb +28 -0
- data/lib/feedzirra/itunes_rss_owner.rb +8 -0
- data/lib/feedzirra/rdf.rb +9 -1
- data/lib/feedzirra/rdf_entry.rb +10 -0
- data/lib/feedzirra/rss.rb +9 -1
- data/lib/feedzirra/rss_entry.rb +11 -0
- data/lib/feedzirra.rb +5 -0
- data/spec/feedzirra/feed_spec.rb +415 -123
- data/spec/feedzirra/itunes_rss_item_spec.rb +48 -0
- data/spec/feedzirra/itunes_rss_owner_spec.rb +18 -0
- data/spec/feedzirra/itunes_rss_spec.rb +50 -0
- data/spec/spec_helper.rb +21 -9
- metadata +8 -1
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Feedzirra::ITunesRSSItem 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::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 == "Wed, 15 Jun 2005 19:00:00 GMT"
|
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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Feedzirra::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::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
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Feedzirra::ITunesRSS do
|
4
|
+
describe "#will_parse?" do
|
5
|
+
it "should return true for an itunes RSS feed" do
|
6
|
+
Feedzirra::ITunesRSS.should be_able_to_parse(sample_itunes_feed)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return fase for an atom feed" do
|
10
|
+
Feedzirra::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::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 == 3
|
37
|
+
@feed.itunes_categories[0] == "Technology"
|
38
|
+
@feed.itunes_categories[1] == "Gadgets"
|
39
|
+
@feed.itunes_categories[2] == "TV & Film"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse the summary" do
|
43
|
+
@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
|
+
end
|
45
|
+
|
46
|
+
it "should parse entries" do
|
47
|
+
@feed.entries.size.should == 3
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,38 +9,50 @@ $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
|
9
9
|
|
10
10
|
require "lib/feedzirra"
|
11
11
|
|
12
|
+
def load_sample(filename)
|
13
|
+
File.read("#{File.dirname(__FILE__)}/sample_feeds/#{filename}")
|
14
|
+
end
|
15
|
+
|
12
16
|
def sample_atom_feed
|
13
|
-
|
17
|
+
load_sample("AmazonWebServicesBlog.xml")
|
14
18
|
end
|
15
19
|
|
16
20
|
def sample_atom_entry_content
|
17
|
-
|
21
|
+
load_sample("AmazonWebServicesBlogFirstEntryContent.xml")
|
22
|
+
end
|
23
|
+
|
24
|
+
def sample_itunes_feed
|
25
|
+
load_sample("itunes.xml")
|
18
26
|
end
|
19
27
|
|
20
28
|
def sample_rdf_feed
|
21
|
-
|
29
|
+
load_sample("HREFConsideredHarmful.xml")
|
22
30
|
end
|
23
31
|
|
24
32
|
def sample_rdf_entry_content
|
25
|
-
|
33
|
+
load_sample("HREFConsideredHarmfulFirstEntry.xml")
|
26
34
|
end
|
27
35
|
|
28
36
|
def sample_rss_feed_burner_feed
|
29
|
-
|
37
|
+
load_sample("SamHarrisAuthorPhilosopherEssayistAtheist.xml")
|
30
38
|
end
|
31
39
|
|
32
40
|
def sample_rss_feed
|
33
|
-
|
41
|
+
load_sample("TenderLovemaking.xml")
|
34
42
|
end
|
35
43
|
|
36
44
|
def sample_rss_entry_content
|
37
|
-
|
45
|
+
load_sample("TenderLovemakingFirstEntry.xml")
|
38
46
|
end
|
39
47
|
|
40
48
|
def sample_feedburner_atom_feed
|
41
|
-
|
49
|
+
load_sample("PaulDixExplainsNothing.xml")
|
42
50
|
end
|
43
51
|
|
44
52
|
def sample_feedburner_atom_entry_content
|
45
|
-
|
53
|
+
load_sample("PaulDixExplainsNothingFirstEntryContent.xml")
|
54
|
+
end
|
55
|
+
|
56
|
+
def sample_wfw_feed
|
57
|
+
load_sample("PaulDixExplainsNothingWFW.xml")
|
46
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pauldix-feedzirra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dix
|
@@ -82,12 +82,16 @@ extra_rdoc_files: []
|
|
82
82
|
|
83
83
|
files:
|
84
84
|
- lib/core_ext/date.rb
|
85
|
+
- lib/core_ext/string.rb
|
85
86
|
- lib/feedzirra.rb
|
86
87
|
- lib/feedzirra/feed.rb
|
87
88
|
- lib/feedzirra/atom.rb
|
88
89
|
- lib/feedzirra/atom_entry.rb
|
89
90
|
- lib/feedzirra/atom_feed_burner.rb
|
90
91
|
- lib/feedzirra/atom_feed_burner_entry.rb
|
92
|
+
- lib/feedzirra/itunes_rss.rb
|
93
|
+
- lib/feedzirra/itunes_rss_item.rb
|
94
|
+
- lib/feedzirra/itunes_rss_owner.rb
|
91
95
|
- lib/feedzirra/rdf.rb
|
92
96
|
- lib/feedzirra/rdf_entry.rb
|
93
97
|
- lib/feedzirra/rss.rb
|
@@ -103,6 +107,9 @@ files:
|
|
103
107
|
- spec/feedzirra/atom_entry_spec.rb
|
104
108
|
- spec/feedzirra/atom_feed_burner_spec.rb
|
105
109
|
- spec/feedzirra/atom_feed_burner_entry_spec.rb
|
110
|
+
- spec/feedzirra/itunes_rss_spec.rb
|
111
|
+
- spec/feedzirra/itunes_rss_item_spec.rb
|
112
|
+
- spec/feedzirra/itunes_rss_owner_spec.rb
|
106
113
|
- spec/feedzirra/rdf_spec.rb
|
107
114
|
- spec/feedzirra/rdf_entry_spec.rb
|
108
115
|
- spec/feedzirra/rss_spec.rb
|