rss 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +38 -0
  3. data/README.md +11 -11
  4. data/lib/rss/itunes.rb +10 -1
  5. data/lib/rss/maker/itunes.rb +2 -0
  6. data/lib/rss/rss.rb +43 -15
  7. data/lib/rss/utils.rb +0 -18
  8. data/lib/rss/version.rb +1 -1
  9. data/lib/rss/xml-stylesheet.rb +3 -4
  10. data/lib/rss/xml.rb +3 -2
  11. data/lib/rss.rb +11 -11
  12. metadata +7 -101
  13. data/Gemfile +0 -6
  14. data/Rakefile +0 -15
  15. data/rss.gemspec +0 -30
  16. data/test/dot.png +0 -0
  17. data/test/rss-assertions.rb +0 -2116
  18. data/test/rss-testcase.rb +0 -479
  19. data/test/run-test.rb +0 -15
  20. data/test/test_1.0.rb +0 -308
  21. data/test/test_2.0.rb +0 -412
  22. data/test/test_accessor.rb +0 -104
  23. data/test/test_atom.rb +0 -684
  24. data/test/test_content.rb +0 -105
  25. data/test/test_dublincore.rb +0 -270
  26. data/test/test_image.rb +0 -215
  27. data/test/test_inherit.rb +0 -41
  28. data/test/test_itunes.rb +0 -360
  29. data/test/test_maker_0.9.rb +0 -477
  30. data/test/test_maker_1.0.rb +0 -519
  31. data/test/test_maker_2.0.rb +0 -758
  32. data/test/test_maker_atom_entry.rb +0 -394
  33. data/test/test_maker_atom_feed.rb +0 -455
  34. data/test/test_maker_content.rb +0 -48
  35. data/test/test_maker_dc.rb +0 -150
  36. data/test/test_maker_image.rb +0 -63
  37. data/test/test_maker_itunes.rb +0 -488
  38. data/test/test_maker_slash.rb +0 -38
  39. data/test/test_maker_sy.rb +0 -45
  40. data/test/test_maker_taxo.rb +0 -82
  41. data/test/test_maker_trackback.rb +0 -42
  42. data/test/test_maker_xml-stylesheet.rb +0 -84
  43. data/test/test_parser.rb +0 -122
  44. data/test/test_parser_1.0.rb +0 -529
  45. data/test/test_parser_2.0.rb +0 -123
  46. data/test/test_parser_atom_entry.rb +0 -164
  47. data/test/test_parser_atom_feed.rb +0 -277
  48. data/test/test_setup_maker_0.9.rb +0 -247
  49. data/test/test_setup_maker_1.0.rb +0 -551
  50. data/test/test_setup_maker_2.0.rb +0 -309
  51. data/test/test_setup_maker_atom_entry.rb +0 -410
  52. data/test/test_setup_maker_atom_feed.rb +0 -446
  53. data/test/test_setup_maker_itunes.rb +0 -146
  54. data/test/test_setup_maker_slash.rb +0 -39
  55. data/test/test_slash.rb +0 -65
  56. data/test/test_syndication.rb +0 -126
  57. data/test/test_taxonomy.rb +0 -173
  58. data/test/test_to_s.rb +0 -701
  59. data/test/test_trackback.rb +0 -136
  60. data/test/test_xml-stylesheet.rb +0 -109
