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
data/test/test_maker_0.9.rb
DELETED
@@ -1,477 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMaker09 < TestCase
|
8
|
-
def test_supported?
|
9
|
-
assert(RSS::Maker.supported?("0.9"))
|
10
|
-
assert(RSS::Maker.supported?("rss0.9"))
|
11
|
-
assert(RSS::Maker.supported?("0.91"))
|
12
|
-
assert(RSS::Maker.supported?("rss0.91"))
|
13
|
-
assert(RSS::Maker.supported?("0.92"))
|
14
|
-
assert(RSS::Maker.supported?("rss0.92"))
|
15
|
-
assert(!RSS::Maker.supported?("0.93"))
|
16
|
-
assert(!RSS::Maker.supported?("rss0.93"))
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_find_class
|
20
|
-
assert_equal(RSS::Maker::RSS091, RSS::Maker["0.91"])
|
21
|
-
assert_equal(RSS::Maker::RSS091, RSS::Maker["rss0.91"])
|
22
|
-
assert_equal(RSS::Maker::RSS092, RSS::Maker["0.9"])
|
23
|
-
assert_equal(RSS::Maker::RSS092, RSS::Maker["0.92"])
|
24
|
-
assert_equal(RSS::Maker::RSS092, RSS::Maker["rss0.92"])
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_rss
|
28
|
-
assert_raise(LocalJumpError) do
|
29
|
-
RSS::Maker.make("0.91")
|
30
|
-
end
|
31
|
-
|
32
|
-
rss = RSS::Maker.make("0.9") do |maker|
|
33
|
-
setup_dummy_channel(maker)
|
34
|
-
setup_dummy_image(maker)
|
35
|
-
end
|
36
|
-
assert_equal("0.92", rss.rss_version)
|
37
|
-
|
38
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
39
|
-
setup_dummy_channel(maker)
|
40
|
-
setup_dummy_image(maker)
|
41
|
-
end
|
42
|
-
assert_equal("0.91", rss.rss_version)
|
43
|
-
|
44
|
-
|
45
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
46
|
-
setup_dummy_channel(maker)
|
47
|
-
setup_dummy_image(maker)
|
48
|
-
|
49
|
-
maker.encoding = "EUC-JP"
|
50
|
-
end
|
51
|
-
assert_equal("0.91", rss.rss_version)
|
52
|
-
assert_equal("EUC-JP", rss.encoding)
|
53
|
-
|
54
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
55
|
-
setup_dummy_channel(maker)
|
56
|
-
setup_dummy_image(maker)
|
57
|
-
|
58
|
-
maker.standalone = "yes"
|
59
|
-
end
|
60
|
-
assert_equal("0.91", rss.rss_version)
|
61
|
-
assert_equal("yes", rss.standalone)
|
62
|
-
|
63
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
64
|
-
setup_dummy_channel(maker)
|
65
|
-
setup_dummy_image(maker)
|
66
|
-
|
67
|
-
maker.encoding = "EUC-JP"
|
68
|
-
maker.standalone = "yes"
|
69
|
-
end
|
70
|
-
assert_equal("0.91", rss.rss_version)
|
71
|
-
assert_equal("EUC-JP", rss.encoding)
|
72
|
-
assert_equal("yes", rss.standalone)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_channel
|
76
|
-
title = "fugafuga"
|
77
|
-
link = "http://hoge.com"
|
78
|
-
description = "fugafugafugafuga"
|
79
|
-
language = "ja"
|
80
|
-
copyright = "foo"
|
81
|
-
managingEditor = "bar"
|
82
|
-
webMaster = "web master"
|
83
|
-
rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
|
84
|
-
docs = "http://foo.com/doc"
|
85
|
-
skipDays = [
|
86
|
-
"Sunday",
|
87
|
-
"Monday",
|
88
|
-
]
|
89
|
-
skipHours = [
|
90
|
-
"0",
|
91
|
-
"13",
|
92
|
-
]
|
93
|
-
pubDate = Time.now
|
94
|
-
lastBuildDate = Time.now
|
95
|
-
|
96
|
-
image_url = "http://example.com/logo.png"
|
97
|
-
image_title = "Logo"
|
98
|
-
|
99
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
100
|
-
maker.channel.title = title
|
101
|
-
maker.channel.link = link
|
102
|
-
maker.channel.description = description
|
103
|
-
maker.channel.language = language
|
104
|
-
maker.channel.copyright = copyright
|
105
|
-
maker.channel.managingEditor = managingEditor
|
106
|
-
maker.channel.webMaster = webMaster
|
107
|
-
maker.channel.rating = rating
|
108
|
-
maker.channel.docs = docs
|
109
|
-
maker.channel.pubDate = pubDate
|
110
|
-
maker.channel.lastBuildDate = lastBuildDate
|
111
|
-
|
112
|
-
skipDays.each do |day|
|
113
|
-
maker.channel.skipDays.new_day do |new_day|
|
114
|
-
new_day.content = day
|
115
|
-
end
|
116
|
-
end
|
117
|
-
skipHours.each do |hour|
|
118
|
-
maker.channel.skipHours.new_hour do |new_hour|
|
119
|
-
new_hour.content = hour
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
maker.image.url = image_url
|
124
|
-
maker.image.title = image_title
|
125
|
-
end
|
126
|
-
channel = rss.channel
|
127
|
-
|
128
|
-
assert_equal(title, channel.title)
|
129
|
-
assert_equal(link, channel.link)
|
130
|
-
assert_equal(description, channel.description)
|
131
|
-
assert_equal(language, channel.language)
|
132
|
-
assert_equal(copyright, channel.copyright)
|
133
|
-
assert_equal(managingEditor, channel.managingEditor)
|
134
|
-
assert_equal(webMaster, channel.webMaster)
|
135
|
-
assert_equal(rating, channel.rating)
|
136
|
-
assert_equal(docs, channel.docs)
|
137
|
-
assert_equal(pubDate, channel.pubDate)
|
138
|
-
assert_equal(pubDate, channel.date)
|
139
|
-
assert_equal(lastBuildDate, channel.lastBuildDate)
|
140
|
-
|
141
|
-
skipDays.each_with_index do |day, i|
|
142
|
-
assert_equal(day, channel.skipDays.days[i].content)
|
143
|
-
end
|
144
|
-
skipHours.each_with_index do |hour, i|
|
145
|
-
assert_equal(hour.to_i, channel.skipHours.hours[i].content)
|
146
|
-
end
|
147
|
-
|
148
|
-
assert(channel.items.empty?)
|
149
|
-
|
150
|
-
assert_equal(image_url, channel.image.url)
|
151
|
-
assert_equal(image_title, channel.image.title)
|
152
|
-
assert_equal(link, channel.image.link)
|
153
|
-
|
154
|
-
assert_nil(channel.textInput)
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_not_valid_channel
|
158
|
-
title = "fugafuga"
|
159
|
-
link = "http://hoge.com"
|
160
|
-
description = "fugafugafugafuga"
|
161
|
-
language = "ja"
|
162
|
-
|
163
|
-
assert_not_set_error("maker.channel", %w(title)) do
|
164
|
-
RSS::Maker.make("0.91") do |maker|
|
165
|
-
# maker.channel.title = title
|
166
|
-
maker.channel.link = link
|
167
|
-
maker.channel.description = description
|
168
|
-
maker.channel.language = language
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
assert_not_set_error("maker.channel", %w(link)) do
|
173
|
-
RSS::Maker.make("0.91") do |maker|
|
174
|
-
maker.channel.title = title
|
175
|
-
# maker.channel.link = link
|
176
|
-
maker.channel.link = nil
|
177
|
-
maker.channel.description = description
|
178
|
-
maker.channel.language = language
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
assert_not_set_error("maker.channel", %w(description)) do
|
183
|
-
RSS::Maker.make("0.91") do |maker|
|
184
|
-
maker.channel.title = title
|
185
|
-
maker.channel.link = link
|
186
|
-
# maker.channel.description = description
|
187
|
-
maker.channel.language = language
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
assert_not_set_error("maker.channel", %w(language)) do
|
192
|
-
RSS::Maker.make("0.91") do |maker|
|
193
|
-
maker.channel.title = title
|
194
|
-
maker.channel.link = link
|
195
|
-
maker.channel.description = description
|
196
|
-
# maker.channel.language = language
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_image
|
202
|
-
title = "fugafuga"
|
203
|
-
link = "http://hoge.com"
|
204
|
-
url = "http://hoge.com/hoge.png"
|
205
|
-
width = "144"
|
206
|
-
height = "400"
|
207
|
-
description = "an image"
|
208
|
-
|
209
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
210
|
-
setup_dummy_channel(maker)
|
211
|
-
maker.channel.link = link
|
212
|
-
|
213
|
-
maker.image.title = title
|
214
|
-
maker.image.url = url
|
215
|
-
maker.image.width = width
|
216
|
-
maker.image.height = height
|
217
|
-
maker.image.description = description
|
218
|
-
end
|
219
|
-
image = rss.image
|
220
|
-
assert_equal(title, image.title)
|
221
|
-
assert_equal(link, image.link)
|
222
|
-
assert_equal(url, image.url)
|
223
|
-
assert_equal(width.to_i, image.width)
|
224
|
-
assert_equal(height.to_i, image.height)
|
225
|
-
assert_equal(description, image.description)
|
226
|
-
|
227
|
-
assert_not_set_error("maker.channel", %w(description title language)) do
|
228
|
-
RSS::Maker.make("0.91") do |maker|
|
229
|
-
# setup_dummy_channel(maker)
|
230
|
-
maker.channel.link = link
|
231
|
-
|
232
|
-
maker.image.title = title
|
233
|
-
maker.image.url = url
|
234
|
-
maker.image.width = width
|
235
|
-
maker.image.height = height
|
236
|
-
maker.image.description = description
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_not_valid_image
|
242
|
-
title = "fugafuga"
|
243
|
-
link = "http://hoge.com"
|
244
|
-
url = "http://hoge.com/hoge.png"
|
245
|
-
width = "144"
|
246
|
-
height = "400"
|
247
|
-
description = "an image"
|
248
|
-
|
249
|
-
assert_not_set_error("maker.image", %w(title)) do
|
250
|
-
RSS::Maker.make("0.91") do |maker|
|
251
|
-
setup_dummy_channel(maker)
|
252
|
-
maker.channel.link = link
|
253
|
-
|
254
|
-
# maker.image.title = title
|
255
|
-
maker.image.url = url
|
256
|
-
maker.image.width = width
|
257
|
-
maker.image.height = height
|
258
|
-
maker.image.description = description
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
assert_not_set_error("maker.channel", %w(link)) do
|
263
|
-
RSS::Maker.make("0.91") do |maker|
|
264
|
-
setup_dummy_channel(maker)
|
265
|
-
# maker.channel.link = link
|
266
|
-
maker.channel.link = nil
|
267
|
-
|
268
|
-
maker.image.title = title
|
269
|
-
maker.image.url = url
|
270
|
-
maker.image.width = width
|
271
|
-
maker.image.height = height
|
272
|
-
maker.image.description = description
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
assert_not_set_error("maker.image", %w(url)) do
|
277
|
-
RSS::Maker.make("0.91") do |maker|
|
278
|
-
setup_dummy_channel(maker)
|
279
|
-
maker.channel.link = link
|
280
|
-
|
281
|
-
maker.image.title = title
|
282
|
-
# maker.image.url = url
|
283
|
-
maker.image.width = width
|
284
|
-
maker.image.height = height
|
285
|
-
maker.image.description = description
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_items(with_convenience_way=true)
|
291
|
-
title = "TITLE"
|
292
|
-
link = "http://hoge.com/"
|
293
|
-
description = "text hoge fuga"
|
294
|
-
|
295
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
296
|
-
setup_dummy_channel(maker)
|
297
|
-
setup_dummy_image(maker)
|
298
|
-
end
|
299
|
-
assert(rss.channel.items.empty?)
|
300
|
-
|
301
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
302
|
-
setup_dummy_channel(maker)
|
303
|
-
|
304
|
-
maker.items.new_item do |item|
|
305
|
-
item.title = title
|
306
|
-
item.link = link
|
307
|
-
# item.description = description
|
308
|
-
end
|
309
|
-
|
310
|
-
setup_dummy_image(maker)
|
311
|
-
end
|
312
|
-
assert_equal(1, rss.channel.items.size)
|
313
|
-
item = rss.channel.items.first
|
314
|
-
assert_equal(title, item.title)
|
315
|
-
assert_equal(link, item.link)
|
316
|
-
assert_nil(item.description)
|
317
|
-
|
318
|
-
pubDate = Time.now
|
319
|
-
|
320
|
-
item_size = 5
|
321
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
322
|
-
setup_dummy_channel(maker)
|
323
|
-
|
324
|
-
item_size.times do |i|
|
325
|
-
maker.items.new_item do |_item|
|
326
|
-
_item.title = "#{title}#{i}"
|
327
|
-
_item.link = "#{link}#{i}"
|
328
|
-
_item.description = "#{description}#{i}"
|
329
|
-
_item.date = pubDate - i
|
330
|
-
end
|
331
|
-
end
|
332
|
-
maker.items.do_sort = true
|
333
|
-
|
334
|
-
setup_dummy_image(maker)
|
335
|
-
end
|
336
|
-
assert_equal(item_size, rss.items.size)
|
337
|
-
rss.channel.items.each_with_index do |_item, i|
|
338
|
-
assert_equal("#{title}#{i}", _item.title)
|
339
|
-
assert_equal("#{link}#{i}", _item.link)
|
340
|
-
assert_equal("#{description}#{i}", _item.description)
|
341
|
-
end
|
342
|
-
|
343
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
344
|
-
setup_dummy_channel(maker)
|
345
|
-
|
346
|
-
item_size.times do |i|
|
347
|
-
maker.items.new_item do |_item|
|
348
|
-
_item.title = "#{title}#{i}"
|
349
|
-
_item.link = "#{link}#{i}"
|
350
|
-
_item.description = "#{description}#{i}"
|
351
|
-
end
|
352
|
-
end
|
353
|
-
maker.items.do_sort = Proc.new do |x, y|
|
354
|
-
if with_convenience_way
|
355
|
-
y.title[-1] <=> x.title[-1]
|
356
|
-
else
|
357
|
-
y.title {|t| t.content[-1]} <=> x.title {|t| t.content[-1]}
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
setup_dummy_image(maker)
|
362
|
-
end
|
363
|
-
assert_equal(item_size, rss.items.size)
|
364
|
-
rss.channel.items.reverse.each_with_index do |_item, i|
|
365
|
-
assert_equal("#{title}#{i}", _item.title)
|
366
|
-
assert_equal("#{link}#{i}", _item.link)
|
367
|
-
assert_equal("#{description}#{i}", _item.description)
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
def test_items_with_new_api_since_018
|
372
|
-
test_items(false)
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_textInput
|
376
|
-
title = "fugafuga"
|
377
|
-
description = "text hoge fuga"
|
378
|
-
name = "hoge"
|
379
|
-
link = "http://hoge.com"
|
380
|
-
|
381
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
382
|
-
setup_dummy_channel(maker)
|
383
|
-
setup_dummy_image(maker)
|
384
|
-
|
385
|
-
maker.textinput.title = title
|
386
|
-
maker.textinput.description = description
|
387
|
-
maker.textinput.name = name
|
388
|
-
maker.textinput.link = link
|
389
|
-
end
|
390
|
-
textInput = rss.channel.textInput
|
391
|
-
assert_equal(title, textInput.title)
|
392
|
-
assert_equal(description, textInput.description)
|
393
|
-
assert_equal(name, textInput.name)
|
394
|
-
assert_equal(link, textInput.link)
|
395
|
-
|
396
|
-
assert_not_set_error("maker.channel",
|
397
|
-
%w(link language description title)) do
|
398
|
-
RSS::Maker.make("0.91") do |maker|
|
399
|
-
# setup_dummy_channel(maker)
|
400
|
-
|
401
|
-
maker.textinput.title = title
|
402
|
-
maker.textinput.description = description
|
403
|
-
maker.textinput.name = name
|
404
|
-
maker.textinput.link = link
|
405
|
-
end
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
def test_not_valid_textInput
|
410
|
-
title = "fugafuga"
|
411
|
-
description = "text hoge fuga"
|
412
|
-
name = "hoge"
|
413
|
-
link = "http://hoge.com"
|
414
|
-
|
415
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
416
|
-
setup_dummy_channel(maker)
|
417
|
-
setup_dummy_image(maker)
|
418
|
-
|
419
|
-
# maker.textinput.title = title
|
420
|
-
maker.textinput.description = description
|
421
|
-
maker.textinput.name = name
|
422
|
-
maker.textinput.link = link
|
423
|
-
end
|
424
|
-
assert_nil(rss.channel.textInput)
|
425
|
-
|
426
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
427
|
-
setup_dummy_channel(maker)
|
428
|
-
setup_dummy_image(maker)
|
429
|
-
|
430
|
-
maker.textinput.title = title
|
431
|
-
# maker.textinput.description = description
|
432
|
-
maker.textinput.name = name
|
433
|
-
maker.textinput.link = link
|
434
|
-
end
|
435
|
-
assert_nil(rss.channel.textInput)
|
436
|
-
|
437
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
438
|
-
setup_dummy_channel(maker)
|
439
|
-
setup_dummy_image(maker)
|
440
|
-
|
441
|
-
maker.textinput.title = title
|
442
|
-
maker.textinput.description = description
|
443
|
-
# maker.textinput.name = name
|
444
|
-
maker.textinput.link = link
|
445
|
-
end
|
446
|
-
assert_nil(rss.channel.textInput)
|
447
|
-
|
448
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
449
|
-
setup_dummy_channel(maker)
|
450
|
-
setup_dummy_image(maker)
|
451
|
-
|
452
|
-
maker.textinput.title = title
|
453
|
-
maker.textinput.description = description
|
454
|
-
maker.textinput.name = name
|
455
|
-
# maker.textinput.link = link
|
456
|
-
end
|
457
|
-
assert_nil(rss.channel.textInput)
|
458
|
-
end
|
459
|
-
|
460
|
-
def test_date_in_string
|
461
|
-
date = Time.now
|
462
|
-
|
463
|
-
rss = RSS::Maker.make("0.91") do |maker|
|
464
|
-
setup_dummy_channel(maker)
|
465
|
-
setup_dummy_image(maker)
|
466
|
-
|
467
|
-
maker.items.new_item do |item|
|
468
|
-
item.title = "The first item"
|
469
|
-
item.link = "http://example.com/blog/1.html"
|
470
|
-
item.date = date.rfc822
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
assert_equal(date.iso8601, rss.items[0].date.iso8601)
|
475
|
-
end
|
476
|
-
end
|
477
|
-
end
|