rss 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +16 -0
- data/Rakefile +8 -1
- data/lib/rss/itunes.rb +49 -1
- data/lib/rss/maker/itunes.rb +13 -0
- data/lib/rss/parser.rb +1 -1
- data/lib/rss/version.rb +1 -1
- data/rss.gemspec +6 -56
- data/test/dot.png +0 -0
- data/test/rss-assertions.rb +2116 -0
- data/test/rss-testcase.rb +479 -0
- data/test/run-test.rb +15 -0
- data/test/test_1.0.rb +308 -0
- data/test/test_2.0.rb +412 -0
- data/test/test_accessor.rb +104 -0
- data/test/test_atom.rb +684 -0
- data/test/test_content.rb +105 -0
- data/test/test_dublincore.rb +270 -0
- data/test/test_image.rb +215 -0
- data/test/test_inherit.rb +41 -0
- data/test/test_itunes.rb +360 -0
- data/test/test_maker_0.9.rb +477 -0
- data/test/test_maker_1.0.rb +519 -0
- data/test/test_maker_2.0.rb +758 -0
- data/test/test_maker_atom_entry.rb +394 -0
- data/test/test_maker_atom_feed.rb +455 -0
- data/test/test_maker_content.rb +48 -0
- data/test/test_maker_dc.rb +150 -0
- data/test/test_maker_image.rb +63 -0
- data/test/test_maker_itunes.rb +488 -0
- data/test/test_maker_slash.rb +38 -0
- data/test/test_maker_sy.rb +45 -0
- data/test/test_maker_taxo.rb +82 -0
- data/test/test_maker_trackback.rb +42 -0
- data/test/test_maker_xml-stylesheet.rb +84 -0
- data/test/test_parser.rb +122 -0
- data/test/test_parser_1.0.rb +529 -0
- data/test/test_parser_2.0.rb +123 -0
- data/test/test_parser_atom_entry.rb +164 -0
- data/test/test_parser_atom_feed.rb +277 -0
- data/test/test_setup_maker_0.9.rb +247 -0
- data/test/test_setup_maker_1.0.rb +551 -0
- data/test/test_setup_maker_2.0.rb +309 -0
- data/test/test_setup_maker_atom_entry.rb +410 -0
- data/test/test_setup_maker_atom_feed.rb +446 -0
- data/test/test_setup_maker_itunes.rb +146 -0
- data/test/test_setup_maker_slash.rb +39 -0
- data/test/test_slash.rb +65 -0
- data/test/test_syndication.rb +126 -0
- data/test/test_taxonomy.rb +173 -0
- data/test/test_to_s.rb +701 -0
- data/test/test_trackback.rb +136 -0
- data/test/test_xml-stylesheet.rb +109 -0
- metadata +109 -7
- data/.gitignore +0 -9
- data/.travis.yml +0 -26
@@ -0,0 +1,446 @@
|
|
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
|
@@ -0,0 +1,146 @@
|
|
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
|