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_image.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerImage < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://web.resource.org/rss/1.0/modules/image/"
|
11
|
-
|
12
|
-
@favicon_infos = {
|
13
|
-
"about" => "http://www.kuro5hin.org/favicon.ico",
|
14
|
-
"image_size" => "small",
|
15
|
-
"dc_title" => "example",
|
16
|
-
}
|
17
|
-
@item_infos = {
|
18
|
-
"about" => "http://www.example.org/item.png",
|
19
|
-
"resource" => "http://www.example.org/item",
|
20
|
-
"dc_title" => "Example Image",
|
21
|
-
"image_width" => "100",
|
22
|
-
"image_height" => "65",
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_rss10
|
27
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
28
|
-
setup_dummy_channel(maker)
|
29
|
-
@favicon_infos.each do |name, value|
|
30
|
-
maker.channel.image_favicon.__send__("#{name}=", value)
|
31
|
-
end
|
32
|
-
|
33
|
-
setup_dummy_image(maker)
|
34
|
-
|
35
|
-
setup_dummy_item(maker)
|
36
|
-
item = maker.items.last
|
37
|
-
@item_infos.each do |name, value|
|
38
|
-
item.image_item.__send__("#{name}=", value)
|
39
|
-
end
|
40
|
-
|
41
|
-
setup_dummy_textinput(maker)
|
42
|
-
end
|
43
|
-
|
44
|
-
setup_rss = RSS::Maker.make("1.0") do |maker|
|
45
|
-
rss.setup_maker(maker)
|
46
|
-
end
|
47
|
-
|
48
|
-
[rss, setup_rss].each_with_index do |target, i|
|
49
|
-
favicon = target.channel.image_favicon
|
50
|
-
assert_equal(@favicon_infos["about"], favicon.about)
|
51
|
-
assert_equal(@favicon_infos["image_size"], favicon.image_size)
|
52
|
-
assert_equal(@favicon_infos["dc_title"], favicon.dc_title)
|
53
|
-
|
54
|
-
item = target.items.last.image_item
|
55
|
-
assert_equal(@item_infos["about"], item.about)
|
56
|
-
assert_equal(@item_infos["resource"], item.resource)
|
57
|
-
assert_equal(@item_infos["image_width"].to_i, item.image_width)
|
58
|
-
assert_equal(@item_infos["image_height"].to_i, item.image_height)
|
59
|
-
assert_equal(@item_infos["dc_title"], item.dc_title)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/test/test_maker_itunes.rb
DELETED
@@ -1,488 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerITunes < TestCase
|
8
|
-
def test_author
|
9
|
-
assert_maker_itunes_author(%w(channel))
|
10
|
-
assert_maker_itunes_author(%w(items last))
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_block
|
14
|
-
assert_maker_itunes_block(%w(channel))
|
15
|
-
assert_maker_itunes_block(%w(items last))
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_category
|
19
|
-
assert_maker_itunes_category(%w(channel))
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_image
|
23
|
-
assert_maker_itunes_image(%w(channel))
|
24
|
-
assert_maker_itunes_image(%w(items last))
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_duration
|
28
|
-
assert_maker_itunes_duration(%w(items last))
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_explicit
|
32
|
-
assert_maker_itunes_explicit(%w(channel))
|
33
|
-
assert_maker_itunes_explicit(%w(items last))
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_keywords
|
37
|
-
assert_maker_itunes_keywords(%w(channel))
|
38
|
-
assert_maker_itunes_keywords(%w(items last))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_new_feed_url
|
42
|
-
assert_maker_itunes_new_feed_url(%w(channel))
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_owner
|
46
|
-
assert_maker_itunes_owner(%w(channel))
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_subtitle
|
50
|
-
assert_maker_itunes_subtitle(%w(channel))
|
51
|
-
assert_maker_itunes_subtitle(%w(items last))
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_summary
|
55
|
-
assert_maker_itunes_summary(%w(channel))
|
56
|
-
assert_maker_itunes_summary(%w(items last))
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def assert_maker_itunes_author(maker_readers, feed_readers=nil)
|
62
|
-
_wrap_assertion do
|
63
|
-
feed_readers ||= maker_readers
|
64
|
-
author = "John Doe"
|
65
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
66
|
-
setup_dummy_channel(maker)
|
67
|
-
setup_dummy_item(maker)
|
68
|
-
|
69
|
-
target = chain_reader(maker, maker_readers)
|
70
|
-
target.itunes_author = author
|
71
|
-
end
|
72
|
-
target = chain_reader(rss20, feed_readers)
|
73
|
-
assert_equal(author, target.itunes_author)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def _assert_maker_itunes_block(value, boolean_value, maker_readers,
|
78
|
-
feed_readers)
|
79
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
80
|
-
setup_dummy_channel(maker)
|
81
|
-
setup_dummy_item(maker)
|
82
|
-
|
83
|
-
target = chain_reader(maker, maker_readers)
|
84
|
-
target.itunes_block = value
|
85
|
-
assert_equal(value, target.itunes_block)
|
86
|
-
assert_equal(boolean_value, target.itunes_block?)
|
87
|
-
end
|
88
|
-
target = chain_reader(rss20, feed_readers)
|
89
|
-
if [true, false].include?(value)
|
90
|
-
value = value ? "yes" : "no"
|
91
|
-
end
|
92
|
-
assert_equal(value, target.itunes_block)
|
93
|
-
assert_equal(boolean_value, target.itunes_block?)
|
94
|
-
end
|
95
|
-
|
96
|
-
def assert_maker_itunes_block(maker_readers, feed_readers=nil)
|
97
|
-
_wrap_assertion do
|
98
|
-
feed_readers ||= maker_readers
|
99
|
-
_assert_maker_itunes_block("yes", true, maker_readers, feed_readers)
|
100
|
-
_assert_maker_itunes_block("Yes", true, maker_readers, feed_readers)
|
101
|
-
_assert_maker_itunes_block("no", false, maker_readers, feed_readers)
|
102
|
-
_assert_maker_itunes_block("", false, maker_readers, feed_readers)
|
103
|
-
_assert_maker_itunes_block(true, true, maker_readers, feed_readers)
|
104
|
-
_assert_maker_itunes_block(false, false, maker_readers, feed_readers)
|
105
|
-
_assert_maker_itunes_block(nil, false, maker_readers, feed_readers)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def _assert_maker_itunes_category(categories, maker_readers, feed_readers)
|
110
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
111
|
-
setup_dummy_channel(maker)
|
112
|
-
setup_dummy_item(maker)
|
113
|
-
|
114
|
-
target = chain_reader(maker, maker_readers)
|
115
|
-
categories.each do |category|
|
116
|
-
sub_target = target.itunes_categories
|
117
|
-
if category.is_a?(Array)
|
118
|
-
category.each do |sub_category|
|
119
|
-
sub_target = sub_target.new_category
|
120
|
-
sub_target.text = sub_category
|
121
|
-
end
|
122
|
-
else
|
123
|
-
sub_target.new_category.text = category
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
target = chain_reader(rss20, feed_readers)
|
129
|
-
actual_categories = target.itunes_categories.collect do |category|
|
130
|
-
cat = category.text
|
131
|
-
if category.itunes_categories.empty?
|
132
|
-
cat
|
133
|
-
else
|
134
|
-
[cat, *category.itunes_categories.collect {|c| c.text}]
|
135
|
-
end
|
136
|
-
end
|
137
|
-
assert_equal(categories, actual_categories)
|
138
|
-
end
|
139
|
-
|
140
|
-
def assert_maker_itunes_category(maker_readers, feed_readers=nil)
|
141
|
-
_wrap_assertion do
|
142
|
-
feed_readers ||= maker_readers
|
143
|
-
_assert_maker_itunes_category(["Audio Blogs"],
|
144
|
-
maker_readers, feed_readers)
|
145
|
-
_assert_maker_itunes_category([["Arts & Entertainment", "Games"]],
|
146
|
-
maker_readers, feed_readers)
|
147
|
-
_assert_maker_itunes_category([["Arts & Entertainment", "Games"],
|
148
|
-
["Technology", "Computers"],
|
149
|
-
"Audio Blogs"],
|
150
|
-
maker_readers, feed_readers)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def assert_maker_itunes_image(maker_readers, feed_readers=nil)
|
155
|
-
_wrap_assertion do
|
156
|
-
feed_readers ||= maker_readers
|
157
|
-
url = "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
158
|
-
|
159
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
160
|
-
setup_dummy_channel(maker)
|
161
|
-
setup_dummy_item(maker)
|
162
|
-
|
163
|
-
target = chain_reader(maker, maker_readers)
|
164
|
-
target.itunes_image = url
|
165
|
-
end
|
166
|
-
|
167
|
-
target = chain_reader(rss20, feed_readers)
|
168
|
-
assert_not_nil(target.itunes_image)
|
169
|
-
assert_equal(url, target.itunes_image.href)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def _assert_maker_itunes_duration(hour, minute, second, value,
|
174
|
-
maker_readers, feed_readers)
|
175
|
-
_assert_maker_itunes_duration_by_value(hour, minute, second, value,
|
176
|
-
maker_readers, feed_readers)
|
177
|
-
_assert_maker_itunes_duration_by_hour_minute_second(hour, minute, second,
|
178
|
-
value,
|
179
|
-
maker_readers,
|
180
|
-
feed_readers)
|
181
|
-
end
|
182
|
-
|
183
|
-
def _assert_maker_itunes_duration_by(hour, minute, second, value,
|
184
|
-
maker_readers, feed_readers)
|
185
|
-
expected_value = nil
|
186
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
187
|
-
setup_dummy_channel(maker)
|
188
|
-
setup_dummy_item(maker)
|
189
|
-
|
190
|
-
target = chain_reader(maker, maker_readers)
|
191
|
-
expected_value = yield(target)
|
192
|
-
assert_equal(expected_value, target.itunes_duration)
|
193
|
-
target.itunes_duration do |duration|
|
194
|
-
assert_equal([hour, minute, second, expected_value],
|
195
|
-
[duration.hour, duration.minute,
|
196
|
-
duration.second, duration.content])
|
197
|
-
end
|
198
|
-
end
|
199
|
-
target = chain_reader(rss20, feed_readers)
|
200
|
-
duration = target.itunes_duration
|
201
|
-
assert_not_nil(duration)
|
202
|
-
assert_equal([hour, minute, second, expected_value],
|
203
|
-
[duration.hour, duration.minute,
|
204
|
-
duration.second, duration.content])
|
205
|
-
end
|
206
|
-
|
207
|
-
def _assert_maker_itunes_duration_by_value(hour, minute, second, value,
|
208
|
-
maker_readers, feed_readers)
|
209
|
-
_assert_maker_itunes_duration_by(hour, minute, second, value,
|
210
|
-
maker_readers, feed_readers) do |target|
|
211
|
-
target.itunes_duration = value
|
212
|
-
value
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
def _assert_maker_itunes_duration_by_hour_minute_second(hour, minute, second,
|
217
|
-
value,
|
218
|
-
maker_readers,
|
219
|
-
feed_readers)
|
220
|
-
_assert_maker_itunes_duration_by(hour, minute, second, value,
|
221
|
-
maker_readers, feed_readers) do |target|
|
222
|
-
target.itunes_duration do |duration|
|
223
|
-
duration.hour = hour
|
224
|
-
duration.minute = minute
|
225
|
-
duration.second = second
|
226
|
-
end
|
227
|
-
value.split(":").collect {|v| "%02d" % v.to_i}.join(":")
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
def _assert_maker_itunes_duration_invalid_value(value, maker_readers)
|
232
|
-
assert_raise(ArgumentError) do
|
233
|
-
::RSS::Maker.make("rss2.0") do |maker|
|
234
|
-
setup_dummy_channel(maker)
|
235
|
-
setup_dummy_item(maker)
|
236
|
-
|
237
|
-
target = chain_reader(maker, maker_readers)
|
238
|
-
target.itunes_duration = value
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
def assert_maker_itunes_duration(maker_readers, feed_readers=nil)
|
244
|
-
_wrap_assertion do
|
245
|
-
feed_readers ||= maker_readers
|
246
|
-
_assert_maker_itunes_duration(7, 14, 5, "07:14:05", maker_readers,
|
247
|
-
feed_readers)
|
248
|
-
_assert_maker_itunes_duration(7, 14, 5, "7:14:05", maker_readers,
|
249
|
-
feed_readers)
|
250
|
-
_assert_maker_itunes_duration(0, 4, 55, "04:55", maker_readers,
|
251
|
-
feed_readers)
|
252
|
-
_assert_maker_itunes_duration(0, 4, 5, "4:05", maker_readers,
|
253
|
-
feed_readers)
|
254
|
-
_assert_maker_itunes_duration(0, 0, 5, "0:05", maker_readers,
|
255
|
-
feed_readers)
|
256
|
-
_assert_maker_itunes_duration_by_value(0, 5, 15, "315", maker_readers,
|
257
|
-
feed_readers)
|
258
|
-
_assert_maker_itunes_duration_by_value(1, 0, 1, "3601", maker_readers,
|
259
|
-
feed_readers)
|
260
|
-
|
261
|
-
_assert_maker_itunes_duration_invalid_value("09:07:14:05", maker_readers)
|
262
|
-
_assert_maker_itunes_duration_invalid_value("10:5", maker_readers)
|
263
|
-
_assert_maker_itunes_duration_invalid_value("10:03:5", maker_readers)
|
264
|
-
_assert_maker_itunes_duration_invalid_value("10:3:05", maker_readers)
|
265
|
-
|
266
|
-
_assert_maker_itunes_duration_invalid_value("xx:xx:xx", maker_readers)
|
267
|
-
|
268
|
-
_assert_maker_itunes_duration_invalid_value("", maker_readers)
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def _assert_maker_itunes_explicit(explicit, value,
|
273
|
-
maker_readers, feed_readers)
|
274
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
275
|
-
setup_dummy_channel(maker)
|
276
|
-
setup_dummy_item(maker)
|
277
|
-
|
278
|
-
target = chain_reader(maker, maker_readers)
|
279
|
-
target.itunes_explicit = value
|
280
|
-
assert_equal(explicit, target.itunes_explicit?)
|
281
|
-
end
|
282
|
-
target = chain_reader(rss20, feed_readers)
|
283
|
-
assert_equal(value, target.itunes_explicit)
|
284
|
-
assert_equal(explicit, target.itunes_explicit?)
|
285
|
-
end
|
286
|
-
|
287
|
-
def assert_maker_itunes_explicit(maker_readers, feed_readers=nil)
|
288
|
-
_wrap_assertion do
|
289
|
-
feed_readers ||= maker_readers
|
290
|
-
_assert_maker_itunes_explicit(true, "explicit",
|
291
|
-
maker_readers, feed_readers)
|
292
|
-
_assert_maker_itunes_explicit(true, "yes",
|
293
|
-
maker_readers, feed_readers)
|
294
|
-
_assert_maker_itunes_explicit(true, "true",
|
295
|
-
maker_readers, feed_readers)
|
296
|
-
_assert_maker_itunes_explicit(false, "clean",
|
297
|
-
maker_readers, feed_readers)
|
298
|
-
_assert_maker_itunes_explicit(false, "no",
|
299
|
-
maker_readers, feed_readers)
|
300
|
-
_assert_maker_itunes_explicit(false, "false",
|
301
|
-
maker_readers, feed_readers)
|
302
|
-
_assert_maker_itunes_explicit(nil, "invalid",
|
303
|
-
maker_readers, feed_readers)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
def _assert_maker_itunes_keywords(keywords, value,
|
308
|
-
maker_readers, feed_readers)
|
309
|
-
_assert_maker_itunes_keywords_by_value(keywords, value,
|
310
|
-
maker_readers, feed_readers)
|
311
|
-
_assert_maker_itunes_keywords_by_keywords(keywords, maker_readers,
|
312
|
-
feed_readers)
|
313
|
-
end
|
314
|
-
|
315
|
-
def _assert_maker_itunes_keywords_by(keywords, maker_readers, feed_readers)
|
316
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
317
|
-
setup_dummy_channel(maker)
|
318
|
-
setup_dummy_item(maker)
|
319
|
-
|
320
|
-
target = chain_reader(maker, maker_readers)
|
321
|
-
yield(target)
|
322
|
-
end
|
323
|
-
assert_nothing_raised do
|
324
|
-
rss20 = ::RSS::Parser.parse(rss20.to_s)
|
325
|
-
end
|
326
|
-
target = chain_reader(rss20, feed_readers)
|
327
|
-
assert_equal(keywords, target.itunes_keywords)
|
328
|
-
end
|
329
|
-
|
330
|
-
def _assert_maker_itunes_keywords_by_value(keywords, value,
|
331
|
-
maker_readers, feed_readers)
|
332
|
-
_assert_maker_itunes_keywords_by(keywords, maker_readers,
|
333
|
-
feed_readers) do |target|
|
334
|
-
target.itunes_keywords = value
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
def _assert_maker_itunes_keywords_by_keywords(keywords,
|
339
|
-
maker_readers, feed_readers)
|
340
|
-
_assert_maker_itunes_keywords_by(keywords, maker_readers,
|
341
|
-
feed_readers) do |target|
|
342
|
-
target.itunes_keywords = keywords
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
def assert_maker_itunes_keywords(maker_readers, feed_readers=nil)
|
347
|
-
_wrap_assertion do
|
348
|
-
feed_readers ||= maker_readers
|
349
|
-
_assert_maker_itunes_keywords(["salt"], "salt",
|
350
|
-
maker_readers, feed_readers)
|
351
|
-
_assert_maker_itunes_keywords(["salt"], " salt ",
|
352
|
-
maker_readers, feed_readers)
|
353
|
-
_assert_maker_itunes_keywords(["salt", "pepper", "shaker", "exciting"],
|
354
|
-
"salt, pepper, shaker, exciting",
|
355
|
-
maker_readers, feed_readers)
|
356
|
-
_assert_maker_itunes_keywords(["metric", "socket", "wrenches",
|
357
|
-
"toolsalt"],
|
358
|
-
"metric, socket, wrenches, toolsalt",
|
359
|
-
maker_readers, feed_readers)
|
360
|
-
_assert_maker_itunes_keywords(["olitics", "red", "blue", "state"],
|
361
|
-
"olitics, red, blue, state",
|
362
|
-
maker_readers, feed_readers)
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
def assert_maker_itunes_new_feed_url(maker_readers, feed_readers=nil)
|
367
|
-
feed_readers ||= maker_readers
|
368
|
-
url = "http://newlocation.com/example.rss"
|
369
|
-
|
370
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
371
|
-
setup_dummy_channel(maker)
|
372
|
-
setup_dummy_item(maker)
|
373
|
-
|
374
|
-
target = chain_reader(maker, maker_readers)
|
375
|
-
target.itunes_new_feed_url = url
|
376
|
-
end
|
377
|
-
target = chain_reader(rss20, feed_readers)
|
378
|
-
assert_equal(url, target.itunes_new_feed_url)
|
379
|
-
end
|
380
|
-
|
381
|
-
def _assert_maker_itunes_owner(name, email, maker_readers, feed_readers)
|
382
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
383
|
-
setup_dummy_channel(maker)
|
384
|
-
setup_dummy_item(maker)
|
385
|
-
|
386
|
-
target = chain_reader(maker, maker_readers)
|
387
|
-
owner = target.itunes_owner
|
388
|
-
owner.itunes_name = name
|
389
|
-
owner.itunes_email = email
|
390
|
-
end
|
391
|
-
owner = chain_reader(rss20, feed_readers).itunes_owner
|
392
|
-
if name.nil? and email.nil?
|
393
|
-
assert_nil(owner)
|
394
|
-
else
|
395
|
-
assert_not_nil(owner)
|
396
|
-
assert_equal(name, owner.itunes_name)
|
397
|
-
assert_equal(email, owner.itunes_email)
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
def assert_maker_itunes_owner(maker_readers, feed_readers=nil)
|
402
|
-
_wrap_assertion do
|
403
|
-
feed_readers ||= maker_readers
|
404
|
-
_assert_maker_itunes_owner("John Doe", "john.doe@example.com",
|
405
|
-
maker_readers, feed_readers)
|
406
|
-
|
407
|
-
not_set_name = (["maker"] + maker_readers + ["itunes_owner"]).join(".")
|
408
|
-
assert_not_set_error(not_set_name, ["itunes_name"]) do
|
409
|
-
_assert_maker_itunes_owner(nil, "john.doe@example.com",
|
410
|
-
maker_readers, feed_readers)
|
411
|
-
end
|
412
|
-
assert_not_set_error(not_set_name, ["itunes_email"]) do
|
413
|
-
_assert_maker_itunes_owner("John Doe", nil,
|
414
|
-
maker_readers, feed_readers)
|
415
|
-
end
|
416
|
-
|
417
|
-
_assert_maker_itunes_owner(nil, nil, maker_readers, feed_readers)
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
def _assert_maker_itunes_subtitle(subtitle, maker_readers, feed_readers)
|
422
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
423
|
-
setup_dummy_channel(maker)
|
424
|
-
setup_dummy_item(maker)
|
425
|
-
|
426
|
-
target = chain_reader(maker, maker_readers)
|
427
|
-
target.itunes_subtitle = subtitle
|
428
|
-
end
|
429
|
-
|
430
|
-
target = chain_reader(rss20, feed_readers)
|
431
|
-
assert_equal(subtitle, target.itunes_subtitle)
|
432
|
-
end
|
433
|
-
|
434
|
-
def assert_maker_itunes_subtitle(maker_readers, feed_readers=nil)
|
435
|
-
_wrap_assertion do
|
436
|
-
feed_readers ||= maker_readers
|
437
|
-
_assert_maker_itunes_subtitle("A show about everything",
|
438
|
-
maker_readers, feed_readers)
|
439
|
-
_assert_maker_itunes_subtitle("A short primer on table spices",
|
440
|
-
maker_readers, feed_readers)
|
441
|
-
_assert_maker_itunes_subtitle("Comparing socket wrenches is fun!",
|
442
|
-
maker_readers, feed_readers)
|
443
|
-
_assert_maker_itunes_subtitle("Red + Blue != Purple",
|
444
|
-
maker_readers, feed_readers)
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
def _assert_maker_itunes_summary(summary, maker_readers, feed_readers)
|
449
|
-
rss20 = ::RSS::Maker.make("rss2.0") do |maker|
|
450
|
-
setup_dummy_channel(maker)
|
451
|
-
setup_dummy_item(maker)
|
452
|
-
|
453
|
-
target = chain_reader(maker, maker_readers)
|
454
|
-
target.itunes_summary = summary
|
455
|
-
end
|
456
|
-
|
457
|
-
target = chain_reader(rss20, feed_readers)
|
458
|
-
assert_equal(summary, target.itunes_summary)
|
459
|
-
end
|
460
|
-
|
461
|
-
def assert_maker_itunes_summary(maker_readers, feed_readers=nil)
|
462
|
-
_wrap_assertion do
|
463
|
-
feed_readers ||= maker_readers
|
464
|
-
_assert_maker_itunes_summary("All About Everything is a show about " +
|
465
|
-
"everything. Each week we dive into any " +
|
466
|
-
"subject known to man and talk about it " +
|
467
|
-
"as much as we can. Look for our Podcast " +
|
468
|
-
"in the iTunes Music Store",
|
469
|
-
maker_readers, feed_readers)
|
470
|
-
_assert_maker_itunes_summary("This week we talk about salt and pepper " +
|
471
|
-
"shakers, comparing and contrasting pour " +
|
472
|
-
"rates, construction materials, and " +
|
473
|
-
"overall aesthetics. Come and join the " +
|
474
|
-
"party!",
|
475
|
-
maker_readers, feed_readers)
|
476
|
-
_assert_maker_itunes_summary("This week we talk about metric vs. old " +
|
477
|
-
"english socket wrenches. Which one is " +
|
478
|
-
"better? Do you really need both? Get " +
|
479
|
-
"all of your answers here.",
|
480
|
-
maker_readers, feed_readers)
|
481
|
-
_assert_maker_itunes_summary("This week we talk about surviving in a " +
|
482
|
-
"Red state if you're a Blue person. Or " +
|
483
|
-
"vice versa.",
|
484
|
-
maker_readers, feed_readers)
|
485
|
-
end
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
data/test/test_maker_slash.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerSlash < TestCase
|
8
|
-
def setup
|
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
|
-
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("slash_#{name}=", value)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
item = rss.items.last
|
29
|
-
assert_not_nil(item)
|
30
|
-
assert_slash_elements(item)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def assert_slash_elements(target)
|
35
|
-
super(@elements, target)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/test/test_maker_sy.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMakerSyndication < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@uri = "http://purl.org/rss/1.0/modules/syndication/"
|
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
|
-
:updatePeriod => "hourly",
|
19
|
-
:updateFrequency => "2",
|
20
|
-
:updateBase => t,
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_rss10
|
25
|
-
rss = RSS::Maker.make("1.0") do |maker|
|
26
|
-
setup_dummy_channel(maker)
|
27
|
-
set_elements(maker.channel)
|
28
|
-
setup_dummy_item(maker)
|
29
|
-
end
|
30
|
-
assert_syndication(@elements, rss.channel)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def accessor_name(name)
|
35
|
-
"sy_#{name}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def set_elements(target)
|
39
|
-
@elements.each do |name, value|
|
40
|
-
target.__send__("#{accessor_name(name)}=", value)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|