summaryrefslogtreecommitdiff
path: root/lib/rss/1.0.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-08 12:58:36 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-08 12:58:36 +0000
commitbcf72db844b54492aca33b068711992bd73caccf (patch)
treea54da3329420c04614c460c3b45388951a790aa2 /lib/rss/1.0.rb
parent67c5b057e692b39c801aea811c6b75b40c4b8c22 (diff)
* 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
Diffstat (limited to 'lib/rss/1.0.rb')
-rw-r--r--lib/rss/1.0.rb209
1 files changed, 103 insertions, 106 deletions
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index 563ed66426..0e3e66ea95 100644
--- a/lib/rss/1.0.rb
+++ b/lib/rss/1.0.rb
@@ -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