data/test/test_itunes.rb DELETED
@@ -1,360 +0,0 @@
1
- # frozen_string_literal: false
2
- require "cgi"
3
- require "rexml/document"
4
-
5
- require_relative "rss-testcase"
6
-
7
- require "rss/2.0"
8
- require "rss/itunes"
9
-
10
- module RSS
11
- class TestITunes < TestCase
12
- def test_author
13
- assert_itunes_author(%w(channel)) do |content, xmlns|
14
- make_rss20(make_channel20(content), xmlns)
15
- end
16
-
17
- assert_itunes_author(%w(items last)) do |content, xmlns|
18
- make_rss20(make_channel20(make_item20(content)), xmlns)
19
- end
20
- end
21
-
22
- def test_block
23
- assert_itunes_block(%w(items last)) do |content, xmlns|
24
- make_rss20(make_channel20(make_item20(content)), xmlns)
25
- end
26
- end
27
-
28
- def test_category
29
- assert_itunes_category(%w(channel)) do |content, xmlns|
30
- make_rss20(make_channel20(content), xmlns)
31
- end
32
- end
33
-
34
- def test_image
35
- assert_itunes_image(%w(channel)) do |content, xmlns|
36
- make_rss20(make_channel20(content), xmlns)
37
- end
38
-
39
- assert_itunes_image(%w(items last)) do |content, xmlns|
40
- make_rss20(make_channel20(make_item20(content)), xmlns)
41
- end
42
- end
43
-
44
- def test_duration
45
- assert_itunes_duration(%w(items last)) do |content, xmlns|
46
- make_rss20(make_channel20(make_item20(content)), xmlns)
47
- end
48
- end
49
-
50
- def test_explicit
51
- assert_itunes_explicit(%w(channel)) do |content, xmlns|
52
- make_rss20(make_channel20(content), xmlns)
53
- end
54
-
55
- assert_itunes_explicit(%w(items last)) do |content, xmlns|
56
- make_rss20(make_channel20(make_item20(content)), xmlns)
57
- end
58
- end
59
-
60
- def test_keywords
61
- assert_itunes_keywords(%w(channel)) do |content, xmlns|
62
- make_rss20(make_channel20(content), xmlns)
63
- end
64
-
65
- assert_itunes_keywords(%w(items last)) do |content, xmlns|
66
- make_rss20(make_channel20(make_item20(content)), xmlns)
67
- end
68
- end
69
-
70
- def test_new_feed_url
71
- assert_itunes_new_feed_url(%w(channel)) do |content, xmlns|
72
- make_rss20(make_channel20(content), xmlns)
73
- end
74
- end
75
-
76
- def test_owner
77
- assert_itunes_owner(%w(channel)) do |content, xmlns|
78
- make_rss20(make_channel20(content), xmlns)
79
- end
80
- end
81
-
82
- def test_subtitle
83
- assert_itunes_subtitle(%w(channel)) do |content, xmlns|
84
- make_rss20(make_channel20(content), xmlns)
85
- end
86
-
87
- assert_itunes_subtitle(%w(items last)) do |content, xmlns|
88
- make_rss20(make_channel20(make_item20(content)), xmlns)
89
- end
90
- end
91
-
92
- def test_summary
93
- assert_itunes_summary(%w(channel)) do |content, xmlns|
94
- make_rss20(make_channel20(content), xmlns)
95
- end
96
-
97
- assert_itunes_summary(%w(items last)) do |content, xmlns|
98
- make_rss20(make_channel20(make_item20(content)), xmlns)
99
- end
100
- end
101
-
102
- private
103
- def itunes_rss20_parse(content, &maker)
104
- xmlns = {"itunes" => "http://www.itunes.com/dtds/podcast-1.0.dtd"}
105
- rss20_xml = maker.call(content, xmlns)
106
- ::RSS::Parser.parse(rss20_xml)
107
- end
108
-
109
- def assert_itunes_author(readers, &rss20_maker)
110
- _wrap_assertion do
111
- author = "John Lennon"
112
- rss20 = itunes_rss20_parse(tag("itunes:author", author), &rss20_maker)
113
- target = chain_reader(rss20, readers)
114
- assert_equal(author, target.itunes_author)
115
- end
116
- end
117
-
118
- def _assert_itunes_block(value, boolean_value, readers, &rss20_maker)
119
- rss20 = itunes_rss20_parse(tag("itunes:block", value), &rss20_maker)
120
- target = chain_reader(rss20, readers)
121
- assert_equal(value, target.itunes_block)
122
- assert_equal(boolean_value, target.itunes_block?)
123
- end
124
-
125
- def assert_itunes_block(readers, &rss20_maker)
126
- _wrap_assertion do
127
- _assert_itunes_block("yes", true, readers, &rss20_maker)
128
- _assert_itunes_block("Yes", true, readers, &rss20_maker)
129
- _assert_itunes_block("no", false, readers, &rss20_maker)
130
- _assert_itunes_block("", false, readers, &rss20_maker)
131
- end
132
- end
133
-
134
- def _assert_itunes_category(categories, readers, &rss20_maker)
135
- cats = categories.collect do |category|
136
- if category.is_a?(Array)
137
- category, sub_category = category
138
- tag("itunes:category",
139
- tag("itunes:category", nil, {"text" => sub_category}),
140
- {"text" => category})
141
- else
142
- tag("itunes:category", nil, {"text" => category})
143
- end
144
- end.join
145
- rss20 = itunes_rss20_parse(cats, &rss20_maker)
146
- target = chain_reader(rss20, readers)
147
- actual_categories = target.itunes_categories.collect do |category|
148
- cat = category.text
149
- if category.itunes_categories.empty?
150
- cat
151
- else
152
- [cat, *category.itunes_categories.collect {|c| c.text}]
153
- end
154
- end
155
- assert_equal(categories, actual_categories)
156
- end
157
-
158
- def assert_itunes_category(readers, &rss20_maker)
159
- _wrap_assertion do
160
- _assert_itunes_category(["Audio Blogs"], readers, &rss20_maker)
161
- _assert_itunes_category([["Arts & Entertainment", "Games"]],
162
- readers, &rss20_maker)
163
- _assert_itunes_category([["Arts & Entertainment", "Games"],
164
- ["Technology", "Computers"],
165
- "Audio Blogs"],
166
- readers, &rss20_maker)
167
- end
168
- end
169
-
170
- def assert_itunes_image(readers, &rss20_maker)
171
- _wrap_assertion do
172
- url = "http://example.com/podcasts/everything/AllAboutEverything.jpg"
173
- content = tag("itunes:image", nil, {"href" => url})
174
- rss20 = itunes_rss20_parse(content, &rss20_maker)
175
- target = chain_reader(rss20, readers)
176
- assert_not_nil(target.itunes_image)
177
- assert_equal(url, target.itunes_image.href)
178
-
179
- assert_missing_attribute("image", "href") do
180
- content = tag("itunes:image")
181
- itunes_rss20_parse(content, &rss20_maker)
182
- end
183
- end
184
- end
185
-
186
- def _assert_itunes_duration(hour, minute, second, value,
187
- readers, &rss20_maker)
188
- content = tag("itunes:duration", value)
189
- rss20 = itunes_rss20_parse(content, &rss20_maker)
190
- duration = chain_reader(rss20, readers).itunes_duration
191
- assert_equal(value, duration.content)
192
- assert_equal(hour, duration.hour)
193
- assert_equal(minute, duration.minute)
194
- assert_equal(second, duration.second)
195
- end
196
-
197
- def _assert_itunes_duration_not_available_value(value, &rss20_maker)
198
- assert_not_available_value("duration", value) do
199
- content = tag("itunes:duration", value)
200
- itunes_rss20_parse(content, &rss20_maker)
201
- end
202
- end
203
-
204
- def assert_itunes_duration(readers, &rss20_maker)
205
- _wrap_assertion do
206
- _assert_itunes_duration(7, 14, 5, "07:14:05", readers, &rss20_maker)
207
- _assert_itunes_duration(7, 14, 5, "7:14:05", readers, &rss20_maker)
208
- _assert_itunes_duration(0, 4, 55, "04:55", readers, &rss20_maker)
209
- _assert_itunes_duration(0, 4, 5, "4:05", readers, &rss20_maker)
210
- _assert_itunes_duration(0, 0, 5, "5", readers, &rss20_maker)
211
- _assert_itunes_duration(0, 3, 15, "195", readers, &rss20_maker)
212
- _assert_itunes_duration(1, 0, 1, "3601", readers, &rss20_maker)
213
-
214
- _assert_itunes_duration_not_available_value("09:07:14:05", &rss20_maker)
215
- _assert_itunes_duration_not_available_value("10:5", &rss20_maker)
216
- _assert_itunes_duration_not_available_value("10:03:5", &rss20_maker)
217
- _assert_itunes_duration_not_available_value("10:3:05", &rss20_maker)
218
-
219
- _assert_itunes_duration_not_available_value("xx:xx:xx", &rss20_maker)
220
-
221
- _assert_itunes_duration_not_available_value("", &rss20_maker)
222
- end
223
- end
224
-
225
- def _assert_itunes_explicit(explicit, value, readers, &rss20_maker)
226
- content = tag("itunes:explicit", value)
227
- rss20 = itunes_rss20_parse(content, &rss20_maker)
228
- target = chain_reader(rss20, readers)
229
- assert_equal(value, target.itunes_explicit)
230
- assert_equal(explicit, target.itunes_explicit?)
231
- end
232
-
233
- def assert_itunes_explicit(readers, &rss20_maker)
234
- _wrap_assertion do
235
- _assert_itunes_explicit(true, "explicit", readers, &rss20_maker)
236
- _assert_itunes_explicit(true, "yes", readers, &rss20_maker)
237
- _assert_itunes_explicit(true, "true", readers, &rss20_maker)
238
- _assert_itunes_explicit(false, "clean", readers, &rss20_maker)
239
- _assert_itunes_explicit(false, "no", readers, &rss20_maker)
240
- _assert_itunes_explicit(false, "false", readers, &rss20_maker)
241
- _assert_itunes_explicit(nil, "invalid", readers, &rss20_maker)
242
- end
243
- end
244
-
245
- def _assert_itunes_keywords(keywords, value, readers, &rss20_maker)
246
- content = tag("itunes:keywords", value)
247
- rss20 = itunes_rss20_parse(content, &rss20_maker)
248
- target = chain_reader(rss20, readers)
249
- assert_equal(keywords, target.itunes_keywords)
250
- end
251
-
252
- def assert_itunes_keywords(readers, &rss20_maker)
253
- _wrap_assertion do
254
- _assert_itunes_keywords(["salt"], "salt", readers, &rss20_maker)
255
- _assert_itunes_keywords(["salt"], " salt ", readers, &rss20_maker)
256
- _assert_itunes_keywords(["salt", "pepper", "shaker", "exciting"],
257
- "salt, pepper, shaker, exciting",
258
- readers, &rss20_maker)
259
- _assert_itunes_keywords(["metric", "socket", "wrenches", "toolsalt"],
260
- "metric, socket, wrenches, toolsalt",
261
- readers, &rss20_maker)
262
- _assert_itunes_keywords(["olitics", "red", "blue", "state"],
263
- "olitics, red, blue, state",
264
- readers, &rss20_maker)
265
- end
266
- end
267
-
268
- def assert_itunes_new_feed_url(readers, &rss20_maker)
269
- _wrap_assertion do
270
- url = "http://newlocation.com/example.rss"
271
- content = tag("itunes:new-feed-url", url)
272
- rss20 = itunes_rss20_parse(content, &rss20_maker)
273
- target = chain_reader(rss20, readers)
274
- assert_equal(url, target.itunes_new_feed_url)
275
- end
276
- end
277
-
278
- def _assert_itunes_owner(name, email, readers, &rss20_maker)
279
- content = tag("itunes:owner",
280
- tag("itunes:name", name) + tag("itunes:email", email))
281
- rss20 = itunes_rss20_parse(content, &rss20_maker)
282
- owner = chain_reader(rss20, readers).itunes_owner
283
- assert_equal(name, owner.itunes_name)
284
- assert_equal(email, owner.itunes_email)
285
- end
286
-
287
- def assert_itunes_owner(readers, &rss20_maker)
288
- _wrap_assertion do
289
- _assert_itunes_owner("John Doe", "john.doe@example.com",
290
- readers, &rss20_maker)
291
-
292
- assert_missing_tag("name", "owner") do
293
- content = tag("itunes:owner")
294
- itunes_rss20_parse(content, &rss20_maker)
295
- end
296
-
297
- assert_missing_tag("name", "owner") do
298
- content = tag("itunes:owner",
299
- tag("itunes:email", "john.doe@example.com"))
300
- itunes_rss20_parse(content, &rss20_maker)
301
- end
302
-
303
- assert_missing_tag("email", "owner") do
304
- content = tag("itunes:owner", tag("itunes:name", "John Doe"))
305
- itunes_rss20_parse(content, &rss20_maker)
306
- end
307
- end
308
- end
309
-
310
- def _assert_itunes_subtitle(value, readers, &rss20_maker)
311
- content = tag("itunes:subtitle", value)
312
- rss20 = itunes_rss20_parse(content, &rss20_maker)
313
- target = chain_reader(rss20, readers)
314
- assert_equal(value, target.itunes_subtitle)
315
- end
316
-
317
- def assert_itunes_subtitle(readers, &rss20_maker)
318
- _wrap_assertion do
319
- _assert_itunes_subtitle("A show about everything", readers, &rss20_maker)
320
- _assert_itunes_subtitle("A short primer on table spices",
321
- readers, &rss20_maker)
322
- _assert_itunes_subtitle("Comparing socket wrenches is fun!",
323
- readers, &rss20_maker)
324
- _assert_itunes_subtitle("Red + Blue != Purple", readers, &rss20_maker)
325
- end
326
- end
327
-
328
- def _assert_itunes_summary(value, readers, &rss20_maker)
329
- content = tag("itunes:summary", value)
330
- rss20 = itunes_rss20_parse(content, &rss20_maker)
331
- target = chain_reader(rss20, readers)
332
- assert_equal(value, target.itunes_summary)
333
- end
334
-
335
- def assert_itunes_summary(readers, &rss20_maker)
336
- _wrap_assertion do
337
- _assert_itunes_summary("All About Everything is a show about " +
338
- "everything. Each week we dive into any " +
339
- "subject known to man and talk about it as " +
340
- "much as we can. Look for our Podcast in " +
341
- "the iTunes Music Store",
342
- readers, &rss20_maker)
343
- _assert_itunes_summary("This week we talk about salt and pepper " +
344
- "shakers, comparing and contrasting pour " +
345
- "rates, construction materials, and overall " +
346
- "aesthetics. Come and join the party!",
347
- readers, &rss20_maker)
348
- _assert_itunes_summary("This week we talk about metric vs. old " +
349
- "english socket wrenches. Which one is " +
350
- "better? Do you really need both? Get all " +
351
- "of your answers here.",
352
- readers, &rss20_maker)
353
- _assert_itunes_summary("This week we talk about surviving in a " +
354
- "Red state if you're a Blue person. Or " +
355
- "vice versa.",
356
- readers, &rss20_maker)
357
- end
358
- end
359
- end
360
- end