rubysl-rss 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/rss.rb +1 -0
- data/lib/rss/0.9.rb +428 -0
- data/lib/rss/1.0.rb +452 -0
- data/lib/rss/2.0.rb +111 -0
- data/lib/rss/atom.rb +749 -0
- data/lib/rss/content.rb +31 -0
- data/lib/rss/content/1.0.rb +10 -0
- data/lib/rss/content/2.0.rb +12 -0
- data/lib/rss/converter.rb +162 -0
- data/lib/rss/dublincore.rb +161 -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 +193 -0
- data/lib/rss/itunes.rb +410 -0
- data/lib/rss/maker.rb +44 -0
- data/lib/rss/maker/0.9.rb +467 -0
- data/lib/rss/maker/1.0.rb +434 -0
- data/lib/rss/maker/2.0.rb +223 -0
- data/lib/rss/maker/atom.rb +172 -0
- data/lib/rss/maker/base.rb +868 -0
- data/lib/rss/maker/content.rb +21 -0
- data/lib/rss/maker/dublincore.rb +124 -0
- data/lib/rss/maker/entry.rb +163 -0
- data/lib/rss/maker/feed.rb +429 -0
- data/lib/rss/maker/image.rb +111 -0
- data/lib/rss/maker/itunes.rb +242 -0
- data/lib/rss/maker/slash.rb +33 -0
- data/lib/rss/maker/syndication.rb +18 -0
- data/lib/rss/maker/taxonomy.rb +118 -0
- data/lib/rss/maker/trackback.rb +61 -0
- data/lib/rss/parser.rb +541 -0
- data/lib/rss/rexmlparser.rb +54 -0
- data/lib/rss/rss.rb +1312 -0
- data/lib/rss/slash.rb +49 -0
- data/lib/rss/syndication.rb +67 -0
- data/lib/rss/taxonomy.rb +145 -0
- data/lib/rss/trackback.rb +288 -0
- data/lib/rss/utils.rb +111 -0
- data/lib/rss/xml-stylesheet.rb +105 -0
- data/lib/rss/xml.rb +71 -0
- data/lib/rss/xmlparser.rb +93 -0
- data/lib/rss/xmlscanner.rb +121 -0
- data/lib/rubysl/rss.rb +2 -0
- data/lib/rubysl/rss/rss.rb +19 -0
- data/lib/rubysl/rss/version.rb +5 -0
- data/rubysl-rss.gemspec +23 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3eb93259d4e044e8483e641f7ffb1061f89eb98
|
4
|
+
data.tar.gz: 4b9d868c45af61dc53c8c1dec751933637003b07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba15661cec3b9b3825a555cd6604aab81a8b0b2067be5b334146e93255821f62ea8603afd2de34d4b7662fa81a9a6405d4b27579540dbce67c1e2d1c59de3142
|
7
|
+
data.tar.gz: c746088480be967b5d4e8491a796af8d8fdbba08563c412634b753afbb1ba608e1b4a088636f045437a9fbd3338fd230e78adaed49e30fd7605808e253d4ac76
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (c) 2013, Brian Shirai
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
3. Neither the name of the library nor the names of its contributors may be
|
13
|
+
used to endorse or promote products derived from this software without
|
14
|
+
specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
|
20
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
21
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
23
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
24
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
25
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Rubysl::Rss
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rubysl-rss'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rubysl-rss
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rss.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "rubysl/rss"
|
data/lib/rss/0.9.rb
ADDED
@@ -0,0 +1,428 @@
|
|
1
|
+
require "rss/parser"
|
2
|
+
|
3
|
+
module RSS
|
4
|
+
|
5
|
+
module RSS09
|
6
|
+
NSPOOL = {}
|
7
|
+
ELEMENTS = []
|
8
|
+
|
9
|
+
def self.append_features(klass)
|
10
|
+
super
|
11
|
+
|
12
|
+
klass.install_must_call_validator('', "")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Rss < Element
|
17
|
+
|
18
|
+
include RSS09
|
19
|
+
include RootElementMixin
|
20
|
+
|
21
|
+
%w(channel).each do |name|
|
22
|
+
install_have_child_element(name, "", nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_writer :feed_version
|
26
|
+
alias_method(:rss_version, :feed_version)
|
27
|
+
alias_method(:rss_version=, :feed_version=)
|
28
|
+
|
29
|
+
def initialize(feed_version, version=nil, encoding=nil, standalone=nil)
|
30
|
+
super
|
31
|
+
@feed_type = "rss"
|
32
|
+
end
|
33
|
+
|
34
|
+
def items
|
35
|
+
if @channel
|
36
|
+
@channel.items
|
37
|
+
else
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def image
|
43
|
+
if @channel
|
44
|
+
@channel.image
|
45
|
+
else
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def textinput
|
51
|
+
if @channel
|
52
|
+
@channel.textInput
|
53
|
+
else
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def setup_maker_elements(maker)
|
59
|
+
super
|
60
|
+
items.each do |item|
|
61
|
+
item.setup_maker(maker.items)
|
62
|
+
end
|
63
|
+
image.setup_maker(maker) if image
|
64
|
+
textinput.setup_maker(maker) if textinput
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def _attrs
|
69
|
+
[
|
70
|
+
["version", true, "feed_version"],
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
class Channel < Element
|
75
|
+
|
76
|
+
include RSS09
|
77
|
+
|
78
|
+
[
|
79
|
+
["title", nil, :text],
|
80
|
+
["link", nil, :text],
|
81
|
+
["description", nil, :text],
|
82
|
+
["language", nil, :text],
|
83
|
+
["copyright", "?", :text],
|
84
|
+
["managingEditor", "?", :text],
|
85
|
+
["webMaster", "?", :text],
|
86
|
+
["rating", "?", :text],
|
87
|
+
["pubDate", "?", :date, :rfc822],
|
88
|
+
["lastBuildDate", "?", :date, :rfc822],
|
89
|
+
["docs", "?", :text],
|
90
|
+
["cloud", "?", :have_attribute],
|
91
|
+
["skipDays", "?", :have_child],
|
92
|
+
["skipHours", "?", :have_child],
|
93
|
+
["image", nil, :have_child],
|
94
|
+
["item", "*", :have_children],
|
95
|
+
["textInput", "?", :have_child],
|
96
|
+
].each do |name, occurs, type, *args|
|
97
|
+
__send__("install_#{type}_element", name, "", occurs, name, *args)
|
98
|
+
end
|
99
|
+
alias date pubDate
|
100
|
+
alias date= pubDate=
|
101
|
+
|
102
|
+
private
|
103
|
+
def maker_target(maker)
|
104
|
+
maker.channel
|
105
|
+
end
|
106
|
+
|
107
|
+
def setup_maker_elements(channel)
|
108
|
+
super
|
109
|
+
[
|
110
|
+
[skipDays, "day"],
|
111
|
+
[skipHours, "hour"],
|
112
|
+
].each do |skip, key|
|
113
|
+
if skip
|
114
|
+
skip.__send__("#{key}s").each do |val|
|
115
|
+
target_skips = channel.__send__("skip#{key.capitalize}s")
|
116
|
+
new_target = target_skips.__send__("new_#{key}")
|
117
|
+
new_target.content = val.content
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def not_need_to_call_setup_maker_variables
|
124
|
+
%w(image textInput)
|
125
|
+
end
|
126
|
+
|
127
|
+
class SkipDays < Element
|
128
|
+
include RSS09
|
129
|
+
|
130
|
+
[
|
131
|
+
["day", "*"]
|
132
|
+
].each do |name, occurs|
|
133
|
+
install_have_children_element(name, "", occurs)
|
134
|
+
end
|
135
|
+
|
136
|
+
class Day < Element
|
137
|
+
include RSS09
|
138
|
+
|
139
|
+
content_setup
|
140
|
+
|
141
|
+
def initialize(*args)
|
142
|
+
if Utils.element_initialize_arguments?(args)
|
143
|
+
super
|
144
|
+
else
|
145
|
+
super()
|
146
|
+
self.content = args[0]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
class SkipHours < Element
|
155
|
+
include RSS09
|
156
|
+
|
157
|
+
[
|
158
|
+
["hour", "*"]
|
159
|
+
].each do |name, occurs|
|
160
|
+
install_have_children_element(name, "", occurs)
|
161
|
+
end
|
162
|
+
|
163
|
+
class Hour < Element
|
164
|
+
include RSS09
|
165
|
+
|
166
|
+
content_setup(:integer)
|
167
|
+
|
168
|
+
def initialize(*args)
|
169
|
+
if Utils.element_initialize_arguments?(args)
|
170
|
+
super
|
171
|
+
else
|
172
|
+
super()
|
173
|
+
self.content = args[0]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
class Image < Element
|
181
|
+
|
182
|
+
include RSS09
|
183
|
+
|
184
|
+
%w(url title link).each do |name|
|
185
|
+
install_text_element(name, "", nil)
|
186
|
+
end
|
187
|
+
[
|
188
|
+
["width", :integer],
|
189
|
+
["height", :integer],
|
190
|
+
["description"],
|
191
|
+
].each do |name, type|
|
192
|
+
install_text_element(name, "", "?", name, type)
|
193
|
+
end
|
194
|
+
|
195
|
+
def initialize(*args)
|
196
|
+
if Utils.element_initialize_arguments?(args)
|
197
|
+
super
|
198
|
+
else
|
199
|
+
super()
|
200
|
+
self.url = args[0]
|
201
|
+
self.title = args[1]
|
202
|
+
self.link = args[2]
|
203
|
+
self.width = args[3]
|
204
|
+
self.height = args[4]
|
205
|
+
self.description = args[5]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
private
|
210
|
+
def maker_target(maker)
|
211
|
+
maker.image
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class Cloud < Element
|
216
|
+
|
217
|
+
include RSS09
|
218
|
+
|
219
|
+
[
|
220
|
+
["domain", "", true],
|
221
|
+
["port", "", true, :integer],
|
222
|
+
["path", "", true],
|
223
|
+
["registerProcedure", "", true],
|
224
|
+
["protocol", "", true],
|
225
|
+
].each do |name, uri, required, type|
|
226
|
+
install_get_attribute(name, uri, required, type)
|
227
|
+
end
|
228
|
+
|
229
|
+
def initialize(*args)
|
230
|
+
if Utils.element_initialize_arguments?(args)
|
231
|
+
super
|
232
|
+
else
|
233
|
+
super()
|
234
|
+
self.domain = args[0]
|
235
|
+
self.port = args[1]
|
236
|
+
self.path = args[2]
|
237
|
+
self.registerProcedure = args[3]
|
238
|
+
self.protocol = args[4]
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
class Item < Element
|
244
|
+
|
245
|
+
include RSS09
|
246
|
+
|
247
|
+
[
|
248
|
+
["title", '?', :text],
|
249
|
+
["link", '?', :text],
|
250
|
+
["description", '?', :text],
|
251
|
+
["category", '*', :have_children, "categories"],
|
252
|
+
["source", '?', :have_child],
|
253
|
+
["enclosure", '?', :have_child],
|
254
|
+
].each do |tag, occurs, type, *args|
|
255
|
+
__send__("install_#{type}_element", tag, "", occurs, tag, *args)
|
256
|
+
end
|
257
|
+
|
258
|
+
private
|
259
|
+
def maker_target(items)
|
260
|
+
if items.respond_to?("items")
|
261
|
+
# For backward compatibility
|
262
|
+
items = items.items
|
263
|
+
end
|
264
|
+
items.new_item
|
265
|
+
end
|
266
|
+
|
267
|
+
def setup_maker_element(item)
|
268
|
+
super
|
269
|
+
@enclosure.setup_maker(item) if @enclosure
|
270
|
+
@source.setup_maker(item) if @source
|
271
|
+
end
|
272
|
+
|
273
|
+
class Source < Element
|
274
|
+
|
275
|
+
include RSS09
|
276
|
+
|
277
|
+
[
|
278
|
+
["url", "", true]
|
279
|
+
].each do |name, uri, required|
|
280
|
+
install_get_attribute(name, uri, required)
|
281
|
+
end
|
282
|
+
|
283
|
+
content_setup
|
284
|
+
|
285
|
+
def initialize(*args)
|
286
|
+
if Utils.element_initialize_arguments?(args)
|
287
|
+
super
|
288
|
+
else
|
289
|
+
super()
|
290
|
+
self.url = args[0]
|
291
|
+
self.content = args[1]
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
private
|
296
|
+
def maker_target(item)
|
297
|
+
item.source
|
298
|
+
end
|
299
|
+
|
300
|
+
def setup_maker_attributes(source)
|
301
|
+
source.url = url
|
302
|
+
source.content = content
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
class Enclosure < Element
|
307
|
+
|
308
|
+
include RSS09
|
309
|
+
|
310
|
+
[
|
311
|
+
["url", "", true],
|
312
|
+
["length", "", true, :integer],
|
313
|
+
["type", "", true],
|
314
|
+
].each do |name, uri, required, type|
|
315
|
+
install_get_attribute(name, uri, required, type)
|
316
|
+
end
|
317
|
+
|
318
|
+
def initialize(*args)
|
319
|
+
if Utils.element_initialize_arguments?(args)
|
320
|
+
super
|
321
|
+
else
|
322
|
+
super()
|
323
|
+
self.url = args[0]
|
324
|
+
self.length = args[1]
|
325
|
+
self.type = args[2]
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
private
|
330
|
+
def maker_target(item)
|
331
|
+
item.enclosure
|
332
|
+
end
|
333
|
+
|
334
|
+
def setup_maker_attributes(enclosure)
|
335
|
+
enclosure.url = url
|
336
|
+
enclosure.length = length
|
337
|
+
enclosure.type = type
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
class Category < Element
|
342
|
+
|
343
|
+
include RSS09
|
344
|
+
|
345
|
+
[
|
346
|
+
["domain", "", false]
|
347
|
+
].each do |name, uri, required|
|
348
|
+
install_get_attribute(name, uri, required)
|
349
|
+
end
|
350
|
+
|
351
|
+
content_setup
|
352
|
+
|
353
|
+
def initialize(*args)
|
354
|
+
if Utils.element_initialize_arguments?(args)
|
355
|
+
super
|
356
|
+
else
|
357
|
+
super()
|
358
|
+
self.domain = args[0]
|
359
|
+
self.content = args[1]
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
private
|
364
|
+
def maker_target(item)
|
365
|
+
item.new_category
|
366
|
+
end
|
367
|
+
|
368
|
+
def setup_maker_attributes(category)
|
369
|
+
category.domain = domain
|
370
|
+
category.content = content
|
371
|
+
end
|
372
|
+
|
373
|
+
end
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
class TextInput < Element
|
378
|
+
|
379
|
+
include RSS09
|
380
|
+
|
381
|
+
%w(title description name link).each do |name|
|
382
|
+
install_text_element(name, "", nil)
|
383
|
+
end
|
384
|
+
|
385
|
+
def initialize(*args)
|
386
|
+
if Utils.element_initialize_arguments?(args)
|
387
|
+
super
|
388
|
+
else
|
389
|
+
super()
|
390
|
+
self.title = args[0]
|
391
|
+
self.description = args[1]
|
392
|
+
self.name = args[2]
|
393
|
+
self.link = args[3]
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
private
|
398
|
+
def maker_target(maker)
|
399
|
+
maker.textinput
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
end
|
406
|
+
|
407
|
+
RSS09::ELEMENTS.each do |name|
|
408
|
+
BaseListener.install_get_text_element("", name, name)
|
409
|
+
end
|
410
|
+
|
411
|
+
module ListenerMixin
|
412
|
+
private
|
413
|
+
def initial_start_rss(tag_name, prefix, attrs, ns)
|
414
|
+
check_ns(tag_name, prefix, ns, "")
|
415
|
+
|
416
|
+
@rss = Rss.new(attrs['version'], @version, @encoding, @standalone)
|
417
|
+
@rss.do_validate = @do_validate
|
418
|
+
@rss.xml_stylesheets = @xml_stylesheets
|
419
|
+
@last_element = @rss
|
420
|
+
pr = Proc.new do |text, tags|
|
421
|
+
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
|
422
|
+
end
|
423
|
+
@proc_stack.push(pr)
|
424
|
+
end
|
425
|
+
|
426
|
+
end
|
427
|
+
|
428
|
+
end
|