1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
require "rss/2.0"
require "rss/maker/0.9"
module RSS
module Maker
class RSS20 < RSS09
def initialize(feed_version="2.0")
super
end
class Channel < RSS09::Channel
private
def required_variable_names
%w(link)
end
class SkipDays < RSS09::Channel::SkipDays
class Day < RSS09::Channel::SkipDays::Day
end
end
class SkipHours < RSS09::Channel::SkipHours
class Hour < RSS09::Channel::SkipHours::Hour
end
end
class Cloud < RSS09::Channel::Cloud
def to_feed(rss, channel)
cloud = Rss::Channel::Cloud.new
set = setup_values(cloud)
if set
channel.cloud = cloud
set_parent(cloud, channel)
setup_other_elements(rss, cloud)
end
end
private
def required_variable_names
%w(domain port path registerProcedure protocol)
end
end
class Categories < RSS09::Channel::Categories
def to_feed(rss, channel)
@categories.each do |category|
category.to_feed(rss, channel)
end
end
class Category < RSS09::Channel::Categories::Category
def to_feed(rss, channel)
category = Rss::Channel::Category.new
set = setup_values(category)
if set
channel.categories << category
set_parent(category, channel)
setup_other_elements(rss, category)
end
end
private
def required_variable_names
%w(content)
end
end
end
class Generator < GeneratorBase
def to_feed(rss, channel)
channel.generator = content
end
private
def required_variable_names
%w(content)
end
end
end
class Image < RSS09::Image
private
def required_element?
false
end
end
class Items < RSS09::Items
class Item < RSS09::Items::Item
private
def required_variable_names
[]
end
def not_set_required_variables
vars = super
if !title {|t| t.have_required_values?} and
!description {|d| d.have_required_values?}
vars << "title or description"
end
vars
end
def variables
super + ["pubDate"]
end
class Guid < RSS09::Items::Item::Guid
def to_feed(rss, item)
guid = Rss::Channel::Item::Guid.new
set = setup_values(guid)
if set
item.guid = guid
set_parent(guid, item)
setup_other_elements(rss, guid)
end
end
private
def required_variable_names
%w(content)
end
end
class Enclosure < RSS09::Items::Item::Enclosure
def to_feed(rss, item)
enclosure = Rss::Channel::Item::Enclosure.new
set = setup_values(enclosure)
if set
item.enclosure = enclosure
set_parent(enclosure, item)
setup_other_elements(rss, enclosure)
end
end
private
def required_variable_names
%w(url length type)
end
end
class Source < RSS09::Items::Item::Source
def to_feed(rss, item)
source = Rss::Channel::Item::Source.new
set = setup_values(source)
if set
item.source = source
set_parent(source, item)
setup_other_elements(rss, source)
end
end
private
def required_variable_names
%w(url content)
end
class Links < RSS09::Items::Item::Source::Links
def to_feed(rss, source)
return if @links.empty?
@links.first.to_feed(rss, source)
end
class Link < RSS09::Items::Item::Source::Links::Link
def to_feed(rss, source)
source.url = href
end
end
end
end
class Categories < RSS09::Items::Item::Categories
def to_feed(rss, item)
@categories.each do |category|
category.to_feed(rss, item)
end
end
class Category < RSS09::Items::Item::Categories::Category
def to_feed(rss, item)
category = Rss::Channel::Item::Category.new
set = setup_values(category)
if set
item.categories << category
set_parent(category, item)
setup_other_elements(rss)
end
end
private
def required_variable_names
%w(content)
end
end
end
class Authors < RSS09::Items::Item::Authors
def to_feed(rss, item)
return if @authors.empty?
@authors.first.to_feed(rss, item)
end
class Author < RSS09::Items::Item::Authors::Author
def to_feed(rss, item)
item.author = name
end
end
end
end
end
class Textinput < RSS09::Textinput
end
end
add_maker("2.0", "2.0", RSS20)
add_maker("rss2.0", "2.0", RSS20)
end
end
|