rss 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rss.rb +92 -0
- data/lib/rss/0.9.rb +462 -0
- data/lib/rss/1.0.rb +485 -0
- data/lib/rss/2.0.rb +143 -0
- data/lib/rss/atom.rb +1025 -0
- data/lib/rss/content.rb +34 -0
- data/lib/rss/content/1.0.rb +10 -0
- data/lib/rss/content/2.0.rb +12 -0
- data/lib/rss/converter.rb +171 -0
- data/lib/rss/dublincore.rb +164 -0
- data/lib/rss/dublincore/1.0.rb +13 -0
- data/lib/rss/dublincore/2.0.rb +13 -0
- data/lib/rss/dublincore/atom.rb +17 -0
- data/lib/rss/image.rb +198 -0
- data/lib/rss/itunes.rb +413 -0
- data/lib/rss/maker.rb +79 -0
- data/lib/rss/maker/0.9.rb +509 -0
- data/lib/rss/maker/1.0.rb +436 -0
- data/lib/rss/maker/2.0.rb +224 -0
- data/lib/rss/maker/atom.rb +173 -0
- data/lib/rss/maker/base.rb +945 -0
- data/lib/rss/maker/content.rb +22 -0
- data/lib/rss/maker/dublincore.rb +122 -0
- data/lib/rss/maker/entry.rb +164 -0
- data/lib/rss/maker/feed.rb +427 -0
- data/lib/rss/maker/image.rb +112 -0
- data/lib/rss/maker/itunes.rb +243 -0
- data/lib/rss/maker/slash.rb +34 -0
- data/lib/rss/maker/syndication.rb +19 -0
- data/lib/rss/maker/taxonomy.rb +119 -0
- data/lib/rss/maker/trackback.rb +62 -0
- data/lib/rss/parser.rb +589 -0
- data/lib/rss/rexmlparser.rb +50 -0
- data/lib/rss/rss.rb +1346 -0
- data/lib/rss/slash.rb +52 -0
- data/lib/rss/syndication.rb +69 -0
- data/lib/rss/taxonomy.rb +148 -0
- data/lib/rss/trackback.rb +291 -0
- data/lib/rss/utils.rb +200 -0
- data/lib/rss/xml-stylesheet.rb +106 -0
- data/lib/rss/xml.rb +72 -0
- data/lib/rss/xmlparser.rb +95 -0
- data/lib/rss/xmlscanner.rb +122 -0
- data/rss.gemspec +38 -0
- metadata +138 -0
@@ -0,0 +1,509 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
require_relative "../0.9"
|
3
|
+
|
4
|
+
require_relative "base"
|
5
|
+
|
6
|
+
module RSS
|
7
|
+
module Maker
|
8
|
+
|
9
|
+
class RSS09 < RSSBase
|
10
|
+
|
11
|
+
def initialize(feed_version)
|
12
|
+
super
|
13
|
+
@feed_type = "rss"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def make_feed
|
18
|
+
Rss.new(@feed_version, @version, @encoding, @standalone)
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup_elements(rss)
|
22
|
+
setup_channel(rss)
|
23
|
+
end
|
24
|
+
|
25
|
+
class Channel < ChannelBase
|
26
|
+
def to_feed(rss)
|
27
|
+
channel = Rss::Channel.new
|
28
|
+
setup_values(channel)
|
29
|
+
_not_set_required_variables = not_set_required_variables
|
30
|
+
if _not_set_required_variables.empty?
|
31
|
+
rss.channel = channel
|
32
|
+
set_parent(channel, rss)
|
33
|
+
setup_items(rss)
|
34
|
+
setup_image(rss)
|
35
|
+
setup_textinput(rss)
|
36
|
+
setup_other_elements(rss, channel)
|
37
|
+
rss
|
38
|
+
else
|
39
|
+
raise NotSetError.new("maker.channel", _not_set_required_variables)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def setup_items(rss)
|
45
|
+
@maker.items.to_feed(rss)
|
46
|
+
end
|
47
|
+
|
48
|
+
def setup_image(rss)
|
49
|
+
@maker.image.to_feed(rss)
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup_textinput(rss)
|
53
|
+
@maker.textinput.to_feed(rss)
|
54
|
+
end
|
55
|
+
|
56
|
+
def variables
|
57
|
+
super + ["pubDate"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def required_variable_names
|
61
|
+
%w(link language)
|
62
|
+
end
|
63
|
+
|
64
|
+
def not_set_required_variables
|
65
|
+
vars = super
|
66
|
+
vars << "description" unless description {|d| d.have_required_values?}
|
67
|
+
vars << "title" unless title {|t| t.have_required_values?}
|
68
|
+
vars
|
69
|
+
end
|
70
|
+
|
71
|
+
class SkipDays < SkipDaysBase
|
72
|
+
def to_feed(rss, channel)
|
73
|
+
unless @days.empty?
|
74
|
+
skipDays = Rss::Channel::SkipDays.new
|
75
|
+
channel.skipDays = skipDays
|
76
|
+
set_parent(skipDays, channel)
|
77
|
+
@days.each do |day|
|
78
|
+
day.to_feed(rss, skipDays.days)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Day < DayBase
|
84
|
+
def to_feed(rss, days)
|
85
|
+
day = Rss::Channel::SkipDays::Day.new
|
86
|
+
set = setup_values(day)
|
87
|
+
if set
|
88
|
+
days << day
|
89
|
+
set_parent(day, days)
|
90
|
+
setup_other_elements(rss, day)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def required_variable_names
|
96
|
+
%w(content)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class SkipHours < SkipHoursBase
|
102
|
+
def to_feed(rss, channel)
|
103
|
+
unless @hours.empty?
|
104
|
+
skipHours = Rss::Channel::SkipHours.new
|
105
|
+
channel.skipHours = skipHours
|
106
|
+
set_parent(skipHours, channel)
|
107
|
+
@hours.each do |hour|
|
108
|
+
hour.to_feed(rss, skipHours.hours)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class Hour < HourBase
|
114
|
+
def to_feed(rss, hours)
|
115
|
+
hour = Rss::Channel::SkipHours::Hour.new
|
116
|
+
set = setup_values(hour)
|
117
|
+
if set
|
118
|
+
hours << hour
|
119
|
+
set_parent(hour, hours)
|
120
|
+
setup_other_elements(rss, hour)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
def required_variable_names
|
126
|
+
%w(content)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Cloud < CloudBase
|
132
|
+
def to_feed(*args)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class Categories < CategoriesBase
|
137
|
+
def to_feed(*args)
|
138
|
+
end
|
139
|
+
|
140
|
+
class Category < CategoryBase
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class Links < LinksBase
|
145
|
+
def to_feed(rss, channel)
|
146
|
+
return if @links.empty?
|
147
|
+
@links.first.to_feed(rss, channel)
|
148
|
+
end
|
149
|
+
|
150
|
+
class Link < LinkBase
|
151
|
+
def to_feed(rss, channel)
|
152
|
+
if have_required_values?
|
153
|
+
channel.link = href
|
154
|
+
else
|
155
|
+
raise NotSetError.new("maker.channel.link",
|
156
|
+
not_set_required_variables)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
def required_variable_names
|
162
|
+
%w(href)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
class Authors < AuthorsBase
|
168
|
+
def to_feed(rss, channel)
|
169
|
+
end
|
170
|
+
|
171
|
+
class Author < AuthorBase
|
172
|
+
def to_feed(rss, channel)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
class Contributors < ContributorsBase
|
178
|
+
def to_feed(rss, channel)
|
179
|
+
end
|
180
|
+
|
181
|
+
class Contributor < ContributorBase
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class Generator < GeneratorBase
|
186
|
+
def to_feed(rss, channel)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class Copyright < CopyrightBase
|
191
|
+
def to_feed(rss, channel)
|
192
|
+
channel.copyright = content if have_required_values?
|
193
|
+
end
|
194
|
+
|
195
|
+
private
|
196
|
+
def required_variable_names
|
197
|
+
%w(content)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
class Description < DescriptionBase
|
202
|
+
def to_feed(rss, channel)
|
203
|
+
channel.description = content if have_required_values?
|
204
|
+
end
|
205
|
+
|
206
|
+
private
|
207
|
+
def required_variable_names
|
208
|
+
%w(content)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
class Title < TitleBase
|
213
|
+
def to_feed(rss, channel)
|
214
|
+
channel.title = content if have_required_values?
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
def required_variable_names
|
219
|
+
%w(content)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class Image < ImageBase
|
225
|
+
def to_feed(rss)
|
226
|
+
image = Rss::Channel::Image.new
|
227
|
+
set = setup_values(image)
|
228
|
+
if set
|
229
|
+
image.link = link
|
230
|
+
rss.channel.image = image
|
231
|
+
set_parent(image, rss.channel)
|
232
|
+
setup_other_elements(rss, image)
|
233
|
+
elsif required_element?
|
234
|
+
raise NotSetError.new("maker.image", not_set_required_variables)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
private
|
239
|
+
def required_variable_names
|
240
|
+
%w(url title link)
|
241
|
+
end
|
242
|
+
|
243
|
+
def required_element?
|
244
|
+
true
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
class Items < ItemsBase
|
249
|
+
def to_feed(rss)
|
250
|
+
if rss.channel
|
251
|
+
normalize.each do |item|
|
252
|
+
item.to_feed(rss)
|
253
|
+
end
|
254
|
+
setup_other_elements(rss, rss.items)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
class Item < ItemBase
|
259
|
+
def to_feed(rss)
|
260
|
+
item = Rss::Channel::Item.new
|
261
|
+
setup_values(item)
|
262
|
+
_not_set_required_variables = not_set_required_variables
|
263
|
+
if _not_set_required_variables.empty?
|
264
|
+
rss.items << item
|
265
|
+
set_parent(item, rss.channel)
|
266
|
+
setup_other_elements(rss, item)
|
267
|
+
elsif variable_is_set?
|
268
|
+
raise NotSetError.new("maker.items", _not_set_required_variables)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
private
|
273
|
+
def required_variable_names
|
274
|
+
[]
|
275
|
+
end
|
276
|
+
|
277
|
+
def not_set_required_variables
|
278
|
+
vars = super
|
279
|
+
if @maker.feed_version == "0.91"
|
280
|
+
vars << "title" unless title {|t| t.have_required_values?}
|
281
|
+
vars << "link" unless link {|l| l.have_required_values?}
|
282
|
+
end
|
283
|
+
vars
|
284
|
+
end
|
285
|
+
|
286
|
+
class Guid < GuidBase
|
287
|
+
def to_feed(*args)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
class Enclosure < EnclosureBase
|
292
|
+
def to_feed(*args)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
class Source < SourceBase
|
297
|
+
def to_feed(*args)
|
298
|
+
end
|
299
|
+
|
300
|
+
class Authors < AuthorsBase
|
301
|
+
def to_feed(*args)
|
302
|
+
end
|
303
|
+
|
304
|
+
class Author < AuthorBase
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
class Categories < CategoriesBase
|
309
|
+
def to_feed(*args)
|
310
|
+
end
|
311
|
+
|
312
|
+
class Category < CategoryBase
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
class Contributors < ContributorsBase
|
317
|
+
def to_feed(*args)
|
318
|
+
end
|
319
|
+
|
320
|
+
class Contributor < ContributorBase
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
class Generator < GeneratorBase
|
325
|
+
def to_feed(*args)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
class Icon < IconBase
|
330
|
+
def to_feed(*args)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
class Links < LinksBase
|
335
|
+
def to_feed(*args)
|
336
|
+
end
|
337
|
+
|
338
|
+
class Link < LinkBase
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
class Logo < LogoBase
|
343
|
+
def to_feed(*args)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
class Rights < RightsBase
|
348
|
+
def to_feed(*args)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
class Subtitle < SubtitleBase
|
353
|
+
def to_feed(*args)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
class Title < TitleBase
|
358
|
+
def to_feed(*args)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
class Categories < CategoriesBase
|
364
|
+
def to_feed(*args)
|
365
|
+
end
|
366
|
+
|
367
|
+
class Category < CategoryBase
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
class Authors < AuthorsBase
|
372
|
+
def to_feed(*args)
|
373
|
+
end
|
374
|
+
|
375
|
+
class Author < AuthorBase
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
class Links < LinksBase
|
380
|
+
def to_feed(rss, item)
|
381
|
+
return if @links.empty?
|
382
|
+
@links.first.to_feed(rss, item)
|
383
|
+
end
|
384
|
+
|
385
|
+
class Link < LinkBase
|
386
|
+
def to_feed(rss, item)
|
387
|
+
if have_required_values?
|
388
|
+
item.link = href
|
389
|
+
else
|
390
|
+
raise NotSetError.new("maker.link",
|
391
|
+
not_set_required_variables)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
private
|
396
|
+
def required_variable_names
|
397
|
+
%w(href)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
class Contributors < ContributorsBase
|
403
|
+
def to_feed(rss, item)
|
404
|
+
end
|
405
|
+
|
406
|
+
class Contributor < ContributorBase
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
class Rights < RightsBase
|
411
|
+
def to_feed(rss, item)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
class Description < DescriptionBase
|
416
|
+
def to_feed(rss, item)
|
417
|
+
item.description = content if have_required_values?
|
418
|
+
end
|
419
|
+
|
420
|
+
private
|
421
|
+
def required_variable_names
|
422
|
+
%w(content)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
class Content < ContentBase
|
427
|
+
def to_feed(rss, item)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
class Title < TitleBase
|
432
|
+
def to_feed(rss, item)
|
433
|
+
item.title = content if have_required_values?
|
434
|
+
end
|
435
|
+
|
436
|
+
private
|
437
|
+
def required_variable_names
|
438
|
+
%w(content)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
class Textinput < TextinputBase
|
445
|
+
def to_feed(rss)
|
446
|
+
textInput = Rss::Channel::TextInput.new
|
447
|
+
set = setup_values(textInput)
|
448
|
+
if set
|
449
|
+
rss.channel.textInput = textInput
|
450
|
+
set_parent(textInput, rss.channel)
|
451
|
+
setup_other_elements(rss, textInput)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
private
|
456
|
+
def required_variable_names
|
457
|
+
%w(title description name link)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
class RSS091 < RSS09
|
463
|
+
def initialize(feed_version="0.91")
|
464
|
+
super
|
465
|
+
end
|
466
|
+
|
467
|
+
class Channel < RSS09::Channel
|
468
|
+
end
|
469
|
+
|
470
|
+
class Items < RSS09::Items
|
471
|
+
class Item < RSS09::Items::Item
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
class Image < RSS09::Image
|
476
|
+
end
|
477
|
+
|
478
|
+
class Textinput < RSS09::Textinput
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
class RSS092 < RSS09
|
483
|
+
def initialize(feed_version="0.92")
|
484
|
+
super
|
485
|
+
end
|
486
|
+
|
487
|
+
class Channel < RSS09::Channel
|
488
|
+
end
|
489
|
+
|
490
|
+
class Items < RSS09::Items
|
491
|
+
class Item < RSS09::Items::Item
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
class Image < RSS09::Image
|
496
|
+
end
|
497
|
+
|
498
|
+
class Textinput < RSS09::Textinput
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
add_maker("0.9", "0.92", RSS092)
|
503
|
+
add_maker("0.91", "0.91", RSS091)
|
504
|
+
add_maker("0.92", "0.92", RSS092)
|
505
|
+
add_maker("rss0.9", "0.92", RSS092)
|
506
|
+
add_maker("rss0.91", "0.91", RSS091)
|
507
|
+
add_maker("rss0.92", "0.92", RSS092)
|
508
|
+
end
|
509
|
+
end
|