mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/rss.rb: provided default RSS::Element#_tags.
* lib/rss/0.9.rb: used default RSS::Element#_tags. * lib/rss/1.0.rb: ditto. * lib/rss/2.0.rb: ditto. * lib/rss/image.rb: ditto. * lib/rss/taxonomy.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
028e6396c0
commit
df1e494a13
7 changed files with 30 additions and 217 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Tue Jun 20 21:04:33 2006 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/rss.rb: provided default RSS::Element#_tags.
|
||||
|
||||
* lib/rss/0.9.rb: used default RSS::Element#_tags.
|
||||
* lib/rss/1.0.rb: ditto.
|
||||
* lib/rss/2.0.rb: ditto.
|
||||
* lib/rss/image.rb: ditto.
|
||||
* lib/rss/taxonomy.rb: ditto.
|
||||
|
||||
Tue Jun 20 20:47:07 2006 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/rss.rb: hide RSS::Element.install_model.
|
||||
|
|
|
@ -65,14 +65,6 @@ module RSS
|
|||
[@channel]
|
||||
end
|
||||
|
||||
def _tags
|
||||
[
|
||||
["", 'channel'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def _attrs
|
||||
[
|
||||
["version", true, "rss_version"],
|
||||
|
@ -112,35 +104,6 @@ module RSS
|
|||
[@skipDays, @skipHours, @image, @textInput, @cloud, *@item]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = [
|
||||
"title",
|
||||
"link",
|
||||
"description",
|
||||
"language",
|
||||
"copyright",
|
||||
"managingEditor",
|
||||
"webMaster",
|
||||
"rating",
|
||||
"docs",
|
||||
"skipDays",
|
||||
"skipHours",
|
||||
"image",
|
||||
"textInput",
|
||||
"cloud",
|
||||
].delete_if do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |elem|
|
||||
["", elem]
|
||||
end
|
||||
|
||||
@item.each do
|
||||
rv << ["", "item"]
|
||||
end
|
||||
|
||||
rv
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.channel
|
||||
end
|
||||
|
@ -179,12 +142,6 @@ module RSS
|
|||
@day
|
||||
end
|
||||
|
||||
def _tags
|
||||
@day.compact.collect do
|
||||
["", "day"]
|
||||
end
|
||||
end
|
||||
|
||||
class Day < Element
|
||||
include RSS09
|
||||
|
||||
|
@ -217,12 +174,6 @@ module RSS
|
|||
@hour
|
||||
end
|
||||
|
||||
def _tags
|
||||
@hour.compact.collect do
|
||||
["", "hour"]
|
||||
end
|
||||
end
|
||||
|
||||
class Hour < Element
|
||||
include RSS09
|
||||
|
||||
|
@ -270,14 +221,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
%w(url title link width height description).delete_if do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |elem|
|
||||
["", elem]
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.image
|
||||
end
|
||||
|
@ -331,21 +274,6 @@ module RSS
|
|||
[@source, @enclosure, *@category].compact
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = %w(title link description author comments
|
||||
source enclosure).delete_if do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |name|
|
||||
["", name]
|
||||
end
|
||||
|
||||
@category.each do
|
||||
rv << ["", "category"]
|
||||
end
|
||||
|
||||
rv
|
||||
end
|
||||
|
||||
def maker_target(items)
|
||||
if items.respond_to?("items")
|
||||
# For backward compatibility
|
||||
|
@ -383,10 +311,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
[]
|
||||
end
|
||||
|
||||
def maker_target(item)
|
||||
item.source
|
||||
end
|
||||
|
@ -489,14 +413,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
%w(title description name link).each do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |elem|
|
||||
["", elem]
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.textinput
|
||||
end
|
||||
|
|
|
@ -60,18 +60,6 @@ module RSS
|
|||
[@channel, @image, @textinput, *@item]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = [
|
||||
[::RSS::URI, "channel"],
|
||||
[::RSS::URI, "image"],
|
||||
].delete_if {|uri, name| __send__(name).nil?}
|
||||
@item.each do |item|
|
||||
rv << [::RSS::URI, "item"]
|
||||
end
|
||||
rv << [::RSS::URI, "textinput"] if @textinput
|
||||
rv
|
||||
end
|
||||
|
||||
class Li < Element
|
||||
|
||||
include RSS10
|
||||
|
@ -142,14 +130,6 @@ module RSS
|
|||
def children
|
||||
@li
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
@li.each do |li|
|
||||
rv << [URI, "li"]
|
||||
end
|
||||
rv
|
||||
end
|
||||
end
|
||||
|
||||
class Bag < Element
|
||||
|
@ -192,14 +172,6 @@ module RSS
|
|||
def children
|
||||
@li
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
@li.each do |li|
|
||||
rv << [URI, "li"]
|
||||
end
|
||||
rv
|
||||
end
|
||||
end
|
||||
|
||||
class Channel < Element
|
||||
|
@ -246,19 +218,6 @@ module RSS
|
|||
[@image, @items, @textinput]
|
||||
end
|
||||
|
||||
def _tags
|
||||
[
|
||||
[::RSS::URI, 'title'],
|
||||
[::RSS::URI, 'link'],
|
||||
[::RSS::URI, 'description'],
|
||||
[::RSS::URI, 'image'],
|
||||
[::RSS::URI, 'items'],
|
||||
[::RSS::URI, 'textinput'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.channel
|
||||
end
|
||||
|
@ -366,12 +325,6 @@ module RSS
|
|||
def children
|
||||
[@Seq]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
rv << [URI, 'Seq'] unless @Seq.nil?
|
||||
rv
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -408,16 +361,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
[
|
||||
[::RSS::URI, 'title'],
|
||||
[::RSS::URI, 'url'],
|
||||
[::RSS::URI, 'link'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.image
|
||||
end
|
||||
|
@ -461,16 +404,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
[
|
||||
[::RSS::URI, 'title'],
|
||||
[::RSS::URI, 'link'],
|
||||
[::RSS::URI, 'description'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(items)
|
||||
if items.respond_to?("items")
|
||||
# For backward compatibility
|
||||
|
@ -513,17 +446,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
[
|
||||
[::RSS::URI, 'title'],
|
||||
[::RSS::URI, 'description'],
|
||||
[::RSS::URI, 'name'],
|
||||
[::RSS::URI, 'link'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(maker)
|
||||
maker.textinput
|
||||
end
|
||||
|
|
|
@ -32,21 +32,6 @@ module RSS
|
|||
children09 + @category.compact
|
||||
end
|
||||
|
||||
alias _tags09 _tags
|
||||
def _tags
|
||||
rv = %w(generator ttl).delete_if do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |elem|
|
||||
["", elem]
|
||||
end + _tags09
|
||||
|
||||
@category.each do
|
||||
rv << ["", "category"]
|
||||
end
|
||||
|
||||
rv
|
||||
end
|
||||
|
||||
Category = Item::Category
|
||||
|
||||
class Item
|
||||
|
@ -78,15 +63,6 @@ module RSS
|
|||
children09 + [@guid].compact
|
||||
end
|
||||
|
||||
alias _tags09 _tags
|
||||
def _tags
|
||||
%w(comments author pubDate guid).delete_if do |name|
|
||||
__send__(name).nil?
|
||||
end.collect do |elem|
|
||||
["", elem]
|
||||
end + _tags09
|
||||
end
|
||||
|
||||
alias _setup_maker_element setup_maker_element
|
||||
def setup_maker_element(item)
|
||||
_setup_maker_element(item)
|
||||
|
|
|
@ -92,15 +92,6 @@ module RSS
|
|||
end
|
||||
|
||||
private
|
||||
def _tags
|
||||
[
|
||||
[IMAGE_URI, 'width'],
|
||||
[IMAGE_URI, 'height'],
|
||||
].delete_if do |uri, name|
|
||||
__send__(name).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def maker_target(target)
|
||||
target.image_item
|
||||
end
|
||||
|
|
|
@ -144,7 +144,7 @@ module RSS
|
|||
def install_have_child_element(tag_name, uri, occurs, name=nil)
|
||||
name ||= tag_name
|
||||
add_need_initialize_variable(name)
|
||||
install_model(tag_name, uri, occurs)
|
||||
install_model(tag_name, uri, occurs, name)
|
||||
|
||||
attr_accessor name
|
||||
install_element(name) do |n, elem_name|
|
||||
|
@ -164,7 +164,7 @@ EOC
|
|||
plural_name ||= "#{name}s"
|
||||
add_have_children_element(name, plural_name)
|
||||
add_plural_form(name, plural_name)
|
||||
install_model(tag_name, uri, occurs)
|
||||
install_model(tag_name, uri, occurs, plural_name)
|
||||
|
||||
def_children_accessor(name, plural_name)
|
||||
install_element(name, "s") do |n, elem_name|
|
||||
|
@ -184,7 +184,7 @@ EOC
|
|||
disp_name ||= name
|
||||
self::ELEMENTS << name
|
||||
add_need_initialize_variable(name)
|
||||
install_model(tag_name, uri, occurs)
|
||||
install_model(tag_name, uri, occurs, name)
|
||||
|
||||
def_corresponded_attr_writer name, type, disp_name
|
||||
convert_attr_reader name
|
||||
|
@ -213,7 +213,7 @@ EOC
|
|||
disp_name ||= name
|
||||
self::ELEMENTS << name
|
||||
add_need_initialize_variable(name)
|
||||
install_model(tag_name, uri, occurs)
|
||||
install_model(tag_name, uri, occurs, name)
|
||||
|
||||
# accessor
|
||||
convert_attr_reader name
|
||||
|
@ -477,11 +477,12 @@ EOC
|
|||
MUST_CALL_VALIDATORS[uri] = prefix
|
||||
end
|
||||
|
||||
def self.install_model(tag, uri, occurs=nil)
|
||||
if m = MODELS.find {|t, u, o| t == tag and u == uri}
|
||||
def self.install_model(tag, uri, occurs=nil, getter=nil)
|
||||
getter ||= tag
|
||||
if m = MODELS.find {|t, u, o, g| t == tag and u == uri}
|
||||
m[2] = occurs
|
||||
else
|
||||
MODELS << [tag, uri, occurs]
|
||||
MODELS << [tag, uri, occurs, getter]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -776,7 +777,17 @@ EOC
|
|||
|
||||
# default #validate() argument.
|
||||
def _tags
|
||||
[]
|
||||
rv = []
|
||||
self.class.models.each do |name, uri, occurs, getter|
|
||||
value = __send__(getter)
|
||||
next if value.nil?
|
||||
if value.is_a?(Array)
|
||||
rv.concat([[uri, name]] * value.size)
|
||||
else
|
||||
rv << [uri, name]
|
||||
end
|
||||
end
|
||||
rv
|
||||
end
|
||||
|
||||
def _attrs
|
||||
|
@ -824,7 +835,7 @@ EOC
|
|||
end
|
||||
|
||||
models.each_with_index do |model, i|
|
||||
name, model_uri, occurs = model
|
||||
name, model_uri, occurs, getter = model
|
||||
|
||||
if DEBUG
|
||||
p "before"
|
||||
|
|
|
@ -87,12 +87,6 @@ module RSS
|
|||
def children
|
||||
[@Bag]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
rv << [RDF::URI, 'Bag'] unless @Bag.nil?
|
||||
rv
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -148,13 +142,6 @@ module RSS
|
|||
def children
|
||||
[@taxo_link, *@taxo_topics]
|
||||
end
|
||||
|
||||
def _tags
|
||||
rv = []
|
||||
rv << [TAXO_URI, "link"] unless @taxo_link.nil?
|
||||
rv.concat([TAXO_URI, "topics"] * @taxo_topics.size)
|
||||
rv
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue