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,446 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestSetupMakerAtomFeed < TestCase
|
8
|
-
def setup
|
9
|
-
t = Time.iso8601("2000-01-01T12:00:05+00:00")
|
10
|
-
class << t
|
11
|
-
alias_method(:to_s, :iso8601)
|
12
|
-
end
|
13
|
-
|
14
|
-
@dc_elems = {
|
15
|
-
:title => "hoge",
|
16
|
-
:description =>
|
17
|
-
" XML is placing increasingly heavy loads on
|
18
|
-
the existing technical infrastructure of the Internet.",
|
19
|
-
:creator => "Rael Dornfest (mailto:rael@oreilly.com)",
|
20
|
-
:subject => "XML",
|
21
|
-
:publisher => "The O'Reilly Network",
|
22
|
-
:contributor => "hogehoge",
|
23
|
-
:type => "fugafuga",
|
24
|
-
:format => "hohoho",
|
25
|
-
:identifier => "fufufu",
|
26
|
-
:source => "barbar",
|
27
|
-
:language => "ja",
|
28
|
-
:relation => "cococo",
|
29
|
-
:rights => "Copyright (c) 2000 O'Reilly & Associates, Inc.",
|
30
|
-
:date => t,
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_setup_maker_feed(with_dc=true)
|
35
|
-
authors = [
|
36
|
-
{
|
37
|
-
:name => "Bob",
|
38
|
-
:uri => "http://example.com/~bob/",
|
39
|
-
:email => "bob@example.com",
|
40
|
-
},
|
41
|
-
{
|
42
|
-
:name => "Alice",
|
43
|
-
:uri => "http://example.com/~alice/",
|
44
|
-
:email => "alice@example.com",
|
45
|
-
},
|
46
|
-
]
|
47
|
-
categories = [
|
48
|
-
{
|
49
|
-
:term => "music",
|
50
|
-
:label => "Music",
|
51
|
-
},
|
52
|
-
{
|
53
|
-
:term => "book",
|
54
|
-
:scheme => "http://example.com/category/book/",
|
55
|
-
:label => "Book",
|
56
|
-
},
|
57
|
-
]
|
58
|
-
contributors = [
|
59
|
-
{
|
60
|
-
:name => "Chris",
|
61
|
-
:email => "chris@example.com",
|
62
|
-
},
|
63
|
-
{
|
64
|
-
:name => "Eva",
|
65
|
-
:uri => "http://example.com/~eva/",
|
66
|
-
},
|
67
|
-
]
|
68
|
-
generator = {
|
69
|
-
:uri => "http://example.com/generator/",
|
70
|
-
:version => "0.0.1",
|
71
|
-
:content => "Feed Generator",
|
72
|
-
}
|
73
|
-
icon = "http://example.com/icon.png"
|
74
|
-
about = "http://hoge.com"
|
75
|
-
title = "fugafuga"
|
76
|
-
link = "http://hoge.com"
|
77
|
-
logo = "http://example.com/logo.png"
|
78
|
-
rights = "Copyrights (c) 2007 Alice and Bob"
|
79
|
-
description = "fugafugafugafuga"
|
80
|
-
updated = Time.now
|
81
|
-
|
82
|
-
feed = RSS::Maker.make("atom") do |maker|
|
83
|
-
authors.each do |author_info|
|
84
|
-
maker.channel.authors.new_author do |author|
|
85
|
-
author_info.each do |key, value|
|
86
|
-
author.__send__("#{key}=", value)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
categories.each do |category_info|
|
92
|
-
maker.channel.categories.new_category do |category|
|
93
|
-
category_info.each do |key, value|
|
94
|
-
category.__send__("#{key}=", value)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
contributors.each do |contributor_info|
|
100
|
-
maker.channel.contributors.new_contributor do |contributor|
|
101
|
-
contributor_info.each do |key, value|
|
102
|
-
contributor.__send__("#{key}=", value)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
generator.each do |key, value|
|
108
|
-
maker.channel.generator do |g|
|
109
|
-
g.__send__("#{key}=", value)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
maker.channel.icon = icon
|
114
|
-
|
115
|
-
maker.channel.about = about
|
116
|
-
maker.channel.link = link
|
117
|
-
maker.channel.logo = logo
|
118
|
-
maker.channel.rights = rights
|
119
|
-
maker.channel.title = title
|
120
|
-
maker.channel.description = description
|
121
|
-
maker.channel.updated = updated
|
122
|
-
|
123
|
-
if with_dc
|
124
|
-
@dc_elems.each do |var, value|
|
125
|
-
if var == :date
|
126
|
-
maker.channel.new_dc_date(value)
|
127
|
-
else
|
128
|
-
maker.channel.__send__("dc_#{var}=", value)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
setup_dummy_item_atom(maker)
|
134
|
-
end
|
135
|
-
assert_not_nil(feed)
|
136
|
-
|
137
|
-
new_feed = RSS::Maker.make("atom") do |maker|
|
138
|
-
feed.setup_maker(maker)
|
139
|
-
end
|
140
|
-
assert_not_nil(new_feed)
|
141
|
-
|
142
|
-
new_authors = new_feed.authors.collect do |author|
|
143
|
-
{
|
144
|
-
:name => author.name.content,
|
145
|
-
:uri => author.uri.content,
|
146
|
-
:email => author.email.content,
|
147
|
-
}
|
148
|
-
end
|
149
|
-
assert_equal(authors, new_authors)
|
150
|
-
|
151
|
-
new_categories = new_feed.categories.collect do |category|
|
152
|
-
{
|
153
|
-
:term => category.term,
|
154
|
-
:scheme => category.scheme,
|
155
|
-
:label => category.label,
|
156
|
-
}.reject {|key, value| value.nil?}
|
157
|
-
end
|
158
|
-
assert_equal(categories, new_categories)
|
159
|
-
|
160
|
-
new_contributors = new_feed.contributors.collect do |contributor|
|
161
|
-
info = {}
|
162
|
-
info[:name] = contributor.name.content
|
163
|
-
info[:uri] = contributor.uri.content if contributor.uri
|
164
|
-
info[:email] = contributor.email.content if contributor.email
|
165
|
-
info
|
166
|
-
end
|
167
|
-
assert_equal(contributors, new_contributors)
|
168
|
-
|
169
|
-
new_generator = {
|
170
|
-
:uri => new_feed.generator.uri,
|
171
|
-
:version => new_feed.generator.version,
|
172
|
-
:content => new_feed.generator.content,
|
173
|
-
}
|
174
|
-
assert_equal(generator, new_generator)
|
175
|
-
|
176
|
-
assert_equal(icon, new_feed.icon.content)
|
177
|
-
assert_equal(about, new_feed.id.content)
|
178
|
-
assert_equal(link, new_feed.link.href)
|
179
|
-
assert_equal(logo, new_feed.logo.content)
|
180
|
-
assert_equal(rights, new_feed.rights.content)
|
181
|
-
assert_equal(description, new_feed.subtitle.content)
|
182
|
-
assert_equal(title, new_feed.title.content)
|
183
|
-
assert_equal(updated, new_feed.updated.content)
|
184
|
-
|
185
|
-
if with_dc
|
186
|
-
@dc_elems.each do |var, value|
|
187
|
-
if var == :date
|
188
|
-
assert_equal([updated, value],
|
189
|
-
new_feed.dc_dates.collect {|date| date.value})
|
190
|
-
else
|
191
|
-
assert_equal(value, new_feed.__send__("dc_#{var}"))
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
assert_equal(1, new_feed.items.size)
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_setup_maker_feed_without_dc
|
200
|
-
test_setup_maker_feed(false)
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_setup_maker_items(for_backward_compatibility=false)
|
204
|
-
title = "TITLE"
|
205
|
-
link = "http://hoge.com/"
|
206
|
-
description = "text hoge fuga"
|
207
|
-
updated = Time.now
|
208
|
-
|
209
|
-
item_size = 5
|
210
|
-
feed = RSS::Maker.make("atom") do |maker|
|
211
|
-
setup_dummy_channel_atom(maker)
|
212
|
-
|
213
|
-
item_size.times do |i|
|
214
|
-
maker.items.new_item do |item|
|
215
|
-
item.title = "#{title}#{i}"
|
216
|
-
item.link = "#{link}#{i}"
|
217
|
-
item.description = "#{description}#{i}"
|
218
|
-
item.updated = updated + i * 60
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
new_feed = RSS::Maker.make("atom") do |maker|
|
224
|
-
feed.items.each do |item|
|
225
|
-
if for_backward_compatibility
|
226
|
-
item.setup_maker(maker)
|
227
|
-
else
|
228
|
-
item.setup_maker(maker.items)
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
feed.items.clear
|
233
|
-
feed.setup_maker(maker)
|
234
|
-
end
|
235
|
-
|
236
|
-
assert_equal(item_size, new_feed.items.size)
|
237
|
-
new_feed.items.each_with_index do |item, i|
|
238
|
-
assert_equal("#{title}#{i}", item.title.content)
|
239
|
-
assert_equal("#{link}#{i}", item.link.href)
|
240
|
-
assert_equal("#{description}#{i}", item.summary.content)
|
241
|
-
assert_equal(updated + i * 60, item.updated.content)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_setup_maker_items_sort
|
246
|
-
title = "TITLE"
|
247
|
-
link = "http://hoge.com/"
|
248
|
-
summary = "text hoge fuga"
|
249
|
-
updated = Time.now
|
250
|
-
|
251
|
-
feed_size = 5
|
252
|
-
feed = RSS::Maker.make("atom") do |maker|
|
253
|
-
setup_dummy_channel_atom(maker)
|
254
|
-
|
255
|
-
feed_size.times do |i|
|
256
|
-
entry_class = RSS::Atom::Feed::Entry
|
257
|
-
entry = entry_class.new
|
258
|
-
entry.title = entry_class::Title.new(:content => "#{title}#{i}")
|
259
|
-
entry.links << entry_class::Link.new(:href => "#{link}#{i}")
|
260
|
-
entry.summary = entry_class::Summary.new(:content => "#{summary}#{i}")
|
261
|
-
entry.updated = entry_class::Updated.new(:content => updated + i * 60)
|
262
|
-
entry.setup_maker(maker.items)
|
263
|
-
end
|
264
|
-
maker.items.do_sort = false
|
265
|
-
end
|
266
|
-
assert_equal(feed_size, feed.entries.size)
|
267
|
-
feed.entries.each_with_index do |entry, i|
|
268
|
-
assert_equal("#{title}#{i}", entry.title.content)
|
269
|
-
assert_equal("#{link}#{i}", entry.link.href)
|
270
|
-
assert_equal("#{summary}#{i}", entry.summary.content)
|
271
|
-
end
|
272
|
-
|
273
|
-
|
274
|
-
feed = RSS::Maker.make("atom") do |maker|
|
275
|
-
setup_dummy_channel_atom(maker)
|
276
|
-
|
277
|
-
feed_size.times do |i|
|
278
|
-
entry_class = RSS::Atom::Feed::Entry
|
279
|
-
entry = entry_class.new
|
280
|
-
entry.title = entry_class::Title.new(:content => "#{title}#{i}")
|
281
|
-
entry.links << entry_class::Link.new(:href => "#{link}#{i}")
|
282
|
-
entry.summary = entry_class::Summary.new(:content => "#{summary}#{i}")
|
283
|
-
entry.updated = entry_class::Updated.new(:content => updated + i * 60)
|
284
|
-
entry.setup_maker(maker.items)
|
285
|
-
end
|
286
|
-
maker.items.do_sort = true
|
287
|
-
end
|
288
|
-
assert_equal(feed_size, feed.entries.size)
|
289
|
-
feed.entries.reverse.each_with_index do |entry, i|
|
290
|
-
assert_equal("#{title}#{i}", entry.title.content)
|
291
|
-
assert_equal("#{link}#{i}", entry.link.href)
|
292
|
-
assert_equal("#{summary}#{i}", entry.summary.content)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_setup_maker_items_backward_compatibility
|
297
|
-
test_setup_maker_items(true)
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_setup_maker
|
301
|
-
encoding = "EUC-JP"
|
302
|
-
standalone = true
|
303
|
-
|
304
|
-
href = 'a.xsl'
|
305
|
-
type = 'text/xsl'
|
306
|
-
title = 'sample'
|
307
|
-
media = 'printer'
|
308
|
-
charset = 'UTF-8'
|
309
|
-
alternate = 'yes'
|
310
|
-
|
311
|
-
feed = RSS::Maker.make("atom") do |maker|
|
312
|
-
maker.encoding = encoding
|
313
|
-
maker.standalone = standalone
|
314
|
-
|
315
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
316
|
-
xss.href = href
|
317
|
-
xss.type = type
|
318
|
-
xss.title = title
|
319
|
-
xss.media = media
|
320
|
-
xss.charset = charset
|
321
|
-
xss.alternate = alternate
|
322
|
-
end
|
323
|
-
|
324
|
-
setup_dummy_channel_atom(maker)
|
325
|
-
setup_dummy_item_atom(maker)
|
326
|
-
end
|
327
|
-
assert_not_nil(feed)
|
328
|
-
|
329
|
-
new_feed = RSS::Maker.make("atom") do |maker|
|
330
|
-
feed.setup_maker(maker)
|
331
|
-
end
|
332
|
-
|
333
|
-
assert_equal(["atom", "1.0", "feed"], new_feed.feed_info)
|
334
|
-
assert_equal(encoding, new_feed.encoding)
|
335
|
-
assert_equal(standalone, new_feed.standalone)
|
336
|
-
|
337
|
-
xss = new_feed.xml_stylesheets.first
|
338
|
-
assert_equal(1, new_feed.xml_stylesheets.size)
|
339
|
-
assert_equal(href, xss.href)
|
340
|
-
assert_equal(type, xss.type)
|
341
|
-
assert_equal(title, xss.title)
|
342
|
-
assert_equal(media, xss.media)
|
343
|
-
assert_equal(charset, xss.charset)
|
344
|
-
assert_equal(alternate, xss.alternate)
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_setup_maker_full
|
348
|
-
encoding = "EUC-JP"
|
349
|
-
standalone = true
|
350
|
-
|
351
|
-
href = 'a.xsl'
|
352
|
-
type = 'text/xsl'
|
353
|
-
title = 'sample'
|
354
|
-
media = 'printer'
|
355
|
-
charset = 'UTF-8'
|
356
|
-
alternate = 'yes'
|
357
|
-
|
358
|
-
channel_about = "http://hoge.com"
|
359
|
-
channel_title = "fugafuga"
|
360
|
-
channel_link = "http://hoge.com"
|
361
|
-
channel_description = "fugafugafugafuga"
|
362
|
-
channel_author = "Bob"
|
363
|
-
|
364
|
-
image_url = "http://hoge.com/hoge.png"
|
365
|
-
|
366
|
-
item_title = "TITLE"
|
367
|
-
item_link = "http://hoge.com/"
|
368
|
-
item_description = "text hoge fuga"
|
369
|
-
|
370
|
-
entry_size = 5
|
371
|
-
feed = RSS::Maker.make("atom") do |maker|
|
372
|
-
maker.encoding = encoding
|
373
|
-
maker.standalone = standalone
|
374
|
-
|
375
|
-
maker.xml_stylesheets.new_xml_stylesheet do |xss|
|
376
|
-
xss.href = href
|
377
|
-
xss.type = type
|
378
|
-
xss.title = title
|
379
|
-
xss.media = media
|
380
|
-
xss.charset = charset
|
381
|
-
xss.alternate = alternate
|
382
|
-
end
|
383
|
-
|
384
|
-
maker.channel.about = channel_about
|
385
|
-
maker.channel.title = channel_title
|
386
|
-
maker.channel.link = channel_link
|
387
|
-
maker.channel.description = channel_description
|
388
|
-
maker.channel.author = channel_author
|
389
|
-
@dc_elems.each do |var, value|
|
390
|
-
maker.channel.__send__("dc_#{var}=", value)
|
391
|
-
end
|
392
|
-
|
393
|
-
maker.image.url = image_url
|
394
|
-
|
395
|
-
entry_size.times do |i|
|
396
|
-
maker.items.new_item do |item|
|
397
|
-
item.title = "#{item_title}#{i}"
|
398
|
-
item.link = "#{item_link}#{i}"
|
399
|
-
item.description = "#{item_description}#{i}"
|
400
|
-
|
401
|
-
@dc_elems.each do |var, value|
|
402
|
-
item.__send__("dc_#{var}=", value)
|
403
|
-
end
|
404
|
-
end
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
|
-
new_feed = RSS::Maker.make("atom") do |maker|
|
409
|
-
feed.setup_maker(maker)
|
410
|
-
end
|
411
|
-
|
412
|
-
assert_equal(["atom", "1.0", "feed"], new_feed.feed_info)
|
413
|
-
assert_equal(encoding, new_feed.encoding)
|
414
|
-
assert_equal(standalone, new_feed.standalone)
|
415
|
-
|
416
|
-
xss = new_feed.xml_stylesheets.first
|
417
|
-
assert_equal(1, new_feed.xml_stylesheets.size)
|
418
|
-
assert_equal(href, xss.href)
|
419
|
-
assert_equal(type, xss.type)
|
420
|
-
assert_equal(title, xss.title)
|
421
|
-
assert_equal(media, xss.media)
|
422
|
-
assert_equal(charset, xss.charset)
|
423
|
-
assert_equal(alternate, xss.alternate)
|
424
|
-
|
425
|
-
assert_equal(channel_title, new_feed.title.content)
|
426
|
-
assert_equal(channel_link, new_feed.link.href)
|
427
|
-
assert_equal(channel_description, new_feed.subtitle.content)
|
428
|
-
assert_equal(channel_author, new_feed.author.name.content)
|
429
|
-
assert_equal(image_url, new_feed.logo.content)
|
430
|
-
@dc_elems.each do |var, value|
|
431
|
-
assert_equal(value, new_feed.__send__("dc_#{var}"))
|
432
|
-
end
|
433
|
-
|
434
|
-
assert_equal(entry_size, new_feed.entries.size)
|
435
|
-
new_feed.entries.each_with_index do |entry, i|
|
436
|
-
assert_equal("#{item_title}#{i}", entry.title.content)
|
437
|
-
assert_equal("#{item_link}#{i}", entry.link.href)
|
438
|
-
assert_equal("#{item_description}#{i}", entry.summary.content)
|
439
|
-
|
440
|
-
@dc_elems.each do |var, value|
|
441
|
-
assert_equal(value, entry.__send__("dc_#{var}"))
|
442
|
-
end
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestSetupMakerITunes < TestCase
|
8
|
-
def test_setup_maker_simple
|
9
|
-
author = "John Doe"
|
10
|
-
block = true
|
11
|
-
categories = ["Audio Blogs"]
|
12
|
-
image = "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
13
|
-
duration = "4:05"
|
14
|
-
duration_components = [0, 4, 5]
|
15
|
-
explicit = true
|
16
|
-
keywords = ["salt", "pepper", "shaker", "exciting"]
|
17
|
-
owner = {:name => "John Doe", :email => "john.doe@example.com"}
|
18
|
-
subtitle = "A show about everything"
|
19
|
-
summary = "All About Everything is a show about " +
|
20
|
-
"everything. Each week we dive into any " +
|
21
|
-
"subject known to man and talk about it " +
|
22
|
-
"as much as we can. Look for our Podcast " +
|
23
|
-
"in the iTunes Music Store"
|
24
|
-
|
25
|
-
feed = RSS::Maker.make("rss2.0") do |maker|
|
26
|
-
setup_dummy_channel(maker)
|
27
|
-
setup_dummy_item(maker)
|
28
|
-
|
29
|
-
channel = maker.channel
|
30
|
-
channel.itunes_author = author
|
31
|
-
channel.itunes_block = block
|
32
|
-
categories.each do |category|
|
33
|
-
channel.itunes_categories.new_category.text = category
|
34
|
-
end
|
35
|
-
channel.itunes_image = image
|
36
|
-
channel.itunes_explicit = explicit
|
37
|
-
channel.itunes_keywords = keywords
|
38
|
-
channel.itunes_owner.itunes_name = owner[:name]
|
39
|
-
channel.itunes_owner.itunes_email = owner[:email]
|
40
|
-
channel.itunes_subtitle = subtitle
|
41
|
-
channel.itunes_summary = summary
|
42
|
-
|
43
|
-
item = maker.items.last
|
44
|
-
item.itunes_image = image
|
45
|
-
item.itunes_author = author
|
46
|
-
item.itunes_block = block
|
47
|
-
item.itunes_duration = duration
|
48
|
-
item.itunes_explicit = explicit
|
49
|
-
item.itunes_keywords = keywords
|
50
|
-
item.itunes_subtitle = subtitle
|
51
|
-
item.itunes_summary = summary
|
52
|
-
end
|
53
|
-
assert_not_nil(feed)
|
54
|
-
|
55
|
-
new_feed = RSS::Maker.make("rss2.0") do |maker|
|
56
|
-
feed.setup_maker(maker)
|
57
|
-
end
|
58
|
-
assert_not_nil(new_feed)
|
59
|
-
|
60
|
-
channel = new_feed.channel
|
61
|
-
item = new_feed.items.last
|
62
|
-
|
63
|
-
assert_equal(author, channel.itunes_author)
|
64
|
-
assert_equal(author, item.itunes_author)
|
65
|
-
|
66
|
-
assert_equal(block, channel.itunes_block?)
|
67
|
-
assert_equal(block, item.itunes_block?)
|
68
|
-
|
69
|
-
assert_equal(categories,
|
70
|
-
collect_itunes_categories(channel.itunes_categories))
|
71
|
-
|
72
|
-
assert_equal(image, channel.itunes_image.href)
|
73
|
-
assert_equal(image, item.itunes_image.href)
|
74
|
-
|
75
|
-
assert_equal(duration_components,
|
76
|
-
[item.itunes_duration.hour,
|
77
|
-
item.itunes_duration.minute,
|
78
|
-
item.itunes_duration.second])
|
79
|
-
|
80
|
-
assert_equal(explicit, channel.itunes_explicit?)
|
81
|
-
assert_equal(explicit, item.itunes_explicit?)
|
82
|
-
|
83
|
-
assert_equal(keywords, channel.itunes_keywords)
|
84
|
-
assert_equal(keywords, item.itunes_keywords)
|
85
|
-
|
86
|
-
assert_equal(owner,
|
87
|
-
{
|
88
|
-
:name => channel.itunes_owner.itunes_name,
|
89
|
-
:email => channel.itunes_owner.itunes_email
|
90
|
-
})
|
91
|
-
|
92
|
-
assert_equal(subtitle, channel.itunes_subtitle)
|
93
|
-
assert_equal(subtitle, item.itunes_subtitle)
|
94
|
-
|
95
|
-
assert_equal(summary, channel.itunes_summary)
|
96
|
-
assert_equal(summary, item.itunes_summary)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_setup_maker_with_nested_categories
|
100
|
-
categories = [["Arts & Entertainment", "Games"],
|
101
|
-
["Technology", "Computers"],
|
102
|
-
"Audio Blogs"]
|
103
|
-
|
104
|
-
feed = RSS::Maker.make("rss2.0") do |maker|
|
105
|
-
setup_dummy_channel(maker)
|
106
|
-
setup_dummy_item(maker)
|
107
|
-
|
108
|
-
channel = maker.channel
|
109
|
-
categories.each do |category|
|
110
|
-
target = channel.itunes_categories
|
111
|
-
if category.is_a?(Array)
|
112
|
-
category.each do |sub_category|
|
113
|
-
target = target.new_category
|
114
|
-
target.text = sub_category
|
115
|
-
end
|
116
|
-
else
|
117
|
-
target.new_category.text = category
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
assert_not_nil(feed)
|
122
|
-
|
123
|
-
new_feed = RSS::Maker.make("rss2.0") do |maker|
|
124
|
-
feed.setup_maker(maker)
|
125
|
-
end
|
126
|
-
assert_not_nil(new_feed)
|
127
|
-
|
128
|
-
channel = new_feed.channel
|
129
|
-
|
130
|
-
assert_equal(categories,
|
131
|
-
collect_itunes_categories(channel.itunes_categories))
|
132
|
-
end
|
133
|
-
|
134
|
-
private
|
135
|
-
def collect_itunes_categories(categories)
|
136
|
-
categories.collect do |c|
|
137
|
-
rest = collect_itunes_categories(c.itunes_categories)
|
138
|
-
if rest.empty?
|
139
|
-
c.text
|
140
|
-
else
|
141
|
-
[c.text, *rest]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestSetupMakerSlash < TestCase
|
8
|
-
def test_setup_maker
|
9
|
-
elements = {
|
10
|
-
"section" => "articles",
|
11
|
-
"department" => "not-an-ocean-unless-there-are-lobsters",
|
12
|
-
"comments" => 177,
|
13
|
-
"hit_parades" => [177, 155, 105, 33, 6, 3, 0],
|
14
|
-
}
|
15
|
-
|
16
|
-
rss = RSS::Maker.make("rss1.0") do |maker|
|
17
|
-
setup_dummy_channel(maker)
|
18
|
-
setup_dummy_item(maker)
|
19
|
-
|
20
|
-
item = maker.items.last
|
21
|
-
item.slash_section = elements["section"]
|
22
|
-
item.slash_department = elements["department"]
|
23
|
-
item.slash_comments = elements["comments"]
|
24
|
-
item.slash_hit_parade = elements["hit_parades"].join(",")
|
25
|
-
end
|
26
|
-
assert_not_nil(rss)
|
27
|
-
|
28
|
-
new_rss = RSS::Maker.make("rss1.0") do |maker|
|
29
|
-
rss.setup_maker(maker)
|
30
|
-
end
|
31
|
-
assert_not_nil(new_rss)
|
32
|
-
|
33
|
-
item = new_rss.items.last
|
34
|
-
assert_not_nil(item)
|
35
|
-
|
36
|
-
assert_slash_elements(elements, item)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/test/test_slash.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require "cgi"
|
3
|
-
require "rexml/document"
|
4
|
-
|
5
|
-
require_relative "rss-testcase"
|
6
|
-
|
7
|
-
require "rss/1.0"
|
8
|
-
require "rss/slash"
|
9
|
-
|
10
|
-
module RSS
|
11
|
-
class TestSlash < TestCase
|
12
|
-
def setup
|
13
|
-
@elements = {
|
14
|
-
"section" => "articles",
|
15
|
-
"department" => "not-an-ocean-unless-there-are-lobsters",
|
16
|
-
"comments" => 177,
|
17
|
-
"hit_parades" => [177, 155, 105, 33, 6, 3, 0],
|
18
|
-
}
|
19
|
-
|
20
|
-
slash_nodes = @elements.collect do |name, value|
|
21
|
-
if name == "hit_parades"
|
22
|
-
name = "hit_parade"
|
23
|
-
value = value.join(",")
|
24
|
-
end
|
25
|
-
"<slash:#{name}>#{value}</slash:#{name}>"
|
26
|
-
end.join("\n")
|
27
|
-
|
28
|
-
slash_ns = {"slash" => "http://purl.org/rss/1.0/modules/slash/"}
|
29
|
-
@source = make_RDF(<<-EOR, slash_ns)
|
30
|
-
#{make_channel}
|
31
|
-
#{make_image}
|
32
|
-
#{make_item(slash_nodes)}
|
33
|
-
#{make_textinput}
|
34
|
-
EOR
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_parser
|
38
|
-
rss = RSS::Parser.parse(@source)
|
39
|
-
|
40
|
-
assert_not_nil(rss)
|
41
|
-
|
42
|
-
item = rss.items[0]
|
43
|
-
assert_not_nil(item)
|
44
|
-
|
45
|
-
assert_slash_elements(item)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_to_s
|
49
|
-
rss = RSS::Parser.parse(@source)
|
50
|
-
rss = RSS::Parser.parse(rss.to_s)
|
51
|
-
|
52
|
-
assert_not_nil(rss)
|
53
|
-
|
54
|
-
item = rss.items[0]
|
55
|
-
assert_not_nil(item)
|
56
|
-
|
57
|
-
assert_slash_elements(item)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
def assert_slash_elements(target)
|
62
|
-
super(@elements, target)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|