rss 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b4c9e9539fc75445348d13247c59875480824315e591a4158caf8938438bee34
|
4
|
+
data.tar.gz: 4b923e608e3079bd8bffe3c5c8dcc5ad347a5bb1e53808ac0f74a0db0177a36e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1734f6dc142b58b73635d354bf78fe9273b7252c2f5fa8bc49859ead33ba27c520009c2d85985ef2f730ff83963f3e06a556a304d3d25adacca139b0c8aa1068
|
7
|
+
data.tar.gz: daaff41773cd97a209eff268b587a38191b824eb130005d5a740431279a8828a0cf57157c24cdecd8d6c01032e2271941cc5151559f6cca08352b3e7f40d8a48
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# RSS
|
2
|
+
|
3
|
+
Really Simple Syndication (RSS) is a family of formats that describe 'feeds,' specially constructed XML documents that allow an interested person to subscribe and receive updates from a particular web service. This portion of the standard library provides tooling to read and create these feeds.
|
4
|
+
|
5
|
+
The standard library supports RSS 0.91, 1.0, 2.0, and Atom, a related format. Here are some links to the standards documents for these formats:
|
6
|
+
|
7
|
+
* RSS
|
8
|
+
* 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape]
|
9
|
+
* 1.0[http://web.resource.org/rss/1.0/]
|
10
|
+
* 2.0[http://www.rssboard.org/rss-specification]
|
11
|
+
* Atom[http://tools.ietf.org/html/rfc4287]
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rss'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install rss
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Consuming RSS
|
32
|
+
|
33
|
+
If you'd like to read someone's RSS feed with your Ruby code, you've come to the right place. It's really easy to do this, but we'll need the help of open-uri:
|
34
|
+
|
35
|
+
```
|
36
|
+
require 'rss'
|
37
|
+
require 'open-uri'
|
38
|
+
|
39
|
+
url = 'http://www.ruby-lang.org/en/feeds/news.rss'
|
40
|
+
open(url) do |rss|
|
41
|
+
feed = RSS::Parser.parse(rss)
|
42
|
+
puts "Title: #{feed.channel.title}"
|
43
|
+
feed.items.each do |item|
|
44
|
+
puts "Item: #{item.title}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
As you can see, the workhorse is RSS::Parser#parse, which takes the source of the feed and a parameter that performs validation on the feed. We get back an object that has all of the data from our feed, accessible through methods. This example shows getting the title out of the channel element, and looping through the list of items.
|
50
|
+
|
51
|
+
### Producing RSS
|
52
|
+
|
53
|
+
Producing our own RSS feeds is easy as well. Let's make a very basic feed:
|
54
|
+
|
55
|
+
```
|
56
|
+
require "rss"
|
57
|
+
|
58
|
+
rss = RSS::Maker.make("atom") do |maker|
|
59
|
+
maker.channel.author = "matz"
|
60
|
+
maker.channel.updated = Time.now.to_s
|
61
|
+
maker.channel.about = "http://www.ruby-lang.org/en/feeds/news.rss"
|
62
|
+
maker.channel.title = "Example Feed"
|
63
|
+
|
64
|
+
maker.items.new_item do |item|
|
65
|
+
item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
|
66
|
+
item.title = "Ruby 1.9.2-p136 is released"
|
67
|
+
item.updated = Time.now.to_s
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
puts rss
|
72
|
+
```
|
73
|
+
|
74
|
+
As you can see, this is a very Builder-like DSL. This code will spit out an Atom feed with one item. If we needed a second item, we'd make another block with maker.items.new_item and build a second one.
|
75
|
+
|
76
|
+
## Development
|
77
|
+
|
78
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
79
|
+
|
80
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/rss.
|
85
|
+
|
86
|
+
## License
|
87
|
+
|
88
|
+
The gem is available as open source under the terms of the [BSD-2-Clause](LICENSE.txt).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rss"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rss.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
##
|
3
|
+
# = RSS reading and writing
|
4
|
+
#
|
5
|
+
# Really Simple Syndication (RSS) is a family of formats that describe 'feeds,'
|
6
|
+
# specially constructed XML documents that allow an interested person to
|
7
|
+
# subscribe and receive updates from a particular web service. This portion of
|
8
|
+
# the standard library provides tooling to read and create these feeds.
|
9
|
+
#
|
10
|
+
# The standard library supports RSS 0.91, 1.0, 2.0, and Atom, a related format.
|
11
|
+
# Here are some links to the standards documents for these formats:
|
12
|
+
#
|
13
|
+
# * RSS
|
14
|
+
# * 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape]
|
15
|
+
# * 1.0[http://web.resource.org/rss/1.0/]
|
16
|
+
# * 2.0[http://www.rssboard.org/rss-specification]
|
17
|
+
# * Atom[http://tools.ietf.org/html/rfc4287]
|
18
|
+
#
|
19
|
+
# == Consuming RSS
|
20
|
+
#
|
21
|
+
# If you'd like to read someone's RSS feed with your Ruby code, you've come to
|
22
|
+
# the right place. It's really easy to do this, but we'll need the help of
|
23
|
+
# open-uri:
|
24
|
+
#
|
25
|
+
# require 'rss'
|
26
|
+
# require 'open-uri'
|
27
|
+
#
|
28
|
+
# url = 'http://www.ruby-lang.org/en/feeds/news.rss'
|
29
|
+
# open(url) do |rss|
|
30
|
+
# feed = RSS::Parser.parse(rss)
|
31
|
+
# puts "Title: #{feed.channel.title}"
|
32
|
+
# feed.items.each do |item|
|
33
|
+
# puts "Item: #{item.title}"
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# As you can see, the workhorse is RSS::Parser#parse, which takes the source of
|
38
|
+
# the feed and a parameter that performs validation on the feed. We get back an
|
39
|
+
# object that has all of the data from our feed, accessible through methods.
|
40
|
+
# This example shows getting the title out of the channel element, and looping
|
41
|
+
# through the list of items.
|
42
|
+
#
|
43
|
+
# == Producing RSS
|
44
|
+
#
|
45
|
+
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
|
46
|
+
#
|
47
|
+
# require "rss"
|
48
|
+
#
|
49
|
+
# rss = RSS::Maker.make("atom") do |maker|
|
50
|
+
# maker.channel.author = "matz"
|
51
|
+
# maker.channel.updated = Time.now.to_s
|
52
|
+
# maker.channel.about = "http://www.ruby-lang.org/en/feeds/news.rss"
|
53
|
+
# maker.channel.title = "Example Feed"
|
54
|
+
#
|
55
|
+
# maker.items.new_item do |item|
|
56
|
+
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
|
57
|
+
# item.title = "Ruby 1.9.2-p136 is released"
|
58
|
+
# item.updated = Time.now.to_s
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# puts rss
|
63
|
+
#
|
64
|
+
# As you can see, this is a very Builder-like DSL. This code will spit out an
|
65
|
+
# Atom feed with one item. If we needed a second item, we'd make another block
|
66
|
+
# with maker.items.new_item and build a second one.
|
67
|
+
#
|
68
|
+
# == Copyright
|
69
|
+
#
|
70
|
+
# Copyright (c) 2003-2007 Kouhei Sutou <kou@cozmixng.org>
|
71
|
+
#
|
72
|
+
# You can redistribute it and/or modify it under the same terms as Ruby.
|
73
|
+
#
|
74
|
+
# There is an additional tutorial by the author of RSS at:
|
75
|
+
# http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en
|
76
|
+
|
77
|
+
module RSS
|
78
|
+
end
|
79
|
+
|
80
|
+
require 'rss/1.0'
|
81
|
+
require 'rss/2.0'
|
82
|
+
require 'rss/atom'
|
83
|
+
require 'rss/content'
|
84
|
+
require 'rss/dublincore'
|
85
|
+
require 'rss/image'
|
86
|
+
require 'rss/itunes'
|
87
|
+
require 'rss/slash'
|
88
|
+
require 'rss/syndication'
|
89
|
+
require 'rss/taxonomy'
|
90
|
+
require 'rss/trackback'
|
91
|
+
|
92
|
+
require "rss/maker"
|
data/lib/rss/0.9.rb
ADDED
@@ -0,0 +1,462 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
require_relative "parser"
|
3
|
+
|
4
|
+
module RSS
|
5
|
+
|
6
|
+
##
|
7
|
+
# = RSS 0.9 support
|
8
|
+
#
|
9
|
+
# RSS has three different versions. This module contains support for version
|
10
|
+
# 0.9.1[http://www.rssboard.org/rss-0-9-1-netscape].
|
11
|
+
#
|
12
|
+
# == Producing RSS 0.9
|
13
|
+
#
|
14
|
+
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
|
15
|
+
#
|
16
|
+
# require "rss"
|
17
|
+
#
|
18
|
+
# rss = RSS::Maker.make("0.91") do |maker|
|
19
|
+
# maker.channel.language = "en"
|
20
|
+
# maker.channel.author = "matz"
|
21
|
+
# maker.channel.updated = Time.now.to_s
|
22
|
+
# maker.channel.link = "http://www.ruby-lang.org/en/feeds/news.rss"
|
23
|
+
# maker.channel.title = "Example Feed"
|
24
|
+
# maker.channel.description = "A longer description of my feed."
|
25
|
+
# maker.image.url = "http://www.ruby-lang.org/images/logo.gif"
|
26
|
+
# maker.image.title = "An image"
|
27
|
+
# maker.items.new_item do |item|
|
28
|
+
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
|
29
|
+
# item.title = "Ruby 1.9.2-p136 is released"
|
30
|
+
# item.updated = Time.now.to_s
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# puts rss
|
35
|
+
#
|
36
|
+
# As you can see, this is a very Builder-like DSL. This code will spit out an
|
37
|
+
# RSS 0.9 feed with one item. If we needed a second item, we'd make another
|
38
|
+
# block with maker.items.new_item and build a second one.
|
39
|
+
module RSS09
|
40
|
+
NSPOOL = {}
|
41
|
+
ELEMENTS = []
|
42
|
+
|
43
|
+
def self.append_features(klass)
|
44
|
+
super
|
45
|
+
|
46
|
+
klass.install_must_call_validator('', "")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Rss < Element
|
51
|
+
|
52
|
+
include RSS09
|
53
|
+
include RootElementMixin
|
54
|
+
|
55
|
+
%w(channel).each do |name|
|
56
|
+
install_have_child_element(name, "", nil)
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_writer :feed_version
|
60
|
+
alias_method(:rss_version, :feed_version)
|
61
|
+
alias_method(:rss_version=, :feed_version=)
|
62
|
+
|
63
|
+
def initialize(feed_version, version=nil, encoding=nil, standalone=nil)
|
64
|
+
super
|
65
|
+
@feed_type = "rss"
|
66
|
+
end
|
67
|
+
|
68
|
+
def items
|
69
|
+
if @channel
|
70
|
+
@channel.items
|
71
|
+
else
|
72
|
+
[]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def image
|
77
|
+
if @channel
|
78
|
+
@channel.image
|
79
|
+
else
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def textinput
|
85
|
+
if @channel
|
86
|
+
@channel.textInput
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def setup_maker_elements(maker)
|
93
|
+
super
|
94
|
+
items.each do |item|
|
95
|
+
item.setup_maker(maker.items)
|
96
|
+
end
|
97
|
+
image.setup_maker(maker) if image
|
98
|
+
textinput.setup_maker(maker) if textinput
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def _attrs
|
103
|
+
[
|
104
|
+
["version", true, "feed_version"],
|
105
|
+
]
|
106
|
+
end
|
107
|
+
|
108
|
+
class Channel < Element
|
109
|
+
|
110
|
+
include RSS09
|
111
|
+
|
112
|
+
[
|
113
|
+
["title", nil, :text],
|
114
|
+
["link", nil, :text],
|
115
|
+
["description", nil, :text],
|
116
|
+
["language", nil, :text],
|
117
|
+
["copyright", "?", :text],
|
118
|
+
["managingEditor", "?", :text],
|
119
|
+
["webMaster", "?", :text],
|
120
|
+
["rating", "?", :text],
|
121
|
+
["pubDate", "?", :date, :rfc822],
|
122
|
+
["lastBuildDate", "?", :date, :rfc822],
|
123
|
+
["docs", "?", :text],
|
124
|
+
["cloud", "?", :have_attribute],
|
125
|
+
["skipDays", "?", :have_child],
|
126
|
+
["skipHours", "?", :have_child],
|
127
|
+
["image", nil, :have_child],
|
128
|
+
["item", "*", :have_children],
|
129
|
+
["textInput", "?", :have_child],
|
130
|
+
].each do |name, occurs, type, *args|
|
131
|
+
__send__("install_#{type}_element", name, "", occurs, name, *args)
|
132
|
+
end
|
133
|
+
alias date pubDate
|
134
|
+
alias date= pubDate=
|
135
|
+
|
136
|
+
private
|
137
|
+
def maker_target(maker)
|
138
|
+
maker.channel
|
139
|
+
end
|
140
|
+
|
141
|
+
def setup_maker_elements(channel)
|
142
|
+
super
|
143
|
+
[
|
144
|
+
[skipDays, "day"],
|
145
|
+
[skipHours, "hour"],
|
146
|
+
].each do |skip, key|
|
147
|
+
if skip
|
148
|
+
skip.__send__("#{key}s").each do |val|
|
149
|
+
target_skips = channel.__send__("skip#{key.capitalize}s")
|
150
|
+
new_target = target_skips.__send__("new_#{key}")
|
151
|
+
new_target.content = val.content
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def not_need_to_call_setup_maker_variables
|
158
|
+
%w(image textInput)
|
159
|
+
end
|
160
|
+
|
161
|
+
class SkipDays < Element
|
162
|
+
include RSS09
|
163
|
+
|
164
|
+
[
|
165
|
+
["day", "*"]
|
166
|
+
].each do |name, occurs|
|
167
|
+
install_have_children_element(name, "", occurs)
|
168
|
+
end
|
169
|
+
|
170
|
+
class Day < Element
|
171
|
+
include RSS09
|
172
|
+
|
173
|
+
content_setup
|
174
|
+
|
175
|
+
def initialize(*args)
|
176
|
+
if Utils.element_initialize_arguments?(args)
|
177
|
+
super
|
178
|
+
else
|
179
|
+
super()
|
180
|
+
self.content = args[0]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
class SkipHours < Element
|
189
|
+
include RSS09
|
190
|
+
|
191
|
+
[
|
192
|
+
["hour", "*"]
|
193
|
+
].each do |name, occurs|
|
194
|
+
install_have_children_element(name, "", occurs)
|
195
|
+
end
|
196
|
+
|
197
|
+
class Hour < Element
|
198
|
+
include RSS09
|
199
|
+
|
200
|
+
content_setup(:integer)
|
201
|
+
|
202
|
+
def initialize(*args)
|
203
|
+
if Utils.element_initialize_arguments?(args)
|
204
|
+
super
|
205
|
+
else
|
206
|
+
super()
|
207
|
+
self.content = args[0]
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
class Image < Element
|
215
|
+
|
216
|
+
include RSS09
|
217
|
+
|
218
|
+
%w(url title link).each do |name|
|
219
|
+
install_text_element(name, "", nil)
|
220
|
+
end
|
221
|
+
[
|
222
|
+
["width", :integer],
|
223
|
+
["height", :integer],
|
224
|
+
["description"],
|
225
|
+
].each do |name, type|
|
226
|
+
install_text_element(name, "", "?", name, type)
|
227
|
+
end
|
228
|
+
|
229
|
+
def initialize(*args)
|
230
|
+
if Utils.element_initialize_arguments?(args)
|
231
|
+
super
|
232
|
+
else
|
233
|
+
super()
|
234
|
+
self.url = args[0]
|
235
|
+
self.title = args[1]
|
236
|
+
self.link = args[2]
|
237
|
+
self.width = args[3]
|
238
|
+
self.height = args[4]
|
239
|
+
self.description = args[5]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
private
|
244
|
+
def maker_target(maker)
|
245
|
+
maker.image
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
class Cloud < Element
|
250
|
+
|
251
|
+
include RSS09
|
252
|
+
|
253
|
+
[
|
254
|
+
["domain", "", true],
|
255
|
+
["port", "", true, :integer],
|
256
|
+
["path", "", true],
|
257
|
+
["registerProcedure", "", true],
|
258
|
+
["protocol", "", true],
|
259
|
+
].each do |name, uri, required, type|
|
260
|
+
install_get_attribute(name, uri, required, type)
|
261
|
+
end
|
262
|
+
|
263
|
+
def initialize(*args)
|
264
|
+
if Utils.element_initialize_arguments?(args)
|
265
|
+
super
|
266
|
+
else
|
267
|
+
super()
|
268
|
+
self.domain = args[0]
|
269
|
+
self.port = args[1]
|
270
|
+
self.path = args[2]
|
271
|
+
self.registerProcedure = args[3]
|
272
|
+
self.protocol = args[4]
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
class Item < Element
|
278
|
+
|
279
|
+
include RSS09
|
280
|
+
|
281
|
+
[
|
282
|
+
["title", '?', :text],
|
283
|
+
["link", '?', :text],
|
284
|
+
["description", '?', :text],
|
285
|
+
["category", '*', :have_children, "categories"],
|
286
|
+
["source", '?', :have_child],
|
287
|
+
["enclosure", '?', :have_child],
|
288
|
+
].each do |tag, occurs, type, *args|
|
289
|
+
__send__("install_#{type}_element", tag, "", occurs, tag, *args)
|
290
|
+
end
|
291
|
+
|
292
|
+
private
|
293
|
+
def maker_target(items)
|
294
|
+
if items.respond_to?("items")
|
295
|
+
# For backward compatibility
|
296
|
+
items = items.items
|
297
|
+
end
|
298
|
+
items.new_item
|
299
|
+
end
|
300
|
+
|
301
|
+
def setup_maker_element(item)
|
302
|
+
super
|
303
|
+
@enclosure.setup_maker(item) if @enclosure
|
304
|
+
@source.setup_maker(item) if @source
|
305
|
+
end
|
306
|
+
|
307
|
+
class Source < Element
|
308
|
+
|
309
|
+
include RSS09
|
310
|
+
|
311
|
+
[
|
312
|
+
["url", "", true]
|
313
|
+
].each do |name, uri, required|
|
314
|
+
install_get_attribute(name, uri, required)
|
315
|
+
end
|
316
|
+
|
317
|
+
content_setup
|
318
|
+
|
319
|
+
def initialize(*args)
|
320
|
+
if Utils.element_initialize_arguments?(args)
|
321
|
+
super
|
322
|
+
else
|
323
|
+
super()
|
324
|
+
self.url = args[0]
|
325
|
+
self.content = args[1]
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
private
|
330
|
+
def maker_target(item)
|
331
|
+
item.source
|
332
|
+
end
|
333
|
+
|
334
|
+
def setup_maker_attributes(source)
|
335
|
+
source.url = url
|
336
|
+
source.content = content
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
class Enclosure < Element
|
341
|
+
|
342
|
+
include RSS09
|
343
|
+
|
344
|
+
[
|
345
|
+
["url", "", true],
|
346
|
+
["length", "", true, :integer],
|
347
|
+
["type", "", true],
|
348
|
+
].each do |name, uri, required, type|
|
349
|
+
install_get_attribute(name, uri, required, type)
|
350
|
+
end
|
351
|
+
|
352
|
+
def initialize(*args)
|
353
|
+
if Utils.element_initialize_arguments?(args)
|
354
|
+
super
|
355
|
+
else
|
356
|
+
super()
|
357
|
+
self.url = args[0]
|
358
|
+
self.length = args[1]
|
359
|
+
self.type = args[2]
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
private
|
364
|
+
def maker_target(item)
|
365
|
+
item.enclosure
|
366
|
+
end
|
367
|
+
|
368
|
+
def setup_maker_attributes(enclosure)
|
369
|
+
enclosure.url = url
|
370
|
+
enclosure.length = length
|
371
|
+
enclosure.type = type
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
class Category < Element
|
376
|
+
|
377
|
+
include RSS09
|
378
|
+
|
379
|
+
[
|
380
|
+
["domain", "", false]
|
381
|
+
].each do |name, uri, required|
|
382
|
+
install_get_attribute(name, uri, required)
|
383
|
+
end
|
384
|
+
|
385
|
+
content_setup
|
386
|
+
|
387
|
+
def initialize(*args)
|
388
|
+
if Utils.element_initialize_arguments?(args)
|
389
|
+
super
|
390
|
+
else
|
391
|
+
super()
|
392
|
+
self.domain = args[0]
|
393
|
+
self.content = args[1]
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
private
|
398
|
+
def maker_target(item)
|
399
|
+
item.new_category
|
400
|
+
end
|
401
|
+
|
402
|
+
def setup_maker_attributes(category)
|
403
|
+
category.domain = domain
|
404
|
+
category.content = content
|
405
|
+
end
|
406
|
+
|
407
|
+
end
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
class TextInput < Element
|
412
|
+
|
413
|
+
include RSS09
|
414
|
+
|
415
|
+
%w(title description name link).each do |name|
|
416
|
+
install_text_element(name, "", nil)
|
417
|
+
end
|
418
|
+
|
419
|
+
def initialize(*args)
|
420
|
+
if Utils.element_initialize_arguments?(args)
|
421
|
+
super
|
422
|
+
else
|
423
|
+
super()
|
424
|
+
self.title = args[0]
|
425
|
+
self.description = args[1]
|
426
|
+
self.name = args[2]
|
427
|
+
self.link = args[3]
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
private
|
432
|
+
def maker_target(maker)
|
433
|
+
maker.textinput
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
RSS09::ELEMENTS.each do |name|
|
442
|
+
BaseListener.install_get_text_element("", name, name)
|
443
|
+
end
|
444
|
+
|
445
|
+
module ListenerMixin
|
446
|
+
private
|
447
|
+
def initial_start_rss(tag_name, prefix, attrs, ns)
|
448
|
+
check_ns(tag_name, prefix, ns, "", false)
|
449
|
+
|
450
|
+
@rss = Rss.new(attrs['version'], @version, @encoding, @standalone)
|
451
|
+
@rss.do_validate = @do_validate
|
452
|
+
@rss.xml_stylesheets = @xml_stylesheets
|
453
|
+
@last_element = @rss
|
454
|
+
pr = Proc.new do |text, tags|
|
455
|
+
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
|
456
|
+
end
|
457
|
+
@proc_stack.push(pr)
|
458
|
+
end
|
459
|
+
|
460
|
+
end
|
461
|
+
|
462
|
+
end
|