aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rss/1.0.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-19 08:25:25 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-19 08:25:25 +0000
commit9be1ed43c888249563f32a3df394a9841e4f9601 (patch)
tree4a484468fdf164dca7059a0d0e6ea6155ecd5682 /lib/rss/1.0.rb
parent1c453c06081222e9b75dac428b08ffd26f1ca2a7 (diff)
downloadruby-9be1ed43c888249563f32a3df394a9841e4f9601.tar.gz
* lib/rss/rss.rb (RSS::VERSION): 0.1.0 -> 0.1.1.
* lib/rss: #to_s used #tag. * test/rss/test_to_s.rb: added. * lib/rss/maker.rb (RSS::Maker.make): changed API. It's not received modules which is used as the second argument. * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#alternate): changed return value type which is not String but Boolean. * lib/rss/2.0.rb (RSS::Rss::Channel#ttl): changed return value type which is not String but Integer. * lib/rss/0.9.rb (RSS::Rss::Channel): <skipDays> has <day>s and <skipHours> has <hour>s. * lib/rss/maker/0.9.rb (RSS::Maker::RSS09::Channel): ditto. * lib/rss/0.9.rb (RSS::Rss::Channel::Item): <item> has <category>s. * lib/rss/maker/2.0.rb (RSS::Maker::Rss20::Channel::Item): ditto. * lib/rss/2.0.rb (RSS::Rss::Channel): <channel> has <category>s. * lib/rss/maker/2.0.rb (RSS::Maker::RSS20::Channel): ditto. * lib/rss/trackback.rb: parent element has <trackback:about>s. * lib/rss/maker/trackback.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss/1.0.rb')
-rw-r--r--lib/rss/1.0.rb195
1 files changed, 86 insertions, 109 deletions
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index 563ed66426..9a61e456ba 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,7 +270,7 @@ EOT
def _attrs
[
- ["about", true]
+ ["#{PREFIX}:about", true, "about"]
]
end
@@ -298,22 +298,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 +335,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 +377,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 +441,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 +466,9 @@ EOT
def _attrs
[
- ["about", true],
+ ["#{PREFIX}:about", true, "about"]
]
end
-
end
class Item < Element
@@ -522,17 +507,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 +532,9 @@ EOT
def _attrs
[
- ["about", true],
+ ["#{PREFIX}:about", true, "about"]
]
end
-
end
class Textinput < Element
@@ -593,18 +574,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 +601,9 @@ EOT
def _attrs
[
- ["about", true],
+ ["#{PREFIX}:about", true, "about"]
]
end
-
end
end