1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rss, test/rss, sample/rss: backported from CVS HEAD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2004-12-08 12:58:36 +00:00
parent 67c5b057e6
commit bcf72db844
30 changed files with 1967 additions and 990 deletions

View file

@ -18,7 +18,6 @@ module RSS
include RSS10
include RootElementMixin
include XMLStyleSheetMixin
class << self
@ -57,21 +56,22 @@ module RSS
super('1.0', version, encoding, standalone)
end
def full_name
tag_name_with_prefix(PREFIX)
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
rv = <<-EORDF
#{xmldecl}
#{xml_stylesheet_pi}
#{indent}<#{PREFIX}:RDF#{ns_declaration(next_indent)}>
#{channel_element(false, next_indent)}
#{image_element(false, next_indent)}
#{item_elements(false, next_indent)}
#{textinput_element(false, next_indent)}
#{other_element(false, next_indent)}
#{indent}</#{PREFIX}:RDF>
EORDF
rv = tag(indent, ns_declarations) do |next_indent|
[
channel_element(false, next_indent),
image_element(false, next_indent),
item_elements(false, next_indent),
textinput_element(false, next_indent),
other_element(false, next_indent),
]
end
rv = @converter.convert(rv) if convert and @converter
remove_empty_newline(rv)
rv
end
private
@ -119,16 +119,19 @@ EORDF
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
<<-EOT
#{indent}<#{PREFIX}:Seq>
#{li_elements(convert, next_indent)}
#{other_element(convert, next_indent)}
#{indent}</#{PREFIX}:Seq>
EOT
tag(indent) do |next_indent|
[
li_elements(convert, next_indent),
other_element(convert, next_indent),
]
end
end
private
def full_name
tag_name_with_prefix(PREFIX)
end
private
def children
@li
end
@ -169,15 +172,15 @@ EOT
super()
@resource = resource
end
def full_name
tag_name_with_prefix(PREFIX)
end
def to_s(convert=true, indent=calc_indent)
if @resource
rv = %Q!#{indent}<#{PREFIX}:li resource="#{h @resource}" />\n!
rv = @converter.convert(rv) if convert and @converter
rv
else
''
end
rv = tag(indent)
rv = @converter.convert(rv) if convert and @converter
rv
end
private
@ -232,20 +235,17 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
about = ''
about << %Q!#{PREFIX}:about="#{h @about}"! if @about
rv = <<-EOT
#{indent}<channel #{about}>
#{title_element(false, next_indent)}
#{link_element(false, next_indent)}
#{description_element(false, next_indent)}
#{image_element(false, next_indent)}
#{items_element(false, next_indent)}
#{textinput_element(false, next_indent)}
#{other_element(false, next_indent)}
#{indent}</channel>
EOT
rv = tag(indent) do |next_indent|
[
title_element(false, next_indent),
link_element(false, next_indent),
description_element(false, next_indent),
image_element(false, next_indent),
items_element(false, next_indent),
textinput_element(false, next_indent),
other_element(false, next_indent),
]
end
rv = @converter.convert(rv) if convert and @converter
rv
end
@ -270,10 +270,18 @@ EOT
def _attrs
[
["about", true]
["#{PREFIX}:about", true, "about"]
]
end
def maker_target(maker)
maker.channel
end
def setup_maker_attributes(channel)
channel.about = self.about
end
class Image < Element
include RSS10
@ -298,22 +306,17 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
if @resource
rv = %Q!#{indent}<image #{PREFIX}:resource="#{h @resource}" />!
rv = @converter.convert(rv) if convert and @converter
rv
else
''
end
rv = tag(indent)
rv = @converter.convert(rv) if convert and @converter
rv
end
private
def _attrs
[
["resource", true]
["#{PREFIX}:resource", true, "resource"]
]
end
end
class Textinput < Element
@ -340,22 +343,17 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
if @resource
rv = %Q|#{indent}<textinput #{PREFIX}:resource="#{h @resource}" />|
rv = @converter.convert(rv) if convert and @converter
rv
else
''
end
rv = tag(indent)
rv = @converter.convert(rv) if convert and @converter
rv
end
private
def _attrs
[
["resource", true],
["#{PREFIX}:resource", true, "resource"]
]
end
end
class Items < Element
@ -387,13 +385,12 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
<<-EOT
#{indent}<items>
#{Seq_element(convert, next_indent)}
#{other_element(convert, next_indent)}
#{indent}</items>
EOT
rv = tag(indent) do |next_indent|
[
Seq_element(convert, next_indent),
other_element(convert, next_indent),
]
end
end
private
@ -452,17 +449,14 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
about = ''
about << %Q!#{PREFIX}:about="#{h @about}"! if @about
rv = <<-EOT
#{indent}<image #{about}>
#{title_element(false, next_indent)}
#{url_element(false, next_indent)}
#{link_element(false, next_indent)}
#{other_element(false, next_indent)}
#{indent}</image>
EOT
rv = tag(indent) do |next_indent|
[
title_element(false, next_indent),
url_element(false, next_indent),
link_element(false, next_indent),
other_element(false, next_indent),
]
end
rv = @converter.convert(rv) if convert and @converter
rv
end
@ -480,10 +474,13 @@ EOT
def _attrs
[
["about", true],
["#{PREFIX}:about", true, "about"]
]
end
def maker_target(maker)
maker.image
end
end
class Item < Element
@ -522,17 +519,14 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
about = ''
about << %Q!#{PREFIX}:about="#{h @about}"! if @about
rv = <<-EOT
#{indent}<item #{about}>
#{title_element(false, next_indent)}
#{link_element(false, next_indent)}
#{description_element(false, next_indent)}
#{other_element(false, next_indent)}
#{indent}</item>
EOT
rv = tag(indent) do |next_indent|
[
title_element(false, next_indent),
link_element(false, next_indent),
description_element(false, next_indent),
other_element(false, next_indent),
]
end
rv = @converter.convert(rv) if convert and @converter
rv
end
@ -550,10 +544,13 @@ EOT
def _attrs
[
["about", true],
["#{PREFIX}:about", true, "about"]
]
end
def maker_target(maker)
maker.items.new_item
end
end
class Textinput < Element
@ -593,18 +590,15 @@ EOT
end
def to_s(convert=true, indent=calc_indent)
next_indent = indent + INDENT
about = ''
about << %Q!#{PREFIX}:about="#{h @about}"! if @about
rv = <<-EOT
#{indent}<textinput #{about}>
#{title_element(false, next_indent)}
#{description_element(false, next_indent)}
#{name_element(false, next_indent)}
#{link_element(false, next_indent)}
#{other_element(false, next_indent)}
#{indent}</textinput>
EOT
rv = tag(indent) do |next_indent|
[
title_element(false, next_indent),
description_element(false, next_indent),
name_element(false, next_indent),
link_element(false, next_indent),
other_element(false, next_indent),
]
end
rv = @converter.convert(rv) if convert and @converter
rv
end
@ -623,10 +617,13 @@ EOT
def _attrs
[
["about", true],
["#{PREFIX}:about", true, "about"]
]
end
def maker_target(maker)
maker.textinput
end
end
end