From b4634f935ae4e179dc4c234837a80a33f6bb0251 Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 16 Oct 2004 04:51:15 +0000 Subject: * lib/rss/: untabified. * test/rss/: untabified. * lib/rss/0.9.rb (RSS::Rss#to_s): inent -> indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rss/rss-assertions.rb | 266 ++++++++++----------- test/rss/rss-testcase.rb | 232 +++++++++--------- test/rss/test_1.0.rb | 516 ++++++++++++++++++++-------------------- test/rss/test_accessor.rb | 34 +-- test/rss/test_content.rb | 142 +++++------ test/rss/test_dublincore.rb | 192 +++++++-------- test/rss/test_parser.rb | 458 +++++++++++++++++------------------ test/rss/test_syndication.rb | 204 ++++++++-------- test/rss/test_trackback.rb | 204 ++++++++-------- test/rss/test_xml-stylesheet.rb | 198 +++++++-------- 10 files changed, 1223 insertions(+), 1223 deletions(-) (limited to 'test') diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb index ad7da1f6b4..40a72e93cd 100644 --- a/test/rss/rss-assertions.rb +++ b/test/rss/rss-assertions.rb @@ -1,139 +1,139 @@ # -*- tab-width: 2 -*- vim: ts=2 module Test - module Unit - module Assertions - # For backward compatibility - unless instance_methods.include?("assert_raise") - def assert_raise(*args, &block) - assert_raises(*args, &block) - end - end - end - end + module Unit + module Assertions + # For backward compatibility + unless instance_methods.include?("assert_raise") + def assert_raise(*args, &block) + assert_raises(*args, &block) + end + end + end + end end module RSS - module Assertions - - def assert_parse(rss, assert_method, *args) - send("assert_#{assert_method}", *args) do - ::RSS::Parser.parse(rss) - end - send("assert_#{assert_method}", *args) do - ::RSS::Parser.parse(rss, false).validate - end - end - - def assert_ns(prefix, uri) - _wrap_assertion do - begin - yield - flunk("Not raise NSError") - rescue ::RSS::NSError => e - assert_equal(prefix, e.prefix) - assert_equal(uri, e.uri) - end - end - end - - def assert_missing_tag(tag, parent) - _wrap_assertion do - begin - yield - flunk("Not raise MissingTagError") - rescue ::RSS::MissingTagError => e - assert_equal(tag, e.tag) - assert_equal(parent, e.parent) - end - end - end - - def assert_too_much_tag(tag, parent) - _wrap_assertion do - begin - yield - flunk("Not raise TooMuchTagError") - rescue ::RSS::TooMuchTagError => e - assert_equal(tag, e.tag) - assert_equal(parent, e.parent) - end - end - end - - def assert_missing_attribute(tag, attrname) - _wrap_assertion do - begin - yield - flunk("Not raise MissingAttributeError") - rescue ::RSS::MissingAttributeError => e - assert_equal(tag, e.tag) - assert_equal(attrname, e.attribute) - end - end - end - - def assert_not_excepted_tag(tag, parent) - _wrap_assertion do - begin - yield - flunk("Not raise NotExceptedTagError") - rescue ::RSS::NotExceptedTagError => e - assert_equal(tag, e.tag) - assert_equal(parent, e.parent) - end - end - end - - def assert_not_available_value(tag, value) - _wrap_assertion do - begin - yield - flunk("Not raise NotAvailableValueError") - rescue ::RSS::NotAvailableValueError => e - assert_equal(tag, e.tag) - assert_equal(value, e.value) - end - end - end - - def assert_xml_stylesheet_attrs(xsl, attrs) - _wrap_assertion do - normalized_attrs = {} - attrs.each do |name, value| - normalized_attrs[name.to_s] = value - end - ::RSS::XMLStyleSheet::ATTRIBUTES.each do |name| - assert_equal(normalized_attrs[name], xsl.send(name)) - end - end - end - - def assert_xml_stylesheet(target, xsl, attrs) - _wrap_assertion do - if attrs.has_key?(:href) - if !attrs.has_key?(:type) and attrs.has_key?(:guess_type) - attrs[:type] = attrs[:guess_type] - end - assert_equal("xml-stylesheet", target) - assert_xml_stylesheet_attrs(xsl, attrs) - else - assert_nil(target) - assert_equal("", xsl.to_s) - end - end - end - - def assert_xml_stylesheet_pis(attrs_ary) - rdf = ::RSS::RDF.new() - xss_strs = [] - attrs_ary.each do |attrs| - xss = ::RSS::XMLStyleSheet.new(*attrs) - xss_strs.push(xss.to_s) - rdf.xml_stylesheets.push(xss) - end - pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s* e + assert_equal(prefix, e.prefix) + assert_equal(uri, e.uri) + end + end + end + + def assert_missing_tag(tag, parent) + _wrap_assertion do + begin + yield + flunk("Not raise MissingTagError") + rescue ::RSS::MissingTagError => e + assert_equal(tag, e.tag) + assert_equal(parent, e.parent) + end + end + end + + def assert_too_much_tag(tag, parent) + _wrap_assertion do + begin + yield + flunk("Not raise TooMuchTagError") + rescue ::RSS::TooMuchTagError => e + assert_equal(tag, e.tag) + assert_equal(parent, e.parent) + end + end + end + + def assert_missing_attribute(tag, attrname) + _wrap_assertion do + begin + yield + flunk("Not raise MissingAttributeError") + rescue ::RSS::MissingAttributeError => e + assert_equal(tag, e.tag) + assert_equal(attrname, e.attribute) + end + end + end + + def assert_not_excepted_tag(tag, parent) + _wrap_assertion do + begin + yield + flunk("Not raise NotExceptedTagError") + rescue ::RSS::NotExceptedTagError => e + assert_equal(tag, e.tag) + assert_equal(parent, e.parent) + end + end + end + + def assert_not_available_value(tag, value) + _wrap_assertion do + begin + yield + flunk("Not raise NotAvailableValueError") + rescue ::RSS::NotAvailableValueError => e + assert_equal(tag, e.tag) + assert_equal(value, e.value) + end + end + end + + def assert_xml_stylesheet_attrs(xsl, attrs) + _wrap_assertion do + normalized_attrs = {} + attrs.each do |name, value| + normalized_attrs[name.to_s] = value + end + ::RSS::XMLStyleSheet::ATTRIBUTES.each do |name| + assert_equal(normalized_attrs[name], xsl.send(name)) + end + end + end + + def assert_xml_stylesheet(target, xsl, attrs) + _wrap_assertion do + if attrs.has_key?(:href) + if !attrs.has_key?(:type) and attrs.has_key?(:guess_type) + attrs[:type] = attrs[:guess_type] + end + assert_equal("xml-stylesheet", target) + assert_xml_stylesheet_attrs(xsl, attrs) + else + assert_nil(target) + assert_equal("", xsl.to_s) + end + end + end + + def assert_xml_stylesheet_pis(attrs_ary) + rdf = ::RSS::RDF.new() + xss_strs = [] + attrs_ary.each do |attrs| + xss = ::RSS::XMLStyleSheet.new(*attrs) + xss_strs.push(xss.to_s) + rdf.xml_stylesheets.push(xss) + end + pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s*" - rv - end - - def make_RDF(content=nil, xmlns=[]) - <<-EORSS + " + RESOURCES = [ + "http://xml.com/pub/2000/08/09/xslt/xslt.html", + "http://xml.com/pub/2000/08/09/rdfdb/index.html", + ] + + CLOUD_DOMAIN = "data.ourfavoritesongs.com" + CLOUD_PORT = "80" + CLOUD_PATH = "/RPC2" + CLOUD_REGISTER_PROCEDURE = "ourFavoriteSongs.rssPleaseNotify" + CLOUD_PROTOCOL = "xml-rpc" + + ENCLOSURE_URL = "http://www.scripting.com/mp3s/weatherReportSuite.mp3" + ENCLOSURE_LENGTH = "12216320" + ENCLOSURE_TYPE = "audio/mpeg" + + CATEGORY_DOMAIN = "http://www.superopendirectory.com/" + + def default_test + # This class isn't tested + end + + private + def make_xmldecl(v=XMLDECL_VERSION, e=XMLDECL_ENCODING, s=XMLDECL_STANDALONE) + rv = "" + rv + end + + def make_RDF(content=nil, xmlns=[]) + <<-EORSS #{make_xmldecl} #{block_given? ? yield : content} EORSS - end + end - def make_channel(content=nil) - <<-EOC + def make_channel(content=nil) + <<-EOC - #{TITLE_VALUE} - #{LINK_VALUE} - #{DESCRIPTION_VALUE} + #{TITLE_VALUE} + #{LINK_VALUE} + #{DESCRIPTION_VALUE} - + - - + + #{RESOURCES.collect do |res| '' end.join("\n")} - - + + - + #{block_given? ? yield : content} EOC - end + end - def make_image(content=nil) - <<-EOI + def make_image(content=nil) + <<-EOI - #{TITLE_VALUE} - #{URL_VALUE} - #{LINK_VALUE} + #{TITLE_VALUE} + #{URL_VALUE} + #{LINK_VALUE} #{block_given? ? yield : content} EOI - end + end - def make_item(content=nil) - <<-EOI + def make_item(content=nil) + <<-EOI - #{TITLE_VALUE} - #{LINK_VALUE} - #{DESCRIPTION_VALUE} + #{TITLE_VALUE} + #{LINK_VALUE} + #{DESCRIPTION_VALUE} #{block_given? ? yield : content} EOI - end + end - def make_textinput(content=nil) - <<-EOT + def make_textinput(content=nil) + <<-EOT - #{TITLE_VALUE} - #{DESCRIPTION_VALUE} - #{NAME_VALUE} - #{LINK_VALUE} + #{TITLE_VALUE} + #{DESCRIPTION_VALUE} + #{NAME_VALUE} + #{LINK_VALUE} #{block_given? ? yield : content} EOT - end + end - def make_sample_RDF - make_RDF(<<-EOR) + def make_sample_RDF + make_RDF(<<-EOR) #{make_channel} #{make_image} #{make_item} #{make_textinput} EOR - end + end - def make_rss20(content=nil, xmlns=[]) - <<-EORSS + def make_rss20(content=nil, xmlns=[]) + <<-EORSS #{make_xmldecl} #{block_given? ? yield : content} EORSS - end + end - def make_channel20(content=nil) - <<-EOC + def make_channel20(content=nil) + <<-EOC - #{TITLE_VALUE} - #{LINK_VALUE} - #{DESCRIPTION_VALUE} - #{LANGUAGE_VALUE} + #{TITLE_VALUE} + #{LINK_VALUE} + #{DESCRIPTION_VALUE} + #{LANGUAGE_VALUE} - - #{RDF_RESOURCE} - #{TITLE_VALUE} - #{LINK_VALUE} - + + #{RDF_RESOURCE} + #{TITLE_VALUE} + #{LINK_VALUE} + #{RESOURCES.collect do |res| '' + res + '' end.join("\n")} - - #{TITLE_VALUE} - #{DESCRIPTION_VALUE} - #{NAME_VALUE} - #{RDF_RESOURCE} - + + #{TITLE_VALUE} + #{DESCRIPTION_VALUE} + #{NAME_VALUE} + #{RDF_RESOURCE} + #{block_given? ? yield : content} EOC - end + end - def make_item20(content=nil) - <<-EOI + def make_item20(content=nil) + <<-EOI - #{TITLE_VALUE} - #{LINK_VALUE} - #{DESCRIPTION_VALUE} + #{TITLE_VALUE} + #{LINK_VALUE} + #{DESCRIPTION_VALUE} #{block_given? ? yield : content} EOI - end + end - def make_cloud20 - <<-EOC + def make_cloud20 + <<-EOC EOC - end + end - end + end end diff --git a/test/rss/test_1.0.rb b/test/rss/test_1.0.rb index 0ea3e884d8..43a168d035 100644 --- a/test/rss/test_1.0.rb +++ b/test/rss/test_1.0.rb @@ -7,264 +7,264 @@ require "rss-testcase" require "rss/1.0" module RSS - class TestCore < TestCase - - def setup - - @rdf_prefix = "rdf" - @rdf_uri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" - @uri = "http://purl.org/rss/1.0/" - - end - - def test_RDF - - version = "1.0" - encoding = "UTF-8" - standalone = "no" - - rdf = RDF.new(version, encoding, standalone) - - doc = REXML::Document.new(rdf.to_s(false)) - - xmldecl = doc.xml_decl - - %w(version encoding standalone).each do |x| - assert_equal(instance_eval(x), xmldecl.send(x)) - end - - assert_equal(@rdf_uri, doc.root.namespace) - - end - - def test_not_displayed_xml_stylesheets - rdf = RDF.new() - plain_rdf = rdf.to_s - 3.times do - rdf.xml_stylesheets.push(XMLStyleSheet.new) - assert_equal(plain_rdf, rdf.to_s) - end - end - - def test_xml_stylesheets - [ - [{:href => "a.xsl", :type => "text/xsl"}], - [ - {:href => "a.xsl", :type => "text/xsl"}, - {:href => "a.css", :type => "text/css"}, - ], - ].each do |attrs_ary| - assert_xml_stylesheet_pis(attrs_ary) - end - end - - def test_channel - about = "http://hoge.com" - title = "fugafuga" - link = "http://hoge.com" - description = "fugafugafugafuga" - resource = "http://hoge.com/hoge.png" - image = RDF::Channel::Image.new(resource) - items = RDF::Channel::Items.new - textinput = RDF::Channel::Textinput.new(resource) - - channel = RDF::Channel.new(about) - %w(title link description image items textinput).each do |x| - channel.send("#{x}=", instance_eval(x)) - end - - doc = REXML::Document.new(make_RDF(channel.to_s)) - c = doc.root.elements[1] - - assert_equal(about, c.attributes["about"]) - %w(title link description image textinput).each do |x| - elem = c.elements[x] - assert_equal(x, elem.name) - assert_equal(@uri, elem.namespace) - if x == "image" or x == "textinput" - excepted = resource - res = elem.attributes.get_attribute("resource") - assert_equal(@rdf_uri, res.namespace) - value = res.value - else - excepted = instance_eval(x) - value = elem.text - end - assert_equal(excepted, value) - end - assert_equal(@uri, c.elements["items"].namespace) - assert_equal("items", c.elements["items"].name) - - end - - def test_channel_image - - resource = "http://hoge.com/hoge.png" - image = RDF::Channel::Image.new(resource) - - doc = REXML::Document.new(make_RDF(image.to_s)) - i = doc.root.elements[1] - - assert_equal("image", i.name) - assert_equal(@uri, i.namespace) - - res = i.attributes.get_attribute("resource") - - assert_equal(@rdf_uri, res.namespace) - assert_equal(resource, res.value) - - end - - def test_channel_textinput - - resource = "http://hoge.com/hoge.png" - textinput = RDF::Channel::Textinput.new(resource) - - doc = REXML::Document.new(make_RDF(textinput.to_s)) - t = doc.root.elements[1] - - assert_equal("textinput", t.name) - assert_equal(@uri, t.namespace) - - res = t.attributes.get_attribute("resource") - - assert_equal(@rdf_uri, res.namespace) - assert_equal(resource, res.value) - - end - - def test_items - - items = RDF::Channel::Items.new - - doc = REXML::Document.new(make_RDF(items.to_s)) - i = doc.root.elements[1] - - assert_equal("items", i.name) - assert_equal(@uri, i.namespace) - - assert_equal(1, i.elements.size) - assert_equal("Seq", i.elements[1].name) - assert_equal(@rdf_uri, i.elements[1].namespace) - - end - - def test_seq - - seq = RDF::Seq.new - - doc = REXML::Document.new(make_RDF(seq.to_s)) - s = doc.root.elements[1] - - assert_equal("Seq", s.name) - assert_equal(@rdf_uri, s.namespace) - - end - - def test_li - - resource = "http://hoge.com/" - li = RDF::Li.new(resource) - - doc = REXML::Document.new(make_RDF(li.to_s)) - l = doc.root.elements[1] - - assert_equal("li", l.name) - assert_equal(@rdf_uri, l.namespace(l.prefix)) - - res = l.attributes.get_attribute("resource") - - assert_equal('', res.instance_eval("@prefix")) - assert_equal(resource, res.value) - - end - - def test_image - - about = "http://hoge.com" - title = "fugafuga" - url = "http://hoge.com/hoge" - link = "http://hoge.com/fuga" - - image = RDF::Image.new(about) - %w(title url link).each do |x| - image.send("#{x}=", instance_eval(x)) - end - - doc = REXML::Document.new(make_RDF(image.to_s)) - i = doc.root.elements[1] - - assert_equal(about, i.attributes["about"]) - %w(title url link).each do |x| - elem = i.elements[x] - assert_equal(x, elem.name) - assert_equal(@uri, elem.namespace) - assert_equal(instance_eval(x), elem.text) - end - - end - - def test_item - - about = "http://hoge.com" - title = "fugafuga" - link = "http://hoge.com/fuga" - description = "hogehogehoge" - - item = RDF::Item.new(about) - %w(title link description).each do |x| - item.send("#{x}=", instance_eval(x)) - end - - doc = REXML::Document.new(make_RDF(item.to_s)) - i = doc.root.elements[1] - - assert_equal(about, i.attributes["about"]) - %w(title link description).each do |x| - elem = i.elements[x] - assert_equal(x, elem.name) - assert_equal(@uri, elem.namespace) - assert_equal(instance_eval(x), elem.text) - end - - end - - def test_textinput - - about = "http://hoge.com" - title = "fugafuga" - link = "http://hoge.com/fuga" - name = "foo" - description = "hogehogehoge" - - textinput = RDF::Textinput.new(about) - %w(title link name description).each do |x| - textinput.send("#{x}=", instance_eval(x)) - end - - doc = REXML::Document.new(make_RDF(textinput.to_s)) - t = doc.root.elements[1] - - assert_equal(about, t.attributes["about"]) - %w(title link name description).each do |x| - elem = t.elements[x] - assert_equal(x, elem.name) - assert_equal(@uri, elem.namespace) - assert_equal(instance_eval(x), elem.text) - end - - end + class TestCore < TestCase + + def setup + + @rdf_prefix = "rdf" + @rdf_uri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + @uri = "http://purl.org/rss/1.0/" + + end + + def test_RDF + + version = "1.0" + encoding = "UTF-8" + standalone = "no" + + rdf = RDF.new(version, encoding, standalone) + + doc = REXML::Document.new(rdf.to_s(false)) + + xmldecl = doc.xml_decl + + %w(version encoding standalone).each do |x| + assert_equal(instance_eval(x), xmldecl.send(x)) + end + + assert_equal(@rdf_uri, doc.root.namespace) + + end + + def test_not_displayed_xml_stylesheets + rdf = RDF.new() + plain_rdf = rdf.to_s + 3.times do + rdf.xml_stylesheets.push(XMLStyleSheet.new) + assert_equal(plain_rdf, rdf.to_s) + end + end + + def test_xml_stylesheets + [ + [{:href => "a.xsl", :type => "text/xsl"}], + [ + {:href => "a.xsl", :type => "text/xsl"}, + {:href => "a.css", :type => "text/css"}, + ], + ].each do |attrs_ary| + assert_xml_stylesheet_pis(attrs_ary) + end + end + + def test_channel + about = "http://hoge.com" + title = "fugafuga" + link = "http://hoge.com" + description = "fugafugafugafuga" + resource = "http://hoge.com/hoge.png" + image = RDF::Channel::Image.new(resource) + items = RDF::Channel::Items.new + textinput = RDF::Channel::Textinput.new(resource) + + channel = RDF::Channel.new(about) + %w(title link description image items textinput).each do |x| + channel.send("#{x}=", instance_eval(x)) + end + + doc = REXML::Document.new(make_RDF(channel.to_s)) + c = doc.root.elements[1] + + assert_equal(about, c.attributes["about"]) + %w(title link description image textinput).each do |x| + elem = c.elements[x] + assert_equal(x, elem.name) + assert_equal(@uri, elem.namespace) + if x == "image" or x == "textinput" + excepted = resource + res = elem.attributes.get_attribute("resource") + assert_equal(@rdf_uri, res.namespace) + value = res.value + else + excepted = instance_eval(x) + value = elem.text + end + assert_equal(excepted, value) + end + assert_equal(@uri, c.elements["items"].namespace) + assert_equal("items", c.elements["items"].name) + + end + + def test_channel_image + + resource = "http://hoge.com/hoge.png" + image = RDF::Channel::Image.new(resource) + + doc = REXML::Document.new(make_RDF(image.to_s)) + i = doc.root.elements[1] + + assert_equal("image", i.name) + assert_equal(@uri, i.namespace) + + res = i.attributes.get_attribute("resource") + + assert_equal(@rdf_uri, res.namespace) + assert_equal(resource, res.value) + + end + + def test_channel_textinput + + resource = "http://hoge.com/hoge.png" + textinput = RDF::Channel::Textinput.new(resource) + + doc = REXML::Document.new(make_RDF(textinput.to_s)) + t = doc.root.elements[1] + + assert_equal("textinput", t.name) + assert_equal(@uri, t.namespace) + + res = t.attributes.get_attribute("resource") + + assert_equal(@rdf_uri, res.namespace) + assert_equal(resource, res.value) + + end + + def test_items + + items = RDF::Channel::Items.new + + doc = REXML::Document.new(make_RDF(items.to_s)) + i = doc.root.elements[1] + + assert_equal("items", i.name) + assert_equal(@uri, i.namespace) + + assert_equal(1, i.elements.size) + assert_equal("Seq", i.elements[1].name) + assert_equal(@rdf_uri, i.elements[1].namespace) + + end + + def test_seq + + seq = RDF::Seq.new + + doc = REXML::Document.new(make_RDF(seq.to_s)) + s = doc.root.elements[1] + + assert_equal("Seq", s.name) + assert_equal(@rdf_uri, s.namespace) + + end + + def test_li + + resource = "http://hoge.com/" + li = RDF::Li.new(resource) + + doc = REXML::Document.new(make_RDF(li.to_s)) + l = doc.root.elements[1] + + assert_equal("li", l.name) + assert_equal(@rdf_uri, l.namespace(l.prefix)) + + res = l.attributes.get_attribute("resource") + + assert_equal('', res.instance_eval("@prefix")) + assert_equal(resource, res.value) + + end + + def test_image + + about = "http://hoge.com" + title = "fugafuga" + url = "http://hoge.com/hoge" + link = "http://hoge.com/fuga" + + image = RDF::Image.new(about) + %w(title url link).each do |x| + image.send("#{x}=", instance_eval(x)) + end + + doc = REXML::Document.new(make_RDF(image.to_s)) + i = doc.root.elements[1] + + assert_equal(about, i.attributes["about"]) + %w(title url link).each do |x| + elem = i.elements[x] + assert_equal(x, elem.name) + assert_equal(@uri, elem.namespace) + assert_equal(instance_eval(x), elem.text) + end + + end + + def test_item + + about = "http://hoge.com" + title = "fugafuga" + link = "http://hoge.com/fuga" + description = "hogehogehoge" + + item = RDF::Item.new(about) + %w(title link description).each do |x| + item.send("#{x}=", instance_eval(x)) + end + + doc = REXML::Document.new(make_RDF(item.to_s)) + i = doc.root.elements[1] + + assert_equal(about, i.attributes["about"]) + %w(title link description).each do |x| + elem = i.elements[x] + assert_equal(x, elem.name) + assert_equal(@uri, elem.namespace) + assert_equal(instance_eval(x), elem.text) + end + + end + + def test_textinput + + about = "http://hoge.com" + title = "fugafuga" + link = "http://hoge.com/fuga" + name = "foo" + description = "hogehogehoge" + + textinput = RDF::Textinput.new(about) + %w(title link name description).each do |x| + textinput.send("#{x}=", instance_eval(x)) + end + + doc = REXML::Document.new(make_RDF(textinput.to_s)) + t = doc.root.elements[1] + + assert_equal(about, t.attributes["about"]) + %w(title link name description).each do |x| + elem = t.elements[x] + assert_equal(x, elem.name) + assert_equal(@uri, elem.namespace) + assert_equal(instance_eval(x), elem.text) + end + + end - def test_indent_size - assert_equal(0, RDF.indent_size) - assert_equal(1, RDF::Channel.indent_size) - assert_equal(2, RDF::Channel::Image.indent_size) - assert_equal(2, RDF::Channel::Textinput.indent_size) - assert_equal(2, RDF::Channel::Items.indent_size) - assert_equal(1, RDF::Image.indent_size) - assert_equal(1, RDF::Item.indent_size) - assert_equal(1, RDF::Textinput.indent_size) - end + def test_indent_size + assert_equal(0, RDF.indent_size) + assert_equal(1, RDF::Channel.indent_size) + assert_equal(2, RDF::Channel::Image.indent_size) + assert_equal(2, RDF::Channel::Textinput.indent_size) + assert_equal(2, RDF::Channel::Items.indent_size) + assert_equal(1, RDF::Image.indent_size) + assert_equal(1, RDF::Item.indent_size) + assert_equal(1, RDF::Textinput.indent_size) + end - end + end end diff --git a/test/rss/test_accessor.rb b/test/rss/test_accessor.rb index 08f565e596..1b92f9d98c 100644 --- a/test/rss/test_accessor.rb +++ b/test/rss/test_accessor.rb @@ -6,21 +6,21 @@ require "rss/1.0" require "rss/2.0" module RSS - class TestAccessor < TestCase - - def test_date - channel = Rss::Channel.new - channel.do_validate = false - channel.pubDate = nil - assert_nil(channel.pubDate) - - time = Time.now - channel.pubDate = time - assert_equal(time, channel.pubDate) - - channel.pubDate = nil - assert_nil(channel.pubDate) - end - - end + class TestAccessor < TestCase + + def test_date + channel = Rss::Channel.new + channel.do_validate = false + channel.pubDate = nil + assert_nil(channel.pubDate) + + time = Time.now + channel.pubDate = time + assert_equal(time, channel.pubDate) + + channel.pubDate = nil + assert_nil(channel.pubDate) + end + + end end diff --git a/test/rss/test_content.rb b/test/rss/test_content.rb index 24877d3ec9..c0f6e4292f 100644 --- a/test/rss/test_content.rb +++ b/test/rss/test_content.rb @@ -9,89 +9,89 @@ require "rss/1.0" require "rss/content" module RSS - class TestContent < TestCase - - def setup - @prefix = "content" - @uri = "http://purl.org/rss/1.0/modules/content/" - - @parents = %w(item) - - @elems = { - :encoded => "ATTENTION", - } - - @content_nodes = @elems.collect do |name, value| - "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" - end.join("\n") - - @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) + class TestContent < TestCase + + def setup + @prefix = "content" + @uri = "http://purl.org/rss/1.0/modules/content/" + + @parents = %w(item) + + @elems = { + :encoded => "ATTENTION", + } + + @content_nodes = @elems.collect do |name, value| + "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" + end.join("\n") + + @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) #{make_channel()} #{make_image()} #{make_item(@content_nodes)} #{make_textinput()} EOR - @rss = Parser.parse(@rss_source) - end - - def test_parser + @rss = Parser.parse(@rss_source) + end + + def test_parser - assert_nothing_raised do - Parser.parse(@rss_source) - end - - @elems.each do |tag, value| - assert_too_much_tag(tag.to_s, "item") do - Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) + assert_nothing_raised do + Parser.parse(@rss_source) + end + + @elems.each do |tag, value| + assert_too_much_tag(tag.to_s, "item") do + Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) #{make_channel()} #{make_item(("<" + @prefix + ":" + tag.to_s + ">" + - CGI.escapeHTML(value.to_s) + - "") * 2)} + CGI.escapeHTML(value.to_s) + + "") * 2)} EOR - end - end + end + end - end - - def test_accessor - - new_value = { - :encoded => "hoge]]>", - } + end + + def test_accessor + + new_value = { + :encoded => "hoge]]>", + } - @elems.each do |name, value| - @parents.each do |parent| - meth = "#{RSS::CONTENT_PREFIX}_#{name}" - assert_equal(value, @rss.send(parent).send(meth)) - @rss.send(parent).send("#{meth}=", new_value[name].to_s) - assert_equal(new_value[name], @rss.send(parent).send(meth)) - end - end + @elems.each do |name, value| + @parents.each do |parent| + meth = "#{RSS::CONTENT_PREFIX}_#{name}" + assert_equal(value, @rss.send(parent).send(meth)) + @rss.send(parent).send("#{meth}=", new_value[name].to_s) + assert_equal(new_value[name], @rss.send(parent).send(meth)) + end + end - end - - def test_to_s - - @elems.each do |name, value| - excepted = "<#{@prefix}:#{name}>#{CGI.escapeHTML(value)}" - @parents.each do |parent| - meth = "#{RSS::CONTENT_PREFIX}_#{name}_element" - assert_equal(excepted, @rss.send(parent).send(meth)) - end - end + end + + def test_to_s + + @elems.each do |name, value| + excepted = "<#{@prefix}:#{name}>#{CGI.escapeHTML(value)}" + @parents.each do |parent| + meth = "#{RSS::CONTENT_PREFIX}_#{name}_element" + assert_equal(excepted, @rss.send(parent).send(meth)) + end + end - REXML::Document.new(@rss_source).root.each_element do |parent| - if @parents.include?(parent.name) - parent.each_element do |elem| - if elem.namespace == @uri - assert_equal(elem.text, @elems[elem.name.intern].to_s) - end - end - end - end - - end - - end + REXML::Document.new(@rss_source).root.each_element do |parent| + if @parents.include?(parent.name) + parent.each_element do |elem| + if elem.namespace == @uri + assert_equal(elem.text, @elems[elem.name.intern].to_s) + end + end + end + end + + end + + end end diff --git a/test/rss/test_dublincore.rb b/test/rss/test_dublincore.rb index bf5a672837..796666cdb5 100644 --- a/test/rss/test_dublincore.rb +++ b/test/rss/test_dublincore.rb @@ -9,118 +9,118 @@ require "rss/1.0" require "rss/dublincore" module RSS - class TestDublinCore < TestCase + class TestDublinCore < TestCase - def setup - @prefix = "dc" - @uri = "http://purl.org/dc/elements/1.1/" - - @parents = %w(channel image item textinput) - - t = Time.iso8601("2000-01-01T12:00:05+00:00") - class << t - alias_method(:to_s, :iso8601) - end - - @elems = { - :title => "hoge", - :description => - " XML is placing increasingly heavy loads on - the existing technical infrastructure of the Internet.", - :creator => "Rael Dornfest (mailto:rael@oreilly.com)", - :subject => "XML", - :publisher => "The O'Reilly Network", - :contributor => "hogehoge", - :type => "fugafuga", - :format => "hohoho", - :identifier => "fufufu", - :source => "barbar", - :language => "ja", - :relation => "cococo", - :rights => "Copyright (c) 2000 O'Reilly & Associates, Inc.", - :date => t, - } + def setup + @prefix = "dc" + @uri = "http://purl.org/dc/elements/1.1/" + + @parents = %w(channel image item textinput) + + t = Time.iso8601("2000-01-01T12:00:05+00:00") + class << t + alias_method(:to_s, :iso8601) + end + + @elems = { + :title => "hoge", + :description => + " XML is placing increasingly heavy loads on + the existing technical infrastructure of the Internet.", + :creator => "Rael Dornfest (mailto:rael@oreilly.com)", + :subject => "XML", + :publisher => "The O'Reilly Network", + :contributor => "hogehoge", + :type => "fugafuga", + :format => "hohoho", + :identifier => "fufufu", + :source => "barbar", + :language => "ja", + :relation => "cococo", + :rights => "Copyright (c) 2000 O'Reilly & Associates, Inc.", + :date => t, + } - @dc_nodes = @elems.collect do |name, value| - "<#{@prefix}:#{name}>#{value}" - end.join("\n") + @dc_nodes = @elems.collect do |name, value| + "<#{@prefix}:#{name}>#{value}" + end.join("\n") - @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) + @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) #{make_channel(@dc_nodes)} #{make_image(@dc_nodes)} #{make_item(@dc_nodes)} #{make_textinput(@dc_nodes)} EOR - @rss = Parser.parse(@rss_source) - end - - def test_parser + @rss = Parser.parse(@rss_source) + end + + def test_parser - assert_nothing_raised do - Parser.parse(@rss_source) - end - - @elems.each do |tag, value| - assert_too_much_tag(tag.to_s, "channel") do - Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) + assert_nothing_raised do + Parser.parse(@rss_source) + end + + @elems.each do |tag, value| + assert_too_much_tag(tag.to_s, "channel") do + Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) #{make_channel(("<" + @prefix + ":" + tag.to_s + ">" + - value.to_s + - "") * 2)} + value.to_s + + "") * 2)} #{make_item} EOR - end - end + end + end - end - - def test_accessor - - new_value = "hoge" + end + + def test_accessor + + new_value = "hoge" - @elems.each do |name, value| - @parents.each do |parent| - parsed_value = @rss.send(parent).send("dc_#{name}") - if parsed_value.kind_of?(String) - parsed_value = CGI.escapeHTML(parsed_value) - end - assert_equal(value, parsed_value) - if name == :date - t = Time.iso8601("2003-01-01T02:30:23+09:00") - class << t - alias_method(:to_s, :iso8601) - end - @rss.send(parent).send("dc_#{name}=", t.iso8601) - assert_equal(t, @rss.send(parent).send("dc_#{name}")) - else - @rss.send(parent).send("dc_#{name}=", new_value) - assert_equal(new_value, @rss.send(parent).send("dc_#{name}")) - end - end - end + @elems.each do |name, value| + @parents.each do |parent| + parsed_value = @rss.send(parent).send("dc_#{name}") + if parsed_value.kind_of?(String) + parsed_value = CGI.escapeHTML(parsed_value) + end + assert_equal(value, parsed_value) + if name == :date + t = Time.iso8601("2003-01-01T02:30:23+09:00") + class << t + alias_method(:to_s, :iso8601) + end + @rss.send(parent).send("dc_#{name}=", t.iso8601) + assert_equal(t, @rss.send(parent).send("dc_#{name}")) + else + @rss.send(parent).send("dc_#{name}=", new_value) + assert_equal(new_value, @rss.send(parent).send("dc_#{name}")) + end + end + end - end + end - def test_to_s - - @elems.each do |name, value| - excepted = "<#{@prefix}:#{name}>#{value}" - @parents.each do |parent| - assert_equal(excepted, @rss.send(parent).send("dc_#{name}_element")) - end - end - - REXML::Document.new(@rss_source).root.each_element do |parent| - if @parents.include?(parent.name) - parent.each_element do |elem| - if elem.namespace == @uri - assert_equal(CGI.escapeHTML(elem.text), @elems[elem.name.intern].to_s) - end - end - end - end - - end + def test_to_s + + @elems.each do |name, value| + excepted = "<#{@prefix}:#{name}>#{value}" + @parents.each do |parent| + assert_equal(excepted, @rss.send(parent).send("dc_#{name}_element")) + end + end + + REXML::Document.new(@rss_source).root.each_element do |parent| + if @parents.include?(parent.name) + parent.each_element do |elem| + if elem.namespace == @uri + assert_equal(CGI.escapeHTML(elem.text), @elems[elem.name.intern].to_s) + end + end + end + end + + end - end + end end diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb index 5b15ccb908..3fd26bffb4 100644 --- a/test/rss/test_parser.rb +++ b/test/rss/test_parser.rb @@ -7,139 +7,139 @@ require "rss/2.0" require "rss/dublincore" module RSS - class TestParser < TestCase - - def setup - @_default_parser = Parser.default_parser - end - - def teardown - Parser.default_parser = @_default_parser - end - - def test_RDF - assert_ns("", RDF::URI) do - Parser.parse(<<-EOR) + class TestParser < TestCase + + def setup + @_default_parser = Parser.default_parser + end + + def teardown + Parser.default_parser = @_default_parser + end + + def test_RDF + assert_ns("", RDF::URI) do + Parser.parse(<<-EOR) #{make_xmldecl} EOR - end + end - assert_ns("", RDF::URI) do - Parser.parse(<<-EOR) + assert_ns("", RDF::URI) do + Parser.parse(<<-EOR) #{make_xmldecl} EOR - end + end - assert_ns("rdf", RDF::URI) do - Parser.parse(<<-EOR) + assert_ns("rdf", RDF::URI) do + Parser.parse(<<-EOR) #{make_xmldecl} EOR - end + end - assert_parse(<<-EOR, :missing_tag, "channel", "RDF") + assert_parse(<<-EOR, :missing_tag, "channel", "RDF") #{make_xmldecl} EOR - assert_parse(<<-EOR, :missing_tag, "channel", "RDF") + assert_parse(<<-EOR, :missing_tag, "channel", "RDF") #{make_xmldecl} EOR - assert_parse(<<-EOR, :missing_tag, "channel", "RDF") + assert_parse(<<-EOR, :missing_tag, "channel", "RDF") #{make_xmldecl} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") #{make_channel} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") #{make_channel} #{make_image} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") #{make_channel} #{make_textinput} EOR - assert_too_much_tag("image", "RDF") do - Parser.parse(make_RDF(<<-EOR)) + assert_too_much_tag("image", "RDF") do + Parser.parse(make_RDF(<<-EOR)) #{make_channel} #{make_image} #{make_image} #{make_item} #{make_textinput} EOR - end + end - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_item} #{make_image} #{make_textinput} EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_item} #{make_textinput} #{make_image} EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} #{make_item} EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} #{make_item} #{make_textinput} EOR - 1.step(15, 3) do |i| - rss = make_RDF() do - res = make_channel - i.times { res << make_item } - res - end - assert_parse(rss, :nothing_raised) - end + 1.step(15, 3) do |i| + rss = make_RDF() do + res = make_channel + i.times { res << make_item } + res + end + assert_parse(rss, :nothing_raised) + end - end + end - def test_channel + def test_channel - assert_parse(make_RDF(<<-EOR), :missing_attribute, "channel", "about") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "channel", "about") EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "channel") + assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "channel") EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "channel") + assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "channel") hoge EOR - assert_parse(make_RDF(< hoge http://example.com/ EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel") + assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel") hoge http://example.com/ @@ -147,7 +147,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "resource") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "resource") hoge http://example.com/ @@ -156,7 +156,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel") + assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel") hoge http://example.com/ @@ -165,7 +165,7 @@ EOR EOR - rss = make_RDF(<<-EOR) + rss = make_RDF(<<-EOR) hoge http://example.com/ @@ -175,15 +175,15 @@ EOR EOR - assert_missing_tag("Seq", "items") do - Parser.parse(rss) - end + assert_missing_tag("Seq", "items") do + Parser.parse(rss) + end - assert_missing_tag("item", "RDF") do - Parser.parse(rss, false).validate - end + assert_missing_tag("item", "RDF") do + Parser.parse(rss, false).validate + end - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") hoge http://example.com/ @@ -196,7 +196,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "resource") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "resource") hoge http://example.com/ @@ -210,7 +210,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") hoge http://example.com/ @@ -224,11 +224,11 @@ EOR EOR - end + end - def test_rdf_li + def test_rdf_li - rss = make_RDF(<<-EOR) + rss = make_RDF(<<-EOR) hoge http://example.com/ @@ -244,41 +244,41 @@ EOR #{make_item} EOR - source = Proc.new do |rdf_li_attr| - eval(%Q[%Q[#{rss}]], binding) - end + source = Proc.new do |rdf_li_attr| + eval(%Q[%Q[#{rss}]], binding) + end - attr = %q[resource="http://example.com/hoge"] - assert_parse(source.call(attr), :nothing_raised) + attr = %q[resource="http://example.com/hoge"] + assert_parse(source.call(attr), :nothing_raised) - attr = %q[rdf:resource="http://example.com/hoge"] - assert_parse(source.call(attr), :nothing_raised) + attr = %q[rdf:resource="http://example.com/hoge"] + assert_parse(source.call(attr), :nothing_raised) - assert_parse(source.call(""), :missing_attribute, "li", "resource") - end + assert_parse(source.call(""), :missing_attribute, "li", "resource") + end - def test_image + def test_image - assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "about") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "about") #{make_channel} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "image") + assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "image") #{make_channel} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "url", "image") + assert_parse(make_RDF(<<-EOR), :missing_tag, "url", "image") #{make_channel} hoge EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "image") + assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "image") #{make_channel} hoge @@ -286,7 +286,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") + assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF") #{make_channel} hoge @@ -295,7 +295,7 @@ EOR EOR - rss = make_RDF(<<-EOR) + rss = make_RDF(<<-EOR) #{make_channel} http://example.com/ @@ -304,33 +304,33 @@ EOR EOR - assert_missing_tag("item", "RDF") do - Parser.parse(rss) - end + assert_missing_tag("item", "RDF") do + Parser.parse(rss) + end - assert_missing_tag("item", "RDF") do - Parser.parse(rss, false).validate - end + assert_missing_tag("item", "RDF") do + Parser.parse(rss, false).validate + end - end + end - def test_item + def test_item - assert_parse(make_RDF(<<-EOR), :missing_attribute, "item", "about") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "item", "about") #{make_channel} #{make_image} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "item") + assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "item") #{make_channel} #{make_image} EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "item") + assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "item") #{make_channel} #{make_image} @@ -338,8 +338,8 @@ EOR EOR - assert_too_much_tag("title", "item") do - Parser.parse(make_RDF(<<-EOR)) + assert_too_much_tag("title", "item") do + Parser.parse(make_RDF(<<-EOR)) #{make_channel} #{make_image} @@ -348,9 +348,9 @@ EOR http://example.com/hoge.html EOR - end + end - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} @@ -359,7 +359,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} @@ -369,11 +369,11 @@ EOR EOR - end + end - def test_textinput + def test_textinput - assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "about") + assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "about") #{make_channel} #{make_image} #{make_item} @@ -381,7 +381,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "textinput") + assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "textinput") #{make_channel} #{make_image} #{make_item} @@ -389,7 +389,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "description", "textinput") + assert_parse(make_RDF(<<-EOR), :missing_tag, "description", "textinput") #{make_channel} #{make_image} #{make_item} @@ -398,8 +398,8 @@ EOR EOR - assert_too_much_tag("title", "textinput") do - Parser.parse(make_RDF(<<-EOR)) + assert_too_much_tag("title", "textinput") do + Parser.parse(make_RDF(<<-EOR)) #{make_channel} #{make_image} #{make_item} @@ -409,9 +409,9 @@ EOR hogehoge EOR - end + end - assert_parse(make_RDF(<<-EOR), :missing_tag, "name", "textinput") + assert_parse(make_RDF(<<-EOR), :missing_tag, "name", "textinput") #{make_channel} #{make_image} #{make_item} @@ -421,7 +421,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "textinput") + assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "textinput") #{make_channel} #{make_image} #{make_item} @@ -432,7 +432,7 @@ EOR EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} #{make_item} @@ -444,170 +444,170 @@ EOR EOR - end + end - def test_rss20 - - assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss") + def test_rss20 + + assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss") EOR - assert_parse(make_rss20(<<-EOR), :nothing_raised) + assert_parse(make_rss20(<<-EOR), :nothing_raised) #{make_channel20("")} EOR - end - - def test_cloud20 - - attrs = [ - ["domain", CLOUD_DOMAIN], - ["port", CLOUD_PORT], - ["path", CLOUD_PATH], - ["registerProcedure", CLOUD_REGISTER_PROCEDURE], - ["protocol", CLOUD_PROTOCOL], - ] - - (attrs.size + 1).times do |i| - missing_attr = attrs[i] - if missing_attr - meth = :missing_attribute - args = ["cloud", missing_attr[0]] - else - meth = :nothing_raised - args = [] - end - - cloud_attrs = [] - attrs.each_with_index do |attr, j| - unless i == j - cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"] - end - end - - assert_parse(make_rss20(<<-EOR), meth, *args) + end + + def test_cloud20 + + attrs = [ + ["domain", CLOUD_DOMAIN], + ["port", CLOUD_PORT], + ["path", CLOUD_PATH], + ["registerProcedure", CLOUD_REGISTER_PROCEDURE], + ["protocol", CLOUD_PROTOCOL], + ] + + (attrs.size + 1).times do |i| + missing_attr = attrs[i] + if missing_attr + meth = :missing_attribute + args = ["cloud", missing_attr[0]] + else + meth = :nothing_raised + args = [] + end + + cloud_attrs = [] + attrs.each_with_index do |attr, j| + unless i == j + cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"] + end + end + + assert_parse(make_rss20(<<-EOR), meth, *args) #{make_channel20(%Q[])} EOR - end + end - end + end - def test_source20 + def test_source20 - assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url") + assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url") #{make_channel20(make_item20(%Q[Example]))} EOR - assert_parse(make_rss20(<<-EOR), :nothing_raised) + assert_parse(make_rss20(<<-EOR), :nothing_raised) #{make_channel20(make_item20(%Q[]))} EOR - assert_parse(make_rss20(<<-EOR), :nothing_raised) + assert_parse(make_rss20(<<-EOR), :nothing_raised) #{make_channel20(make_item20(%Q[Example]))} EOR - end - - def test_enclosure20 - - attrs = [ - ["url", ENCLOSURE_URL], - ["length", ENCLOSURE_LENGTH], - ["type", ENCLOSURE_TYPE], - ] - - (attrs.size + 1).times do |i| - missing_attr = attrs[i] - if missing_attr - meth = :missing_attribute - args = ["enclosure", missing_attr[0]] - else - meth = :nothing_raised - args = [] - end - - enclosure_attrs = [] - attrs.each_with_index do |attr, j| - unless i == j - enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"] - end - end - - assert_parse(make_rss20(<<-EOR), meth, *args) + end + + def test_enclosure20 + + attrs = [ + ["url", ENCLOSURE_URL], + ["length", ENCLOSURE_LENGTH], + ["type", ENCLOSURE_TYPE], + ] + + (attrs.size + 1).times do |i| + missing_attr = attrs[i] + if missing_attr + meth = :missing_attribute + args = ["enclosure", missing_attr[0]] + else + meth = :nothing_raised + args = [] + end + + enclosure_attrs = [] + attrs.each_with_index do |attr, j| + unless i == j + enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"] + end + end + + assert_parse(make_rss20(<<-EOR), meth, *args) #{make_channel20(%Q[ #{make_item20(%Q[ - ])} - ])} -EOR - - end - - end - - def test_category20 - - attrs = [ - ["domain", CATEGORY_DOMAIN], - ] - - (attrs.size + 1).times do |i| - missing_attr = attrs[i] - if missing_attr - meth = :missing_attribute - args = ["category", missing_attr[0]] - else - meth = :nothing_raised - args = [] - end - - category_attrs = [] - attrs.each_with_index do |attr, j| - unless i == j - category_attrs << %Q[#{attr[0]}="#{attr[1]}"] - end - end - - ["", "Example Text"].each do |text| - assert_parse(make_rss20(<<-EOR), meth, *args) + ])} + ])} +EOR + + end + + end + + def test_category20 + + attrs = [ + ["domain", CATEGORY_DOMAIN], + ] + + (attrs.size + 1).times do |i| + missing_attr = attrs[i] + if missing_attr + meth = :missing_attribute + args = ["category", missing_attr[0]] + else + meth = :nothing_raised + args = [] + end + + category_attrs = [] + attrs.each_with_index do |attr, j| + unless i == j + category_attrs << %Q[#{attr[0]}="#{attr[1]}"] + end + end + + ["", "Example Text"].each do |text| + assert_parse(make_rss20(<<-EOR), meth, *args) #{make_channel20(%Q[ #{make_item20(%Q[ #{text} - ])} - ])} + ])} + ])} EOR - end - end + end + end - end + end - def test_ignore + def test_ignore - rss = make_RDF(<<-EOR) + rss = make_RDF(<<-EOR) #{make_channel} #{make_item} EOR - assert_parse(rss, :nothing_raised) + assert_parse(rss, :nothing_raised) - assert_not_excepted_tag("a", "RDF") do - Parser.parse(rss, true, false) - end + assert_not_excepted_tag("a", "RDF") do + Parser.parse(rss, true, false) + end - end + end - def test_default_parser - assert_nothing_raised() do - Parser.default_parser = RSS::AVAILABLE_PARSERS.first - end + def test_default_parser + assert_nothing_raised() do + Parser.default_parser = RSS::AVAILABLE_PARSERS.first + end - assert_raise(RSS::NotValidXMLParser) do - Parser.default_parser = RSS::Parser - end - end + assert_raise(RSS::NotValidXMLParser) do + Parser.default_parser = RSS::Parser + end + end - end + end end diff --git a/test/rss/test_syndication.rb b/test/rss/test_syndication.rb index 0eec3bacc6..9d620089e1 100644 --- a/test/rss/test_syndication.rb +++ b/test/rss/test_syndication.rb @@ -9,117 +9,117 @@ require "rss/1.0" require "rss/syndication" module RSS - class TestSyndication < TestCase - - def setup - @prefix = "sy" - @uri = "http://purl.org/rss/1.0/modules/syndication/" - - @parents = %w(channel) - - t = Time.iso8601("2000-01-01T12:00:05+00:00") - class << t - alias_method(:to_s, :iso8601) - end - - @elems = { - :updatePeriod => "hourly", - :updateFrequency => 2, - :updateBase => t, - } - - @sy_nodes = @elems.collect do |name, value| - "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" - end.join("\n") - - @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) + class TestSyndication < TestCase + + def setup + @prefix = "sy" + @uri = "http://purl.org/rss/1.0/modules/syndication/" + + @parents = %w(channel) + + t = Time.iso8601("2000-01-01T12:00:05+00:00") + class << t + alias_method(:to_s, :iso8601) + end + + @elems = { + :updatePeriod => "hourly", + :updateFrequency => 2, + :updateBase => t, + } + + @sy_nodes = @elems.collect do |name, value| + "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" + end.join("\n") + + @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) #{make_channel(@sy_nodes)} #{make_image()} #{make_item()} #{make_textinput()} EOR - @rss = Parser.parse(@rss_source) - end - - def test_parser - - assert_nothing_raised do - Parser.parse(@rss_source) - end - - @elems.each do |tag, value| - assert_too_much_tag(tag.to_s, "channel") do - Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) + @rss = Parser.parse(@rss_source) + end + + def test_parser + + assert_nothing_raised do + Parser.parse(@rss_source) + end + + @elems.each do |tag, value| + assert_too_much_tag(tag.to_s, "channel") do + Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) #{make_channel(("<" + @prefix + ":" + tag.to_s + ">" + - CGI.escapeHTML(value.to_s) + - "") * 2)} + CGI.escapeHTML(value.to_s) + + "") * 2)} #{make_item} EOR - end - end + end + end - end - - def test_accessor - - t = Time.iso8601("2003-01-01T12:00:23+09:00") - class << t - alias_method(:to_s, :iso8601) - end - - new_value = { - :updatePeriod => "daily", - :updateFrequency => +11, - :updateBase => t, - } - - @elems.each do |name, value| - @parents.each do |parent| - assert_equal(value, @rss.send(parent).send("sy_#{name}")) - @rss.send(parent).send("sy_#{name}=", new_value[name].to_s) - assert_equal(new_value[name], @rss.send(parent).send("sy_#{name}")) - end - end - - %w(hourly daily weekly monthly yearly).each do |x| - @parents.each do |parent| - assert_nothing_raised do - @rss.send(parent).sy_updatePeriod = x - end - end - end - - %w(-2 0.3 -0.4).each do |x| - @parents.each do |parent| - assert_not_available_value("updateBase", x) do - @rss.send(parent).sy_updateBase = x - end - end - end - - end + end + + def test_accessor + + t = Time.iso8601("2003-01-01T12:00:23+09:00") + class << t + alias_method(:to_s, :iso8601) + end + + new_value = { + :updatePeriod => "daily", + :updateFrequency => +11, + :updateBase => t, + } + + @elems.each do |name, value| + @parents.each do |parent| + assert_equal(value, @rss.send(parent).send("sy_#{name}")) + @rss.send(parent).send("sy_#{name}=", new_value[name].to_s) + assert_equal(new_value[name], @rss.send(parent).send("sy_#{name}")) + end + end + + %w(hourly daily weekly monthly yearly).each do |x| + @parents.each do |parent| + assert_nothing_raised do + @rss.send(parent).sy_updatePeriod = x + end + end + end + + %w(-2 0.3 -0.4).each do |x| + @parents.each do |parent| + assert_not_available_value("updateBase", x) do + @rss.send(parent).sy_updateBase = x + end + end + end + + end - def test_to_s - - @elems.each do |name, value| - excepted = "<#{@prefix}:#{name}>#{value}" - @parents.each do |parent| - assert_equal(excepted, @rss.send(parent).send("sy_#{name}_element")) - end - end - - REXML::Document.new(@rss_source).root.each_element do |parent| - if @parents.include?(parent.name) - parent.each_element do |elem| - if elem.namespace == @uri - assert_equal(elem.text, @elems[elem.name.intern].to_s) - end - end - end - end - - end - - end + def test_to_s + + @elems.each do |name, value| + excepted = "<#{@prefix}:#{name}>#{value}" + @parents.each do |parent| + assert_equal(excepted, @rss.send(parent).send("sy_#{name}_element")) + end + end + + REXML::Document.new(@rss_source).root.each_element do |parent| + if @parents.include?(parent.name) + parent.each_element do |elem| + if elem.namespace == @uri + assert_equal(elem.text, @elems[elem.name.intern].to_s) + end + end + end + end + + end + + end end diff --git a/test/rss/test_trackback.rb b/test/rss/test_trackback.rb index ab77cf3fb8..9c4b086cae 100644 --- a/test/rss/test_trackback.rb +++ b/test/rss/test_trackback.rb @@ -10,128 +10,128 @@ require "rss/2.0" require "rss/trackback" module RSS - class TestTrackBack < TestCase - - def setup - @prefix = "trackback" - @uri = "http://madskills.com/public/xml/rss/module/trackback/" - - @parents = %w(item) - - @elems = { - :ping => "http://bar.com/tb.cgi?tb_id=rssplustrackback", - :about => "http://foo.com/trackback/tb.cgi?tb_id=20020923", - } - - @content_nodes = @elems.collect do |name, value| - "<#{@prefix}:#{name} rdf:resource=\"#{CGI.escapeHTML(value.to_s)}\"/>" - end.join("\n") - - @content_nodes2 = @elems.collect do |name, value| - "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" - end.join("\n") - - @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) + class TestTrackBack < TestCase + + def setup + @prefix = "trackback" + @uri = "http://madskills.com/public/xml/rss/module/trackback/" + + @parents = %w(item) + + @elems = { + :ping => "http://bar.com/tb.cgi?tb_id=rssplustrackback", + :about => "http://foo.com/trackback/tb.cgi?tb_id=20020923", + } + + @content_nodes = @elems.collect do |name, value| + "<#{@prefix}:#{name} rdf:resource=\"#{CGI.escapeHTML(value.to_s)}\"/>" + end.join("\n") + + @content_nodes2 = @elems.collect do |name, value| + "<#{@prefix}:#{name}>#{CGI.escapeHTML(value.to_s)}" + end.join("\n") + + @rss_source = make_RDF(<<-EOR, {@prefix => @uri}) #{make_channel()} #{make_image()} #{make_item(@content_nodes)} #{make_textinput()} EOR - @rss = Parser.parse(@rss_source) + @rss = Parser.parse(@rss_source) - @rss20_source = make_rss20(nil, {@prefix => @uri}) do - make_channel20(nil) do - make_item20(@content_nodes2) - end - end + @rss20_source = make_rss20(nil, {@prefix => @uri}) do + make_channel20(nil) do + make_item20(@content_nodes2) + end + end - @rss20 = Parser.parse(@rss20_source, false) - end + @rss20 = Parser.parse(@rss20_source, false) + end - def test_parser + def test_parser - assert_nothing_raised do - Parser.parse(@rss_source) - end + assert_nothing_raised do + Parser.parse(@rss_source) + end - @elems.find_all{|k, v| k == :ping}.each do |tag, value| - assert_too_much_tag(tag.to_s, "item") do - Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) + @elems.find_all{|k, v| k == :ping}.each do |tag, value| + assert_too_much_tag(tag.to_s, "item") do + Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) #{make_channel()} #{make_item(("<" + @prefix + ":" + tag.to_s + " rdf:resource=\"" + - CGI.escapeHTML(value.to_s) + - "\"/>") * 2)} + CGI.escapeHTML(value.to_s) + + "\"/>") * 2)} EOR - end - end + end + end - @elems.find_all{|k, v| k == :about}.each do |tag, value| - assert_missing_tag("trackback:ping", "item") do - Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) + @elems.find_all{|k, v| k == :about}.each do |tag, value| + assert_missing_tag("trackback:ping", "item") do + Parser.parse(make_RDF(<<-EOR, {@prefix => @uri})) #{make_channel()} #{make_item(("<" + @prefix + ":" + tag.to_s + " rdf:resource=\"" + - CGI.escapeHTML(value.to_s) + - "\"/>") * 2)} + CGI.escapeHTML(value.to_s) + + "\"/>") * 2)} EOR - end + end - end + end - end - - def test_accessor - - new_value = { - :ping => "http://baz.com/trackback/tb.cgi?tb_id=20030808", - :about => "http://hoge.com/trackback/tb.cgi?tb_id=90030808", - } - - @elems.each do |name, value| - @parents.each do |parent| - accessor = "#{RSS::TRACKBACK_PREFIX}_#{name}" - target_accessor = "resource" - target = @rss.send(parent).send(accessor) - target20 = @rss20.channel.send(parent, -1) - assert_equal(value, target.send(target_accessor)) - assert_equal(value, target20.send(accessor)) - target.send("#{target_accessor}=", new_value[name].to_s) - if name == :about - # abount is zero or more - target20.send("#{accessor}=", 0, new_value[name].to_s) - else - target20.send("#{accessor}=", new_value[name].to_s) - end - assert_equal(new_value[name], target.send(target_accessor)) - assert_equal(new_value[name], target20.send(accessor)) - end - end - - end + end + + def test_accessor + + new_value = { + :ping => "http://baz.com/trackback/tb.cgi?tb_id=20030808", + :about => "http://hoge.com/trackback/tb.cgi?tb_id=90030808", + } + + @elems.each do |name, value| + @parents.each do |parent| + accessor = "#{RSS::TRACKBACK_PREFIX}_#{name}" + target_accessor = "resource" + target = @rss.send(parent).send(accessor) + target20 = @rss20.channel.send(parent, -1) + assert_equal(value, target.send(target_accessor)) + assert_equal(value, target20.send(accessor)) + target.send("#{target_accessor}=", new_value[name].to_s) + if name == :about + # abount is zero or more + target20.send("#{accessor}=", 0, new_value[name].to_s) + else + target20.send("#{accessor}=", new_value[name].to_s) + end + assert_equal(new_value[name], target.send(target_accessor)) + assert_equal(new_value[name], target20.send(accessor)) + end + end + + end - def test_to_s - - @elems.each do |name, value| - excepted = %Q!<#{@prefix}:#{name} rdf:resource="#{CGI.escapeHTML(value)}"/>! - @parents.each do |parent| - meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element" - meth << "s" if name == :about - assert_equal(excepted, @rss.send(parent).send(meth)) - end - end - - REXML::Document.new(@rss_source).root.each_element do |parent| - if @parents.include?(parent.name) - parent.each_element do |elem| - if elem.namespace == @uri - assert_equal(elem.attributes["resource"], @elems[elem.name.intern]) - end - end - end - end - - end - - end + def test_to_s + + @elems.each do |name, value| + excepted = %Q!<#{@prefix}:#{name} rdf:resource="#{CGI.escapeHTML(value)}"/>! + @parents.each do |parent| + meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element" + meth << "s" if name == :about + assert_equal(excepted, @rss.send(parent).send(meth)) + end + end + + REXML::Document.new(@rss_source).root.each_element do |parent| + if @parents.include?(parent.name) + parent.each_element do |elem| + if elem.namespace == @uri + assert_equal(elem.attributes["resource"], @elems[elem.name.intern]) + end + end + end + end + + end + + end end diff --git a/test/rss/test_xml-stylesheet.rb b/test/rss/test_xml-stylesheet.rb index ed056257d6..f3dee2c63b 100644 --- a/test/rss/test_xml-stylesheet.rb +++ b/test/rss/test_xml-stylesheet.rb @@ -8,103 +8,103 @@ require "rss/1.0" require "rss/xml-stylesheet" module RSS - class TestXMLStyleSheet < TestCase - - def test_accessor - [ - {:href => "a.xsl", :type => "text/xsl"}, - {:media => "print", :title => "FOO"}, - {:charset => "UTF-8", :alternate => "yes"}, - ].each do |attrs| - assert_xml_stylesheet_attrs(XMLStyleSheet.new(*attrs), attrs) - end - end - - def test_to_s - [ - {:href => "a.xsl", :type => "text/xsl"}, - {:type => "text/xsl"}, - {:href => "a.xsl", :guess_type => "text/xsl"}, - {:href => "a.css", :type => "text/css"}, - {:href => "a.css", :type => "text/xsl", - :guess_type => "text/css"}, - {:href => "a.xsl", :type => "text/xsl", - :title => "sample", :media => "printer", - :charset => "UTF-8", :alternate => "yes"}, - {:href => "a.css", :guess_type => "text/css", - :alternate => "no"}, - {:type => "text/xsl", :title => "sample", - :media => "printer", :charset => "UTF-8", - :alternate => "yes"}, - ].each do |attrs| - target, contents = parse_pi(XMLStyleSheet.new(*attrs).to_s) - assert_xml_stylesheet(target, XMLStyleSheet.new(*contents), attrs) - end - end - - def test_bad_alternate - %w(a ___ ??? BAD_ALTERNATE).each do |value| - xss = XMLStyleSheet.new - assert_raise(NotAvailableValueError) do - xss.alternate = value - end - xss.do_validate = false - assert_nothing_raised do - xss.alternate = value - end - assert_nil(xss.alternate) - end - end - - def test_parse - [ - [{:href => "a.xsl", :type => "text/xsl"},], - [{:media => "print", :title => "FOO"},], - [{:charset => "UTF-8", :alternate => "yes"},], - [{:href => "a.xsl", :type => "text/xsl"}, - {:type => "text/xsl"}, - {:href => "a.xsl", :guess_type => "text/xsl"}, - {:href => "a.css", :type => "text/css"}, - {:href => "a.css", :type => "text/xsl", - :guess_type => "text/css"}, - {:href => "a.xsl", :type => "text/xsl", - :title => "sample", :media => "printer", - :charset => "UTF-8", :alternate => "yes"}, - {:href => "a.css", :guess_type => "text/css", - :alternate => "no"}, - {:type => "text/xsl", :title => "sample", - :media => "printer", :charset => "UTF-8", - :alternate => "yes"},], - ].each do |xsss| - doc = REXML::Document.new(make_sample_RDF) - root = doc.root - xsss.each do |xss| - content = xss.collect do |key, name| - %Q[#{key}="#{name}"] - end.join(" ") - pi = REXML::Instruction.new("xml-stylesheet", content) - root.previous_sibling = pi - end - rss = Parser.parse(doc.to_s) - have_href_xsss = xsss.find_all {|xss| xss.has_key?(:href)} - assert_equal(have_href_xsss.size, rss.xml_stylesheets.size) - rss.xml_stylesheets.each_with_index do |stylesheet, i| - target, = parse_pi(stylesheet.to_s) - assert_xml_stylesheet(target, stylesheet, have_href_xsss[i]) - end - end - end - - def parse_pi(pi) - /\A\s*<\?(\S+)([^(?:\?>)]+)\?>\s*\z/ =~ pi - target = $1 - dummy = REXML::Document.new("").root - contents = {} - dummy.attributes.each do |name, value| - contents[name] = value - end - [target, contents] - end - - end + class TestXMLStyleSheet < TestCase + + def test_accessor + [ + {:href => "a.xsl", :type => "text/xsl"}, + {:media => "print", :title => "FOO"}, + {:charset => "UTF-8", :alternate => "yes"}, + ].each do |attrs| + assert_xml_stylesheet_attrs(XMLStyleSheet.new(*attrs), attrs) + end + end + + def test_to_s + [ + {:href => "a.xsl", :type => "text/xsl"}, + {:type => "text/xsl"}, + {:href => "a.xsl", :guess_type => "text/xsl"}, + {:href => "a.css", :type => "text/css"}, + {:href => "a.css", :type => "text/xsl", + :guess_type => "text/css"}, + {:href => "a.xsl", :type => "text/xsl", + :title => "sample", :media => "printer", + :charset => "UTF-8", :alternate => "yes"}, + {:href => "a.css", :guess_type => "text/css", + :alternate => "no"}, + {:type => "text/xsl", :title => "sample", + :media => "printer", :charset => "UTF-8", + :alternate => "yes"}, + ].each do |attrs| + target, contents = parse_pi(XMLStyleSheet.new(*attrs).to_s) + assert_xml_stylesheet(target, XMLStyleSheet.new(*contents), attrs) + end + end + + def test_bad_alternate + %w(a ___ ??? BAD_ALTERNATE).each do |value| + xss = XMLStyleSheet.new + assert_raise(NotAvailableValueError) do + xss.alternate = value + end + xss.do_validate = false + assert_nothing_raised do + xss.alternate = value + end + assert_nil(xss.alternate) + end + end + + def test_parse + [ + [{:href => "a.xsl", :type => "text/xsl"},], + [{:media => "print", :title => "FOO"},], + [{:charset => "UTF-8", :alternate => "yes"},], + [{:href => "a.xsl", :type => "text/xsl"}, + {:type => "text/xsl"}, + {:href => "a.xsl", :guess_type => "text/xsl"}, + {:href => "a.css", :type => "text/css"}, + {:href => "a.css", :type => "text/xsl", + :guess_type => "text/css"}, + {:href => "a.xsl", :type => "text/xsl", + :title => "sample", :media => "printer", + :charset => "UTF-8", :alternate => "yes"}, + {:href => "a.css", :guess_type => "text/css", + :alternate => "no"}, + {:type => "text/xsl", :title => "sample", + :media => "printer", :charset => "UTF-8", + :alternate => "yes"},], + ].each do |xsss| + doc = REXML::Document.new(make_sample_RDF) + root = doc.root + xsss.each do |xss| + content = xss.collect do |key, name| + %Q[#{key}="#{name}"] + end.join(" ") + pi = REXML::Instruction.new("xml-stylesheet", content) + root.previous_sibling = pi + end + rss = Parser.parse(doc.to_s) + have_href_xsss = xsss.find_all {|xss| xss.has_key?(:href)} + assert_equal(have_href_xsss.size, rss.xml_stylesheets.size) + rss.xml_stylesheets.each_with_index do |stylesheet, i| + target, = parse_pi(stylesheet.to_s) + assert_xml_stylesheet(target, stylesheet, have_href_xsss[i]) + end + end + end + + def parse_pi(pi) + /\A\s*<\?(\S+)([^(?:\?>)]+)\?>\s*\z/ =~ pi + target = $1 + dummy = REXML::Document.new("").root + contents = {} + dummy.attributes.each do |name, value| + contents[name] = value + end + [target, contents] + end + + end end -- cgit v1.2.3