rss 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +38 -0
- data/README.md +11 -11
- data/lib/rss/itunes.rb +10 -1
- data/lib/rss/maker/itunes.rb +2 -0
- data/lib/rss/rss.rb +43 -15
- data/lib/rss/utils.rb +0 -18
- data/lib/rss/version.rb +1 -1
- data/lib/rss/xml-stylesheet.rb +3 -4
- data/lib/rss/xml.rb +3 -2
- data/lib/rss.rb +11 -11
- metadata +7 -101
- data/Gemfile +0 -6
- data/Rakefile +0 -15
- data/rss.gemspec +0 -30
- data/test/dot.png +0 -0
- data/test/rss-assertions.rb +0 -2116
- data/test/rss-testcase.rb +0 -479
- data/test/run-test.rb +0 -15
- data/test/test_1.0.rb +0 -308
- data/test/test_2.0.rb +0 -412
- data/test/test_accessor.rb +0 -104
- data/test/test_atom.rb +0 -684
- data/test/test_content.rb +0 -105
- data/test/test_dublincore.rb +0 -270
- data/test/test_image.rb +0 -215
- data/test/test_inherit.rb +0 -41
- data/test/test_itunes.rb +0 -360
- data/test/test_maker_0.9.rb +0 -477
- data/test/test_maker_1.0.rb +0 -519
- data/test/test_maker_2.0.rb +0 -758
- data/test/test_maker_atom_entry.rb +0 -394
- data/test/test_maker_atom_feed.rb +0 -455
- data/test/test_maker_content.rb +0 -48
- data/test/test_maker_dc.rb +0 -150
- data/test/test_maker_image.rb +0 -63
- data/test/test_maker_itunes.rb +0 -488
- data/test/test_maker_slash.rb +0 -38
- data/test/test_maker_sy.rb +0 -45
- data/test/test_maker_taxo.rb +0 -82
- data/test/test_maker_trackback.rb +0 -42
- data/test/test_maker_xml-stylesheet.rb +0 -84
- data/test/test_parser.rb +0 -122
- data/test/test_parser_1.0.rb +0 -529
- data/test/test_parser_2.0.rb +0 -123
- data/test/test_parser_atom_entry.rb +0 -164
- data/test/test_parser_atom_feed.rb +0 -277
- data/test/test_setup_maker_0.9.rb +0 -247
- data/test/test_setup_maker_1.0.rb +0 -551
- data/test/test_setup_maker_2.0.rb +0 -309
- data/test/test_setup_maker_atom_entry.rb +0 -410
- data/test/test_setup_maker_atom_feed.rb +0 -446
- data/test/test_setup_maker_itunes.rb +0 -146
- data/test/test_setup_maker_slash.rb +0 -39
- data/test/test_slash.rb +0 -65
- data/test/test_syndication.rb +0 -126
- data/test/test_taxonomy.rb +0 -173
- data/test/test_to_s.rb +0 -701
- data/test/test_trackback.rb +0 -136
- data/test/test_xml-stylesheet.rb +0 -109
@@ -1,455 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerAtomFeed < TestCase
|
8
|
-
def test_supported?
|
9
|
-
assert(RSS::Maker.supported?("atom"))
|
10
|
-
assert(RSS::Maker.supported?("atom:feed"))
|
11
|
-
assert(RSS::Maker.supported?("atom1.0"))
|
12
|
-
assert(RSS::Maker.supported?("atom1.0:feed"))
|
13
|
-
assert(!RSS::Maker.supported?("atom2.0"))
|
14
|
-
assert(!RSS::Maker.supported?("atom2.0:feed"))
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_find_class
|
18
|
-
assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom"])
|
19
|
-
assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom:feed"])
|
20
|
-
assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom1.0"])
|
21
|
-
assert_equal(RSS::Maker::Atom::Feed, RSS::Maker["atom1.0:feed"])
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_root_element
|
25
|
-
feed = Maker.make("atom") do |maker|
|
26
|
-
setup_dummy_channel_atom(maker)
|
27
|
-
end
|
28
|
-
assert_equal(["atom", "1.0", "feed"], feed.feed_info)
|
29
|
-
|
30
|
-
feed = Maker.make("atom") do |maker|
|
31
|
-
setup_dummy_channel_atom(maker)
|
32
|
-
maker.encoding = "EUC-JP"
|
33
|
-
end
|
34
|
-
assert_equal(["atom", "1.0", "feed"], feed.feed_info)
|
35
|
-
assert_equal("EUC-JP", feed.encoding)
|
36
|
-
|
37
|
-
feed = Maker.make("atom") do |maker|
|
38
|
-
setup_dummy_channel_atom(maker)
|
39
|
-
maker.standalone = "yes"
|
40
|
-
end
|
41
|
-
assert_equal(["atom", "1.0", "feed"], feed.feed_info)
|
42
|
-
assert_equal("yes", feed.standalone)
|
43
|
-
|
44
|
-
feed = Maker.make("atom") do |maker|
|
45
|
-
setup_dummy_channel_atom(maker)
|
46
|
-
maker.encoding = "EUC-JP"
|
47
|
-
maker.standalone = "yes"
|
48
|
-
end
|
49
|
-
assert_equal(["atom", "1.0", "feed"], feed.feed_info)
|
50
|
-
assert_equal("EUC-JP", feed.encoding)
|
51
|
-
assert_equal("yes", feed.standalone)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_invalid_feed
|
55
|
-
assert_not_set_error("maker.channel", %w(id title author updated)) do
|
56
|
-
Maker.make("atom") do |maker|
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
assert_not_set_error("maker.channel", %w(id title updated)) do
|
61
|
-
Maker.make("atom") do |maker|
|
62
|
-
maker.channel.author = "foo"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
assert_not_set_error("maker.channel", %w(title updated)) do
|
67
|
-
Maker.make("atom") do |maker|
|
68
|
-
maker.channel.author = "foo"
|
69
|
-
maker.channel.id = "http://example.com"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
assert_not_set_error("maker.channel", %w(updated)) do
|
74
|
-
Maker.make("atom") do |maker|
|
75
|
-
maker.channel.author = "foo"
|
76
|
-
maker.channel.id = "http://example.com"
|
77
|
-
maker.channel.title = "Atom Feed"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
assert_not_set_error("maker.channel", %w(author)) do
|
82
|
-
Maker.make("atom") do |maker|
|
83
|
-
maker.channel.id = "http://example.com"
|
84
|
-
maker.channel.title = "Atom Feed"
|
85
|
-
maker.channel.updated = Time.now
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
feed = Maker.make("atom") do |maker|
|
90
|
-
maker.channel.author = "Foo"
|
91
|
-
maker.channel.id = "http://example.com"
|
92
|
-
maker.channel.title = "Atom Feed"
|
93
|
-
maker.channel.updated = Time.now
|
94
|
-
end
|
95
|
-
assert_not_nil(feed)
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_author
|
99
|
-
assert_maker_atom_persons("feed",
|
100
|
-
["channel", "authors"],
|
101
|
-
["authors"],
|
102
|
-
"maker.channel.author") do |maker|
|
103
|
-
setup_dummy_channel_atom(maker)
|
104
|
-
end
|
105
|
-
|
106
|
-
assert_not_set_error("maker.channel", %w(author)) do
|
107
|
-
RSS::Maker.make("atom") do |maker|
|
108
|
-
setup_dummy_channel_atom(maker)
|
109
|
-
setup_dummy_item_atom(maker)
|
110
|
-
maker.channel.authors.clear
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
assert_maker_atom_persons("feed",
|
115
|
-
["items", "first", "authors"],
|
116
|
-
["entries", "first", "authors"],
|
117
|
-
"maker.item.author") do |maker|
|
118
|
-
setup_dummy_channel_atom(maker)
|
119
|
-
setup_dummy_item_atom(maker)
|
120
|
-
end
|
121
|
-
|
122
|
-
assert_maker_atom_persons("feed",
|
123
|
-
["items", "first", "source", "authors"],
|
124
|
-
["entries", "first", "source", "authors"],
|
125
|
-
"maker.item.source.author") do |maker|
|
126
|
-
setup_dummy_channel_atom(maker)
|
127
|
-
setup_dummy_item_atom(maker)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_category
|
132
|
-
assert_maker_atom_categories("feed",
|
133
|
-
["channel", "categories"],
|
134
|
-
["categories"],
|
135
|
-
"maker.channel.category") do |maker|
|
136
|
-
setup_dummy_channel_atom(maker)
|
137
|
-
end
|
138
|
-
|
139
|
-
assert_maker_atom_categories("feed",
|
140
|
-
["items", "first", "categories"],
|
141
|
-
["entries", "first", "categories"],
|
142
|
-
"maker.item.category") do |maker|
|
143
|
-
setup_dummy_channel_atom(maker)
|
144
|
-
setup_dummy_item_atom(maker)
|
145
|
-
end
|
146
|
-
|
147
|
-
assert_maker_atom_categories("feed",
|
148
|
-
["items", "first", "source", "categories"],
|
149
|
-
["entries", "first", "source", "categories"],
|
150
|
-
"maker.item.source.category") do |maker|
|
151
|
-
setup_dummy_channel_atom(maker)
|
152
|
-
setup_dummy_item_atom(maker)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_contributor
|
157
|
-
assert_maker_atom_persons("feed",
|
158
|
-
["channel", "contributors"],
|
159
|
-
["contributors"],
|
160
|
-
"maker.channel.contributor") do |maker|
|
161
|
-
setup_dummy_channel_atom(maker)
|
162
|
-
end
|
163
|
-
|
164
|
-
assert_maker_atom_persons("feed",
|
165
|
-
["items", "first", "contributors"],
|
166
|
-
["entries", "first", "contributors"],
|
167
|
-
"maker.item.contributor") do |maker|
|
168
|
-
setup_dummy_channel_atom(maker)
|
169
|
-
setup_dummy_item_atom(maker)
|
170
|
-
end
|
171
|
-
|
172
|
-
assert_maker_atom_persons("feed",
|
173
|
-
["items", "first", "source", "contributors"],
|
174
|
-
["entries", "first", "source", "contributors"],
|
175
|
-
"maker.item.source.contributor") do |maker|
|
176
|
-
setup_dummy_channel_atom(maker)
|
177
|
-
setup_dummy_item_atom(maker)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_generator
|
182
|
-
assert_maker_atom_generator("feed",
|
183
|
-
["channel", "generator"],
|
184
|
-
["generator"]) do |maker|
|
185
|
-
setup_dummy_channel_atom(maker)
|
186
|
-
setup_dummy_item_atom(maker)
|
187
|
-
end
|
188
|
-
|
189
|
-
assert_maker_atom_generator("feed",
|
190
|
-
["items", "first", "source", "generator"],
|
191
|
-
["entries", "first", "source", "generator"],
|
192
|
-
"maker.item.source.generator") do |maker|
|
193
|
-
setup_dummy_channel_atom(maker)
|
194
|
-
setup_dummy_item_atom(maker)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_icon
|
199
|
-
assert_maker_atom_icon("feed", ["channel"], ["icon"], "icon") do |maker|
|
200
|
-
setup_dummy_channel_atom(maker)
|
201
|
-
end
|
202
|
-
|
203
|
-
assert_maker_atom_icon("feed",
|
204
|
-
["items", "first", "source", "icon"],
|
205
|
-
["entries", "first", "source", "icon"],
|
206
|
-
nil, "maker.item.source.icon") do |maker|
|
207
|
-
setup_dummy_channel_atom(maker)
|
208
|
-
setup_dummy_item_atom(maker)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_link
|
213
|
-
assert_maker_atom_links("feed",
|
214
|
-
["channel", "links"],
|
215
|
-
["links"],
|
216
|
-
"maker.channel.link") do |maker|
|
217
|
-
setup_dummy_channel_atom(maker)
|
218
|
-
end
|
219
|
-
|
220
|
-
assert_maker_atom_links("feed",
|
221
|
-
["items", "first", "links"],
|
222
|
-
["entries", "first", "links"],
|
223
|
-
"maker.item.link") do |maker|
|
224
|
-
setup_dummy_channel_atom(maker)
|
225
|
-
setup_dummy_item_atom(maker)
|
226
|
-
end
|
227
|
-
|
228
|
-
assert_maker_atom_links("feed",
|
229
|
-
["items", "first", "source", "links"],
|
230
|
-
["entries", "first", "source", "links"],
|
231
|
-
"maker.item.source.link", true) do |maker|
|
232
|
-
setup_dummy_channel_atom(maker)
|
233
|
-
setup_dummy_item_atom(maker)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_logo
|
238
|
-
assert_maker_atom_logo("feed", ["channel"], ["logo"], "logo") do |maker|
|
239
|
-
setup_dummy_channel_atom(maker)
|
240
|
-
end
|
241
|
-
|
242
|
-
assert_maker_atom_logo("feed", ["image"], ["logo"], "url") do |maker|
|
243
|
-
setup_dummy_channel_atom(maker)
|
244
|
-
end
|
245
|
-
|
246
|
-
assert_maker_atom_logo("feed",
|
247
|
-
["items", "first", "source", "logo"],
|
248
|
-
["entries", "first", "source", "logo"],
|
249
|
-
nil, "maker.item.source.logo") do |maker|
|
250
|
-
setup_dummy_channel_atom(maker)
|
251
|
-
setup_dummy_item_atom(maker)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
def test_rights
|
256
|
-
assert_maker_atom_text_construct("feed",
|
257
|
-
["channel", "copyright"],
|
258
|
-
["rights"]) do |maker|
|
259
|
-
setup_dummy_channel_atom(maker)
|
260
|
-
end
|
261
|
-
|
262
|
-
assert_maker_atom_text_construct("feed",
|
263
|
-
["items", "first", "rights"],
|
264
|
-
["entries", "first", "rights"],
|
265
|
-
nil, nil, "maker.item.rights"
|
266
|
-
) do |maker|
|
267
|
-
setup_dummy_channel_atom(maker)
|
268
|
-
setup_dummy_item_atom(maker)
|
269
|
-
end
|
270
|
-
|
271
|
-
assert_maker_atom_text_construct("feed",
|
272
|
-
["items", "first", "source", "rights"],
|
273
|
-
["entries", "first", "source", "rights"],
|
274
|
-
nil, nil, "maker.item.source.rights"
|
275
|
-
) do |maker|
|
276
|
-
setup_dummy_channel_atom(maker)
|
277
|
-
setup_dummy_item_atom(maker)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_subtitle
|
282
|
-
assert_maker_atom_text_construct("feed",
|
283
|
-
["channel", "subtitle"],
|
284
|
-
["subtitle"],
|
285
|
-
nil, nil,
|
286
|
-
"maker.channel.description") do |maker|
|
287
|
-
setup_dummy_channel_atom(maker)
|
288
|
-
maker.channel.description = nil
|
289
|
-
end
|
290
|
-
|
291
|
-
assert_maker_atom_text_construct("feed",
|
292
|
-
["channel", "subtitle"],
|
293
|
-
["subtitle"],
|
294
|
-
nil, nil,
|
295
|
-
"maker.channel.description") do |maker|
|
296
|
-
setup_dummy_channel_atom(maker)
|
297
|
-
maker.channel.description {|d| d.content = nil}
|
298
|
-
end
|
299
|
-
|
300
|
-
assert_maker_atom_text_construct("feed",
|
301
|
-
["items", "first", "source", "subtitle"],
|
302
|
-
["entries", "first",
|
303
|
-
"source", "subtitle"],
|
304
|
-
nil, nil,
|
305
|
-
"maker.item.source.subtitle") do |maker|
|
306
|
-
setup_dummy_channel_atom(maker)
|
307
|
-
setup_dummy_item_atom(maker)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
def test_title
|
312
|
-
assert_maker_atom_text_construct("feed",
|
313
|
-
["channel", "title"], ["title"],
|
314
|
-
"maker.channel", ["title"]) do |maker|
|
315
|
-
setup_dummy_channel_atom(maker)
|
316
|
-
maker.channel.title = nil
|
317
|
-
end
|
318
|
-
|
319
|
-
assert_maker_atom_text_construct("feed",
|
320
|
-
["items", "first", "title"],
|
321
|
-
["entries", "first", "title"],
|
322
|
-
"maker.item", ["title"],
|
323
|
-
"maker.item.title") do |maker|
|
324
|
-
setup_dummy_channel_atom(maker)
|
325
|
-
setup_dummy_item_atom(maker)
|
326
|
-
maker.items.first.title = nil
|
327
|
-
end
|
328
|
-
|
329
|
-
assert_maker_atom_text_construct("feed",
|
330
|
-
["items", "first", "source", "title"],
|
331
|
-
["entries", "first", "source", "title"],
|
332
|
-
nil, nil, "maker.item.source.title"
|
333
|
-
) do |maker|
|
334
|
-
setup_dummy_channel_atom(maker)
|
335
|
-
setup_dummy_item_atom(maker)
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
def test_updated
|
340
|
-
assert_maker_atom_date_construct("feed",
|
341
|
-
["channel", "updated"], ["updated"],
|
342
|
-
"maker.channel", ["updated"]) do |maker|
|
343
|
-
setup_dummy_channel_atom(maker)
|
344
|
-
maker.channel.updated = nil
|
345
|
-
end
|
346
|
-
|
347
|
-
assert_maker_atom_date_construct("feed",
|
348
|
-
["items", "first", "updated"],
|
349
|
-
["entries", "first", "updated"],
|
350
|
-
"maker.item", ["updated"]) do |maker|
|
351
|
-
setup_dummy_channel_atom(maker)
|
352
|
-
setup_dummy_item_atom(maker)
|
353
|
-
maker.items.first.updated = nil
|
354
|
-
end
|
355
|
-
|
356
|
-
assert_maker_atom_date_construct("feed",
|
357
|
-
["items", "first", "source", "updated"],
|
358
|
-
["entries", "first", "source", "updated"]
|
359
|
-
) do |maker|
|
360
|
-
setup_dummy_channel_atom(maker)
|
361
|
-
setup_dummy_item_atom(maker)
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
def test_published
|
366
|
-
assert_maker_atom_date_construct("feed",
|
367
|
-
["items", "first", "published"],
|
368
|
-
["entries", "first", "published"]
|
369
|
-
) do |maker|
|
370
|
-
setup_dummy_channel_atom(maker)
|
371
|
-
setup_dummy_item_atom(maker)
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_summary
|
376
|
-
assert_maker_atom_text_construct("feed",
|
377
|
-
["items", "first", "description"],
|
378
|
-
["entries", "first", "summary"],
|
379
|
-
nil, nil, "maker.item.description"
|
380
|
-
) do |maker|
|
381
|
-
setup_dummy_channel_atom(maker)
|
382
|
-
setup_dummy_item_atom(maker)
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_content
|
387
|
-
assert_maker_atom_content("feed",
|
388
|
-
["items", "first", "content"],
|
389
|
-
["entries", "first", "content"],
|
390
|
-
"maker.item.content") do |maker|
|
391
|
-
setup_dummy_channel_atom(maker)
|
392
|
-
setup_dummy_item_atom(maker)
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
def test_id
|
397
|
-
assert_maker_atom_id("feed",
|
398
|
-
["items", "first", "source"],
|
399
|
-
["entries", "first", "source"],
|
400
|
-
"maker.item.source") do |maker|
|
401
|
-
setup_dummy_channel_atom(maker)
|
402
|
-
setup_dummy_item_atom(maker)
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
def test_language
|
407
|
-
language = "ja"
|
408
|
-
feed = Maker.make("atom") do |maker|
|
409
|
-
setup_dummy_channel_atom(maker)
|
410
|
-
maker.channel.language = "ja"
|
411
|
-
end
|
412
|
-
assert_equal(language, feed.dc_language)
|
413
|
-
end
|
414
|
-
|
415
|
-
def test_date
|
416
|
-
date = Time.parse("2004/11/1 10:10")
|
417
|
-
feed = Maker.make("atom") do |maker|
|
418
|
-
setup_dummy_channel_atom(maker)
|
419
|
-
maker.items.new_item do |item|
|
420
|
-
item.link = "http://example.com/article.html"
|
421
|
-
item.title = "sample article"
|
422
|
-
item.date = date
|
423
|
-
end
|
424
|
-
end
|
425
|
-
assert_equal(date, feed.items[0].updated.content)
|
426
|
-
assert_equal([date], feed.items[0].dc_dates.collect {|_date| _date.value})
|
427
|
-
end
|
428
|
-
|
429
|
-
def test_channel_dc_date
|
430
|
-
date = Time.parse("2004/11/1 10:10")
|
431
|
-
feed = Maker.make("atom") do |maker|
|
432
|
-
setup_dummy_channel_atom(maker)
|
433
|
-
maker.channel.updated = nil
|
434
|
-
maker.channel.dc_date = date
|
435
|
-
setup_dummy_item_atom(maker)
|
436
|
-
end
|
437
|
-
assert_equal(date, feed.updated.content)
|
438
|
-
assert_equal([date], feed.dc_dates.collect {|_date| _date.value})
|
439
|
-
end
|
440
|
-
|
441
|
-
def test_item_dc_date
|
442
|
-
date = Time.parse("2004/11/1 10:10")
|
443
|
-
feed = Maker.make("atom") do |maker|
|
444
|
-
setup_dummy_channel_atom(maker)
|
445
|
-
maker.items.new_item do |item|
|
446
|
-
item.link = "http://example.com/article.html"
|
447
|
-
item.title = "sample article"
|
448
|
-
item.dc_date = date
|
449
|
-
end
|
450
|
-
end
|
451
|
-
assert_equal(date, feed.items[0].updated.content)
|
452
|
-
assert_equal([date], feed.items[0].dc_dates.collect {|_date| _date.value})
|
453
|
-
end
|
454
|
-
end
|
455
|
-
end
|
data/test/test_maker_content.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerContent < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://purl.org/rss/1.0/modules/content/"
|
11
|
-
|
12
|
-
@elements = {
|
13
|
-
:encoded => "<em>ATTENTION</em>",
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_rss10
|
18
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
19
|
-
setup_dummy_channel(maker)
|
20
|
-
|
21
|
-
setup_dummy_item(maker)
|
22
|
-
item = maker.items.last
|
23
|
-
@elements.each do |name, value|
|
24
|
-
item.__send__("#{accessor_name(name)}=", value)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
assert_content(@elements, rss.items.last)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_rss20
|
31
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
32
|
-
setup_dummy_channel(maker)
|
33
|
-
|
34
|
-
setup_dummy_item(maker)
|
35
|
-
item = maker.items.last
|
36
|
-
@elements.each do |name, value|
|
37
|
-
item.__send__("#{accessor_name(name)}=", value)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
assert_content(@elements, rss.items.last)
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def accessor_name(name)
|
45
|
-
"content_#{name}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/test/test_maker_dc.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerDublinCore < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://purl.org/dc/elements/1.1/"
|
11
|
-
|
12
|
-
t = Time.iso8601("2000-01-01T12:00:05+00:00")
|
13
|
-
class << t
|
14
|
-
alias_method(:to_s, :iso8601)
|
15
|
-
end
|
16
|
-
|
17
|
-
@elements = {
|
18
|
-
:title => "hoge",
|
19
|
-
:description =>
|
20
|
-
" XML is placing increasingly heavy loads on
|
21
|
-
the existing technical infrastructure of the Internet.",
|
22
|
-
:creator => "Rael Dornfest (mailto:rael@oreilly.com)",
|
23
|
-
:subject => "XML",
|
24
|
-
:publisher => "The O'Reilly Network",
|
25
|
-
:contributor => "hogehoge",
|
26
|
-
:type => "fugafuga",
|
27
|
-
:format => "hohoho",
|
28
|
-
:identifier => "fufufu",
|
29
|
-
:source => "barbar",
|
30
|
-
:language => "ja",
|
31
|
-
:relation => "cococo",
|
32
|
-
:rights => "Copyright (c) 2000 O'Reilly & Associates, Inc.",
|
33
|
-
:date => t,
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_rss10
|
38
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
39
|
-
setup_dummy_channel(maker)
|
40
|
-
set_elements(maker.channel)
|
41
|
-
|
42
|
-
setup_dummy_image(maker)
|
43
|
-
set_elements(maker.image)
|
44
|
-
|
45
|
-
setup_dummy_item(maker)
|
46
|
-
item = maker.items.last
|
47
|
-
@elements.each do |name, value|
|
48
|
-
item.__send__("#{accessor_name(name)}=", value)
|
49
|
-
end
|
50
|
-
|
51
|
-
setup_dummy_textinput(maker)
|
52
|
-
set_elements(maker.textinput)
|
53
|
-
end
|
54
|
-
assert_dublin_core(@elements, rss.channel)
|
55
|
-
assert_dublin_core(@elements, rss.image)
|
56
|
-
assert_dublin_core(@elements, rss.items.last)
|
57
|
-
assert_dublin_core(@elements, rss.textinput)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_rss10_multiple
|
61
|
-
assert_multiple_dublin_core_rss10("_list")
|
62
|
-
assert_multiple_dublin_core_rss10("es")
|
63
|
-
end
|
64
|
-
|
65
|
-
def assert_multiple_dublin_core_rss10(multiple_rights_suffix)
|
66
|
-
elems = []
|
67
|
-
@elements.each do |name, value|
|
68
|
-
plural = name.to_s + (name == :rights ? multiple_rights_suffix : "s")
|
69
|
-
values = [value]
|
70
|
-
if name == :date
|
71
|
-
values << value + 60
|
72
|
-
else
|
73
|
-
values << value * 2
|
74
|
-
end
|
75
|
-
elems << [name, values, plural]
|
76
|
-
end
|
77
|
-
|
78
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
79
|
-
setup_dummy_channel(maker)
|
80
|
-
set_multiple_elements(maker.channel, elems)
|
81
|
-
|
82
|
-
setup_dummy_image(maker)
|
83
|
-
set_multiple_elements(maker.image, elems)
|
84
|
-
|
85
|
-
setup_dummy_item(maker)
|
86
|
-
item = maker.items.last
|
87
|
-
elems.each do |name, values, plural|
|
88
|
-
dc_elems = item.__send__("dc_#{plural}")
|
89
|
-
values.each do |value|
|
90
|
-
elem = dc_elems.__send__("new_#{name}")
|
91
|
-
elem.value = value
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
setup_dummy_textinput(maker)
|
96
|
-
set_multiple_elements(maker.textinput, elems)
|
97
|
-
end
|
98
|
-
assert_multiple_dublin_core(elems, rss.channel)
|
99
|
-
assert_multiple_dublin_core(elems, rss.image)
|
100
|
-
assert_multiple_dublin_core(elems, rss.items.last)
|
101
|
-
assert_multiple_dublin_core(elems, rss.textinput)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_date
|
105
|
-
t1 = Time.iso8601("2000-01-01T12:00:05+00:00")
|
106
|
-
t2 = Time.iso8601("2005-01-01T12:00:05+00:00")
|
107
|
-
|
108
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
109
|
-
setup_dummy_channel(maker)
|
110
|
-
maker.channel.date = t1
|
111
|
-
maker.channel.dc_dates.new_date do |date|
|
112
|
-
date.value = t2
|
113
|
-
end
|
114
|
-
|
115
|
-
setup_dummy_item(maker)
|
116
|
-
item = maker.items.last
|
117
|
-
item.date = t2
|
118
|
-
item.dc_dates.new_date do |date|
|
119
|
-
date.value = t1
|
120
|
-
end
|
121
|
-
end
|
122
|
-
assert_equal([t1, t2], rss.channel.dc_dates.collect{|x| x.value})
|
123
|
-
assert_equal([t2, t1], rss.items.last.dc_dates.collect{|x| x.value})
|
124
|
-
end
|
125
|
-
|
126
|
-
private
|
127
|
-
def accessor_name(name)
|
128
|
-
"dc_#{name}"
|
129
|
-
end
|
130
|
-
|
131
|
-
def set_elements(target, elems=@elements)
|
132
|
-
elems.each do |name, value|
|
133
|
-
target.__send__("#{accessor_name(name)}=", value)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def set_multiple_elements(target, elems)
|
138
|
-
elems.each do |name, values, plural|
|
139
|
-
plural ||= "#{name}s"
|
140
|
-
dc_elems = target.__send__("dc_#{plural}")
|
141
|
-
values.each do |value|
|
142
|
-
dc_elems.__send__("new_#{name}") do |new_dc_elem|
|
143
|
-
new_dc_elem.value = value
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
150
|
-
end
|