feedzirra 0.0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +196 -0
- data/Rakefile +56 -0
- data/lib/core_ext/date.rb +21 -0
- data/lib/core_ext/string.rb +9 -0
- data/lib/feedzirra.rb +34 -0
- data/lib/feedzirra/feed.rb +324 -0
- data/lib/feedzirra/feed_entry_utilities.rb +45 -0
- data/lib/feedzirra/feed_utilities.rb +71 -0
- data/lib/feedzirra/parser/atom.rb +47 -0
- data/lib/feedzirra/parser/atom_entry.rb +51 -0
- data/lib/feedzirra/parser/atom_feed_burner.rb +27 -0
- data/lib/feedzirra/parser/atom_feed_burner_entry.rb +35 -0
- data/lib/feedzirra/parser/itunes_rss.rb +50 -0
- data/lib/feedzirra/parser/itunes_rss_item.rb +31 -0
- data/lib/feedzirra/parser/itunes_rss_owner.rb +12 -0
- data/lib/feedzirra/parser/rss.rb +40 -0
- data/lib/feedzirra/parser/rss_entry.rb +55 -0
- data/spec/feedzirra/feed_entry_utilities_spec.rb +52 -0
- data/spec/feedzirra/feed_spec.rb +546 -0
- data/spec/feedzirra/feed_utilities_spec.rb +149 -0
- data/spec/feedzirra/parser/atom_entry_spec.rb +49 -0
- data/spec/feedzirra/parser/atom_feed_burner_entry_spec.rb +42 -0
- data/spec/feedzirra/parser/atom_feed_burner_spec.rb +39 -0
- data/spec/feedzirra/parser/atom_spec.rb +63 -0
- data/spec/feedzirra/parser/itunes_rss_item_spec.rb +48 -0
- data/spec/feedzirra/parser/itunes_rss_owner_spec.rb +18 -0
- data/spec/feedzirra/parser/itunes_rss_spec.rb +50 -0
- data/spec/feedzirra/parser/rss_entry_spec.rb +91 -0
- data/spec/feedzirra/parser/rss_spec.rb +88 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +66 -0
- metadata +144 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Feedzirra::Parser::RSSEntry do
|
4
|
+
describe "parsing of simple rss feed item" do
|
5
|
+
before(:each) do
|
6
|
+
# I don't really like doing it this way because these unit test should only rely on RSSEntry,
|
7
|
+
# but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
|
8
|
+
@entry = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse the title" do
|
12
|
+
@entry.title.should == "Nokogiri’s Slop Feature"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should parse the url" do
|
16
|
+
@entry.url.should == "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse the author" do
|
20
|
+
@entry.author.should == "Aaron Patterson"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse the content" do
|
24
|
+
@entry.content.should == sample_rss_entry_content
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should provide a summary" do
|
28
|
+
@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  [...]"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should parse the published date" do
|
32
|
+
@entry.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should parse the categories" do
|
36
|
+
@entry.categories.should == ['computadora', 'nokogiri', 'rails']
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should parse the guid as id" do
|
40
|
+
@entry.id.should == "http://tenderlovemaking.com/?p=198"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "parsing of media rss feed item" do
|
45
|
+
before(:each) do
|
46
|
+
# I don't really like doing it this way because these unit test should only rely on RSSEntry,
|
47
|
+
# but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
|
48
|
+
@entry = Feedzirra::Parser::RSS.parse(sample_media_rss_feed).entries.first
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should parse the title" do
|
52
|
+
@entry.title.should == "the new boy on the block"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should parse the url" do
|
56
|
+
@entry.url.should == "http://horowhenua.kete.net.nz/site/images/show/15535-the-new-boy-on-the-block"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse link rel='related' as related" do
|
60
|
+
@entry.related.should == ["http://horowhenua.kete.net.nz/", "http://horowhenua.kete.net.nz/site/all/images"]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should provide a summary" do
|
64
|
+
@entry.summary.should == sample_media_rss_entry_content
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should parse the published date" do
|
68
|
+
@entry.published.to_s.should == "Mon Mar 23 07:55:43 UTC 2009"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should parse the guid as id" do
|
72
|
+
@entry.id.should == "http://horowhenua.kete.net.nz/site/images/show/15535-the-new-boy-on-the-block"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should parse media:content url as media_content" do
|
76
|
+
@entry.media_content.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_large.JPG"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should parse media:description as media_description" do
|
80
|
+
@entry.media_description.should == "big crane from Wellington visits the site for the week"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should parse media:thumbnail url as media_thumbnail" do
|
84
|
+
@entry.media_thumbnail.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_medium.JPG"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should parse enclosure url as enclosure" do
|
88
|
+
@entry.enclosure.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_large.JPG"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Feedzirra::Parser::RSS do
|
4
|
+
describe "#will_parse?" do
|
5
|
+
it "should return true for an RSS feed" do
|
6
|
+
Feedzirra::Parser::RSS.should be_able_to_parse(sample_rss_feed)
|
7
|
+
end
|
8
|
+
|
9
|
+
# this is no longer true. combined rdf and rss into one
|
10
|
+
# it "should return false for an rdf feed" do
|
11
|
+
# Feedzirra::RSS.should_not be_able_to_parse(sample_rdf_feed)
|
12
|
+
# end
|
13
|
+
|
14
|
+
it "should return fase for an atom feed" do
|
15
|
+
Feedzirra::Parser::RSS.should_not be_able_to_parse(sample_atom_feed)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "parsing of simple rss feed" do
|
20
|
+
before(:each) do
|
21
|
+
@feed = Feedzirra::Parser::RSS.parse(sample_rss_feed)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should parse the title" do
|
25
|
+
@feed.title.should == "Tender Lovemaking"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse the url" do
|
29
|
+
@feed.url.should == "http://tenderlovemaking.com"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should provide an accessor for the feed_url" do
|
33
|
+
@feed.respond_to?(:feed_url).should == true
|
34
|
+
@feed.respond_to?(:feed_url=).should == true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should parse entries" do
|
38
|
+
@feed.entries.size.should == 10
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "parsing of media rss feed" do
|
43
|
+
before(:each) do
|
44
|
+
@feed = Feedzirra::Parser::RSS.parse(sample_media_rss_feed)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should parse the title" do
|
48
|
+
@feed.title.should == "horowhenua.kete.net.nz - Latest 50 Results in images"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should parse the url" do
|
52
|
+
@feed.url.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should parse link rel='related' as related" do
|
56
|
+
@feed.related.should == ["http://horowhenua.kete.net.nz/", "http://horowhenua.kete.net.nz/site/all/images"]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse the description" do
|
60
|
+
@feed.description.should == "Showing 1 - 50 results of 368"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse the language" do
|
64
|
+
@feed.language.should == "en-nz"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should provide an accessor for the feed_url" do
|
68
|
+
@feed.respond_to?(:feed_url).should == true
|
69
|
+
@feed.respond_to?(:feed_url=).should == true
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse the prev atom:link" do
|
73
|
+
@feed.prev_page.should == "http://aws.typepad.com/aws/atom.xml?page=1"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse the next atom:link" do
|
77
|
+
@feed.next_page.should == "http://aws.typepad.com/aws/atom.xml?page=3"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should parse the last atom:link" do
|
81
|
+
@feed.last_page.should == "http://aws.typepad.com/aws/atom.xml?page=5"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should parse entries" do
|
85
|
+
@feed.entries.size.should == 50
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
|
4
|
+
# gem install redgreen for colored test output
|
5
|
+
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
|
6
|
+
|
7
|
+
path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
8
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
9
|
+
|
10
|
+
require "lib/feedzirra"
|
11
|
+
|
12
|
+
def load_sample(filename)
|
13
|
+
File.read("#{File.dirname(__FILE__)}/sample_feeds/#{filename}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def sample_atom_feed
|
17
|
+
load_sample("AmazonWebServicesBlog.xml")
|
18
|
+
end
|
19
|
+
|
20
|
+
def sample_atom_entry_content
|
21
|
+
load_sample("AmazonWebServicesBlogFirstEntryContent.xml")
|
22
|
+
end
|
23
|
+
|
24
|
+
def sample_itunes_feed
|
25
|
+
load_sample("itunes.xml")
|
26
|
+
end
|
27
|
+
|
28
|
+
def sample_rdf_feed
|
29
|
+
load_sample("HREFConsideredHarmful.xml")
|
30
|
+
end
|
31
|
+
|
32
|
+
def sample_rdf_entry_content
|
33
|
+
load_sample("HREFConsideredHarmfulFirstEntry.xml")
|
34
|
+
end
|
35
|
+
|
36
|
+
def sample_rss_feed_burner_feed
|
37
|
+
load_sample("SamHarrisAuthorPhilosopherEssayistAtheist.xml")
|
38
|
+
end
|
39
|
+
|
40
|
+
def sample_rss_feed
|
41
|
+
load_sample("TenderLovemaking.xml")
|
42
|
+
end
|
43
|
+
|
44
|
+
def sample_rss_entry_content
|
45
|
+
load_sample("TenderLovemakingFirstEntry.xml")
|
46
|
+
end
|
47
|
+
|
48
|
+
def sample_feedburner_atom_feed
|
49
|
+
load_sample("PaulDixExplainsNothing.xml")
|
50
|
+
end
|
51
|
+
|
52
|
+
def sample_feedburner_atom_entry_content
|
53
|
+
load_sample("PaulDixExplainsNothingFirstEntryContent.xml")
|
54
|
+
end
|
55
|
+
|
56
|
+
def sample_wfw_feed
|
57
|
+
load_sample("PaulDixExplainsNothingWFW.xml")
|
58
|
+
end
|
59
|
+
|
60
|
+
def sample_media_rss_feed
|
61
|
+
load_sample("KeteHorowhenua.xml")
|
62
|
+
end
|
63
|
+
|
64
|
+
def sample_media_rss_entry_content
|
65
|
+
load_sample("KeteHorowhenuaFirstEntry.xml")
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: feedzirra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.18.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Dix
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-03 00:00:00 +12:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: pauldix-sax-machine
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.12
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: taf2-curb
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.2.3
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: builder
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.1.2
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.0.0
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: mdalessio-dryopteris
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.0.0
|
74
|
+
version:
|
75
|
+
description:
|
76
|
+
email: paul@pauldix.net
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files: []
|
82
|
+
|
83
|
+
files:
|
84
|
+
- lib/core_ext/date.rb
|
85
|
+
- lib/core_ext/string.rb
|
86
|
+
- lib/feedzirra.rb
|
87
|
+
- lib/feedzirra/feed.rb
|
88
|
+
- lib/feedzirra/parser/atom.rb
|
89
|
+
- lib/feedzirra/parser/atom_entry.rb
|
90
|
+
- lib/feedzirra/parser/atom_feed_burner.rb
|
91
|
+
- lib/feedzirra/parser/atom_feed_burner_entry.rb
|
92
|
+
- lib/feedzirra/parser/itunes_rss.rb
|
93
|
+
- lib/feedzirra/parser/itunes_rss_item.rb
|
94
|
+
- lib/feedzirra/parser/itunes_rss_owner.rb
|
95
|
+
- lib/feedzirra/parser/rss.rb
|
96
|
+
- lib/feedzirra/parser/rss_entry.rb
|
97
|
+
- lib/feedzirra/feed_utilities.rb
|
98
|
+
- lib/feedzirra/feed_entry_utilities.rb
|
99
|
+
- README.textile
|
100
|
+
- Rakefile
|
101
|
+
- spec/spec.opts
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- spec/feedzirra/feed_spec.rb
|
104
|
+
- spec/feedzirra/parser/atom_spec.rb
|
105
|
+
- spec/feedzirra/parser/atom_entry_spec.rb
|
106
|
+
- spec/feedzirra/parser/atom_feed_burner_spec.rb
|
107
|
+
- spec/feedzirra/parser/atom_feed_burner_entry_spec.rb
|
108
|
+
- spec/feedzirra/parser/itunes_rss_spec.rb
|
109
|
+
- spec/feedzirra/parser/itunes_rss_item_spec.rb
|
110
|
+
- spec/feedzirra/parser/itunes_rss_owner_spec.rb
|
111
|
+
- spec/feedzirra/parser/rss_spec.rb
|
112
|
+
- spec/feedzirra/parser/rss_entry_spec.rb
|
113
|
+
- spec/feedzirra/feed_utilities_spec.rb
|
114
|
+
- spec/feedzirra/feed_entry_utilities_spec.rb
|
115
|
+
has_rdoc: true
|
116
|
+
homepage: http://github.com/pauldix/feedzirra
|
117
|
+
licenses: []
|
118
|
+
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: "0"
|
129
|
+
version:
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
135
|
+
version:
|
136
|
+
requirements: []
|
137
|
+
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.3.5
|
140
|
+
signing_key:
|
141
|
+
specification_version: 2
|
142
|
+
summary: "A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all."
|
143
|
+
test_files: []
|
144
|
+
|