blob: 11f518ca2728b582632506c9aa0f9b0f2f039c07 (
plain)
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
224
225
226
|
require "rss/0.9"
require "rss/maker/base"
module RSS
module Maker
class RSS09 < RSSBase
def initialize(rss_version="0.91")
super
end
def to_rss
rss = Rss.new(@rss_version, @version, @encoding, @standalone)
setup_xml_stylesheets(rss)
setup_channel(rss)
setup_other_elements(rss)
if rss.channel
rss
else
nil
end
end
private
def setup_channel(rss)
@channel.to_rss(rss)
end
class Channel < ChannelBase
def to_rss(rss)
channel = Rss::Channel.new
set = setup_values(channel)
if set
rss.channel = channel
setup_items(rss)
setup_image(rss)
setup_textinput(rss)
setup_other_elements(rss)
if rss.channel.image
rss
else
nil
end
end
end
def have_required_values?
@title and @link and @description and @language
end
private
def setup_items(rss)
@maker.items.to_rss(rss)
end
def setup_image(rss)
@maker.image.to_rss(rss)
end
def setup_textinput(rss)
@maker.textinput.to_rss(rss)
end
def variables
super + ["pubDate"]
end
class SkipDays < SkipDaysBase
def to_rss(rss, channel)
unless @days.empty?
skipDays = Rss::Channel::SkipDays.new
channel.skipDays = skipDays
@days.each do |day|
day.to_rss(rss, skipDays.days)
end
end
end
class Day < DayBase
def to_rss(rss, days)
day = Rss::Channel::SkipDays::Day.new
set = setup_values(day)
if set
days << day
setup_other_elements(rss)
end
end
def have_required_values?
@content
end
end
end
class SkipHours < SkipHoursBase
def to_rss(rss, channel)
unless @hours.empty?
skipHours = Rss::Channel::SkipHours.new
channel.skipHours = skipHours
@hours.each do |hour|
hour.to_rss(rss, skipHours.hours)
end
end
end
class Hour < HourBase
def to_rss(rss, hours)
hour = Rss::Channel::SkipHours::Hour.new
set = setup_values(hour)
if set
hours << hour
setup_other_elements(rss)
end
end
def have_required_values?
@content
end
end
end
class Cloud < CloudBase
def to_rss(*args)
end
end
class Categories < CategoriesBase
def to_rss(*args)
end
class Category < CategoryBase
end
end
end
class Image < ImageBase
def to_rss(rss)
image = Rss::Channel::Image.new
set = setup_values(image)
if set
image.link = link
rss.channel.image = image
setup_other_elements(rss)
end
end
def have_required_values?
@url and @title and link
end
end
class Items < ItemsBase
def to_rss(rss)
if rss.channel
normalize.each do |item|
item.to_rss(rss)
end
setup_other_elements(rss)
end
end
class Item < ItemBase
def to_rss(rss)
item = Rss::Channel::Item.new
set = setup_values(item)
if set
rss.items << item
setup_other_elements(rss)
end
end
private
def have_required_values?
@title and @link
end
class Guid < GuidBase
def to_rss(*args)
end
end
class Enclosure < EnclosureBase
def to_rss(*args)
end
end
class Source < SourceBase
def to_rss(*args)
end
end
class Categories < CategoriesBase
def to_rss(*args)
end
class Category < CategoryBase
end
end
end
end
class Textinput < TextinputBase
def to_rss(rss)
textInput = Rss::Channel::TextInput.new
set = setup_values(textInput)
if set
rss.channel.textInput = textInput
setup_other_elements(rss)
end
end
private
def have_required_values?
@title and @description and @name and @link
end
end
end
add_maker(filename_to_version(__FILE__), RSS09)
add_maker(filename_to_version(__FILE__) + "1", RSS09)
end
end
|