feedtools 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/lib/feed_tools.rb +730 -301
- data/rakefile +1 -1
- data/test/amp_test.rb +475 -0
- data/test/atom_test.rb +38 -0
- data/test/cache_test.rb +23 -0
- data/test/helper_test.rb +29 -0
- data/test/rss_test.rb +99 -5
- metadata +6 -2
data/test/atom_test.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'feed_tools'
|
3
|
+
|
4
|
+
class AtomTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
FeedTools.tidy_enabled = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_feed_title
|
10
|
+
feed = FeedTools::Feed.open(
|
11
|
+
'http://feedparser.org/tests/wellformed/atom/atom_namespace_1.xml')
|
12
|
+
assert_equal("Example Atom", feed.title)
|
13
|
+
assert_equal(false, feed.bozo?)
|
14
|
+
feed = FeedTools::Feed.open(
|
15
|
+
'http://feedparser.org/tests/wellformed/atom/atom_namespace_2.xml')
|
16
|
+
assert_equal("Example Atom", feed.title)
|
17
|
+
assert_equal(false, feed.bozo?)
|
18
|
+
feed = FeedTools::Feed.open(
|
19
|
+
'http://feedparser.org/tests/wellformed/atom/atom_namespace_3.xml')
|
20
|
+
assert_equal("Example Atom", feed.title)
|
21
|
+
assert_equal(false, feed.bozo?)
|
22
|
+
feed = FeedTools::Feed.open(
|
23
|
+
'http://feedparser.org/tests/wellformed/atom/atom_namespace_4.xml')
|
24
|
+
assert_equal("Example Atom", feed.title)
|
25
|
+
assert_equal(false, feed.bozo?)
|
26
|
+
feed = FeedTools::Feed.open(
|
27
|
+
'http://feedparser.org/tests/wellformed/atom/atom_namespace_5.xml')
|
28
|
+
assert_equal("Example Atom", feed.title)
|
29
|
+
assert_equal(false, feed.bozo?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_feed_author
|
33
|
+
# feed = FeedTools::Feed.open(
|
34
|
+
# 'http://feedparser.org/tests/wellformed/atom/atom_namespace_5.xml')
|
35
|
+
# assert_equal("Example Atom", feed.title)
|
36
|
+
# assert_equal(false, feed.bozo?)
|
37
|
+
end
|
38
|
+
end
|
data/test/cache_test.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'feed_tools'
|
3
|
+
|
4
|
+
class CacheTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
FeedTools.tidy_enabled = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_database_connection
|
10
|
+
# turn the cache on for this test
|
11
|
+
FeedTools.feed_cache = FeedTools::DatabaseFeedCache
|
12
|
+
|
13
|
+
unless FeedTools.feed_cache.nil?
|
14
|
+
# Assumes that there is a database.yml file handy
|
15
|
+
assert_equal(true, FeedTools.feed_cache_connected?)
|
16
|
+
else
|
17
|
+
puts "\nSkipping cache test since the cache is still disabled.\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
# turn the cache back off
|
21
|
+
FeedTools.feed_cache = nil
|
22
|
+
end
|
23
|
+
end
|
data/test/helper_test.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'feed_tools'
|
3
|
+
|
4
|
+
class HelperTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
FeedTools.tidy_enabled = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_escape_entities
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_unescape_entities
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_normalize_url
|
16
|
+
assert_equal("http://slashdot.org/",
|
17
|
+
FeedTools.normalize_url("slashdot.org"))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_sanitize_html
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_tidy_html
|
24
|
+
FeedTools.tidy_enabled = true
|
25
|
+
|
26
|
+
|
27
|
+
FeedTools.tidy_enabled = false
|
28
|
+
end
|
29
|
+
end
|
data/test/rss_test.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'feed_tools'
|
3
3
|
|
4
|
-
# testing is done with the cache turned off
|
5
|
-
FeedTools.feed_cache = nil
|
6
|
-
|
7
4
|
class RssTest < Test::Unit::TestCase
|
8
5
|
def setup
|
6
|
+
FeedTools.tidy_enabled = false
|
9
7
|
end
|
10
8
|
|
11
9
|
def test_feed_well_formed
|
12
10
|
feed = FeedTools::Feed.open(
|
13
11
|
'http://feedparser.org/tests/wellformed/rss/aaa_wellformed.xml')
|
14
12
|
assert_equal(false, feed.bozo?)
|
15
|
-
end
|
13
|
+
end
|
16
14
|
|
17
15
|
def test_feed_title
|
18
16
|
feed = FeedTools::Feed.open(
|
@@ -112,7 +110,7 @@ class RssTest < Test::Unit::TestCase
|
|
112
110
|
feed = FeedTools::Feed.open(
|
113
111
|
'http://feedparser.org/tests/wellformed/rss/' +
|
114
112
|
'item_description_not_a_doctype.xml')
|
115
|
-
assert_equal('<!\'
|
113
|
+
assert_equal('<!\' <a href="foo">', feed.entries.first.description)
|
116
114
|
assert_equal(false, feed.bozo?)
|
117
115
|
end
|
118
116
|
|
@@ -133,4 +131,100 @@ class RssTest < Test::Unit::TestCase
|
|
133
131
|
assert_equal('http://guid.example.com/', feed.entries.first.link)
|
134
132
|
assert_equal(false, feed.bozo?)
|
135
133
|
end
|
134
|
+
|
135
|
+
def test_feed_author
|
136
|
+
feed = FeedTools::Feed.open(
|
137
|
+
'http://feedparser.org/tests/wellformed/rss/channel_author.xml')
|
138
|
+
assert_equal("Example editor (me@example.com)", feed.author.raw)
|
139
|
+
assert_equal("Example editor", feed.author.name)
|
140
|
+
assert_equal("me@example.com", feed.author.email)
|
141
|
+
assert_equal(nil, feed.author.url)
|
142
|
+
assert_equal(false, feed.bozo?)
|
143
|
+
feed = FeedTools::Feed.open(
|
144
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
145
|
+
'channel_author_map_author_detail_email_2.xml')
|
146
|
+
assert_equal("Example editor (me+spam@example.com)", feed.author.raw)
|
147
|
+
assert_equal("Example editor", feed.author.name)
|
148
|
+
assert_equal("me+spam@example.com", feed.author.email)
|
149
|
+
assert_equal(nil, feed.author.url)
|
150
|
+
assert_equal(false, feed.bozo?)
|
151
|
+
feed = FeedTools::Feed.open(
|
152
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
153
|
+
'channel_author_map_author_detail_email_3.xml')
|
154
|
+
assert_equal("me@example.com (Example editor)", feed.author.raw)
|
155
|
+
assert_equal("Example editor", feed.author.name)
|
156
|
+
assert_equal("me@example.com", feed.author.email)
|
157
|
+
assert_equal(nil, feed.author.url)
|
158
|
+
assert_equal(false, feed.bozo?)
|
159
|
+
feed = FeedTools::Feed.open(
|
160
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_author.xml')
|
161
|
+
assert_equal("Example editor", feed.author.raw)
|
162
|
+
assert_equal("Example editor", feed.author.name)
|
163
|
+
assert_equal(nil, feed.author.email)
|
164
|
+
assert_equal(nil, feed.author.url)
|
165
|
+
assert_equal(false, feed.bozo?)
|
166
|
+
feed = FeedTools::Feed.open(
|
167
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
168
|
+
'channel_dc_author_map_author_detail_email.xml')
|
169
|
+
assert_equal("Example editor (me@example.com)", feed.author.raw)
|
170
|
+
assert_equal("Example editor", feed.author.name)
|
171
|
+
assert_equal("me@example.com", feed.author.email)
|
172
|
+
assert_equal(nil, feed.author.url)
|
173
|
+
assert_equal(false, feed.bozo?)
|
174
|
+
feed = FeedTools::Feed.open(
|
175
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_creator.xml')
|
176
|
+
assert_equal("Example editor", feed.author.raw)
|
177
|
+
assert_equal("Example editor", feed.author.name)
|
178
|
+
assert_equal(nil, feed.author.email)
|
179
|
+
assert_equal(nil, feed.author.url)
|
180
|
+
assert_equal(false, feed.bozo?)
|
181
|
+
feed = FeedTools::Feed.open(
|
182
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
183
|
+
'channel_dc_creator_map_author_detail_email.xml')
|
184
|
+
assert_equal("Example editor (me@example.com)", feed.author.raw)
|
185
|
+
assert_equal("Example editor", feed.author.name)
|
186
|
+
assert_equal("me@example.com", feed.author.email)
|
187
|
+
assert_equal(nil, feed.author.url)
|
188
|
+
assert_equal(false, feed.bozo?)
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_feed_publisher
|
192
|
+
feed = FeedTools::Feed.open(
|
193
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_publisher.xml')
|
194
|
+
assert_equal("Example editor", feed.publisher.raw)
|
195
|
+
assert_equal("Example editor", feed.publisher.name)
|
196
|
+
assert_equal(nil, feed.publisher.email)
|
197
|
+
assert_equal(nil, feed.publisher.url)
|
198
|
+
assert_equal(false, feed.bozo?)
|
199
|
+
feed = FeedTools::Feed.open(
|
200
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
201
|
+
'channel_dc_publisher_email.xml')
|
202
|
+
assert_equal("Example editor (me@example.com)", feed.publisher.raw)
|
203
|
+
assert_equal("Example editor", feed.publisher.name)
|
204
|
+
assert_equal("me@example.com", feed.publisher.email)
|
205
|
+
assert_equal(nil, feed.publisher.url)
|
206
|
+
assert_equal(false, feed.bozo?)
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_feed_copyright
|
210
|
+
feed = FeedTools::Feed.open(
|
211
|
+
'http://feedparser.org/tests/wellformed/rss/channel_copyright.xml')
|
212
|
+
assert_equal("Example copyright", feed.copyright)
|
213
|
+
assert_equal(false, feed.bozo?)
|
214
|
+
feed = FeedTools::Feed.open(
|
215
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_rights.xml')
|
216
|
+
assert_equal("Example copyright", feed.copyright)
|
217
|
+
assert_equal(false, feed.bozo?)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_feed_cloud
|
221
|
+
feed = FeedTools::Feed.open(
|
222
|
+
'http://feedparser.org/tests/wellformed/rss/channel_cloud_domain.xml')
|
223
|
+
assert_equal("rpc.sys.com", feed.cloud.domain)
|
224
|
+
assert_equal(80, feed.cloud.port)
|
225
|
+
assert_equal("/RPC2", feed.cloud.path)
|
226
|
+
assert_equal("myCloud.rssPleaseNotify", feed.cloud.register_procedure)
|
227
|
+
assert_equal("xml-rpc", feed.cloud.protocol)
|
228
|
+
assert_equal(false, feed.bozo?)
|
229
|
+
end
|
136
230
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: feedtools
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2005-08-
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2005-08-10
|
8
8
|
summary: "Parsing, generation, and caching system for xml news feeds."
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -68,6 +68,10 @@ files:
|
|
68
68
|
- lib/feed_tools/vendor/htree/template.rb
|
69
69
|
- lib/feed_tools/vendor/htree/text.rb
|
70
70
|
- lib/feed_tools/vendor/htree/traverse.rb
|
71
|
+
- test/amp_test.rb
|
72
|
+
- test/atom_test.rb
|
73
|
+
- test/cache_test.rb
|
74
|
+
- test/helper_test.rb
|
71
75
|
- test/rss_test.rb
|
72
76
|
test_files: []
|
73
77
|
rdoc_options:
|