1 | require "rss/2.0"
|
---|
2 |
|
---|
3 | require "rss/maker/0.9"
|
---|
4 |
|
---|
5 | module RSS
|
---|
6 | module Maker
|
---|
7 |
|
---|
8 | class RSS20 < RSS09
|
---|
9 |
|
---|
10 | def initialize(rss_version="2.0")
|
---|
11 | super
|
---|
12 | end
|
---|
13 |
|
---|
14 | class Channel < RSS09::Channel
|
---|
15 |
|
---|
16 | def have_required_values?
|
---|
17 | @title and @link and @description
|
---|
18 | end
|
---|
19 |
|
---|
20 | def required_variable_names
|
---|
21 | %w(title link description)
|
---|
22 | end
|
---|
23 |
|
---|
24 | class SkipDays < RSS09::Channel::SkipDays
|
---|
25 | class Day < RSS09::Channel::SkipDays::Day
|
---|
26 | end
|
---|
27 | end
|
---|
28 |
|
---|
29 | class SkipHours < RSS09::Channel::SkipHours
|
---|
30 | class Hour < RSS09::Channel::SkipHours::Hour
|
---|
31 | end
|
---|
32 | end
|
---|
33 |
|
---|
34 | class Cloud < RSS09::Channel::Cloud
|
---|
35 | def to_rss(rss, channel)
|
---|
36 | cloud = Rss::Channel::Cloud.new
|
---|
37 | set = setup_values(cloud)
|
---|
38 | if set
|
---|
39 | channel.cloud = cloud
|
---|
40 | setup_other_elements(rss)
|
---|
41 | end
|
---|
42 | end
|
---|
43 |
|
---|
44 | def have_required_values?
|
---|
45 | @domain and @port and @path and
|
---|
46 | @registerProcedure and @protocol
|
---|
47 | end
|
---|
48 | end
|
---|
49 |
|
---|
50 | class Categories < RSS09::Channel::Categories
|
---|
51 | def to_rss(rss, channel)
|
---|
52 | @categories.each do |category|
|
---|
53 | category.to_rss(rss, channel)
|
---|
54 | end
|
---|
55 | end
|
---|
56 |
|
---|
57 | class Category < RSS09::Channel::Categories::Category
|
---|
58 | def to_rss(rss, channel)
|
---|
59 | category = Rss::Channel::Category.new
|
---|
60 | set = setup_values(category)
|
---|
61 | if set
|
---|
62 | channel.categories << category
|
---|
63 | setup_other_elements(rss)
|
---|
64 | end
|
---|
65 | end
|
---|
66 |
|
---|
67 | def have_required_values?
|
---|
68 | @content
|
---|
69 | end
|
---|
70 | end
|
---|
71 | end
|
---|
72 |
|
---|
73 | end
|
---|
74 |
|
---|
75 | class Image < RSS09::Image
|
---|
76 | end
|
---|
77 |
|
---|
78 | class Items < RSS09::Items
|
---|
79 |
|
---|
80 | class Item < RSS09::Items::Item
|
---|
81 |
|
---|
82 | def have_required_values?
|
---|
83 | @title or @description
|
---|
84 | end
|
---|
85 |
|
---|
86 | private
|
---|
87 | def variables
|
---|
88 | super + ["pubDate"]
|
---|
89 | end
|
---|
90 |
|
---|
91 | class Guid < RSS09::Items::Item::Guid
|
---|
92 | def to_rss(rss, item)
|
---|
93 | guid = Rss::Channel::Item::Guid.new
|
---|
94 | set = setup_values(guid)
|
---|
95 | if set
|
---|
96 | item.guid = guid
|
---|
97 | setup_other_elements(rss)
|
---|
98 | end
|
---|
99 | end
|
---|
100 |
|
---|
101 | def have_required_values?
|
---|
102 | @content
|
---|
103 | end
|
---|
104 | end
|
---|
105 |
|
---|
106 | class Enclosure < RSS09::Items::Item::Enclosure
|
---|
107 | def to_rss(rss, item)
|
---|
108 | enclosure = Rss::Channel::Item::Enclosure.new
|
---|
109 | set = setup_values(enclosure)
|
---|
110 | if set
|
---|
111 | item.enclosure = enclosure
|
---|
112 | setup_other_elements(rss)
|
---|
113 | end
|
---|
114 | end
|
---|
115 |
|
---|
116 | def have_required_values?
|
---|
117 | @url and @length and @type
|
---|
118 | end
|
---|
119 | end
|
---|
120 |
|
---|
121 | class Source < RSS09::Items::Item::Source
|
---|
122 | def to_rss(rss, item)
|
---|
123 | source = Rss::Channel::Item::Source.new
|
---|
124 | set = setup_values(source)
|
---|
125 | if set
|
---|
126 | item.source = source
|
---|
127 | setup_other_elements(rss)
|
---|
128 | end
|
---|
129 | end
|
---|
130 |
|
---|
131 | def have_required_values?
|
---|
132 | @url and @content
|
---|
133 | end
|
---|
134 | end
|
---|
135 |
|
---|
136 | class Categories < RSS09::Items::Item::Categories
|
---|
137 | def to_rss(rss, item)
|
---|
138 | @categories.each do |category|
|
---|
139 | category.to_rss(rss, item)
|
---|
140 | end
|
---|
141 | end
|
---|
142 |
|
---|
143 | class Category < RSS09::Items::Item::Categories::Category
|
---|
144 | def to_rss(rss, item)
|
---|
145 | category = Rss::Channel::Item::Category.new
|
---|
146 | set = setup_values(category)
|
---|
147 | if set
|
---|
148 | item.categories << category
|
---|
149 | setup_other_elements(rss)
|
---|
150 | end
|
---|
151 | end
|
---|
152 |
|
---|
153 | def have_required_values?
|
---|
154 | @content
|
---|
155 | end
|
---|
156 | end
|
---|
157 | end
|
---|
158 | end
|
---|
159 |
|
---|
160 | end
|
---|
161 |
|
---|
162 | class Textinput < RSS09::Textinput
|
---|
163 | end
|
---|
164 | end
|
---|
165 |
|
---|
166 | add_maker(filename_to_version(__FILE__), RSS20)
|
---|
167 | end
|
---|
168 | end
|
---|