diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 17:43:05 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 17:43:05 +0000 |
commit | e289fcf81a22f1dc6ebcb87861877b463af04b7c (patch) | |
tree | ef88a6dfdfc68d57025eb98ab6fe8d237c3adccd /lib/rss/2.0.rb | |
parent | 9800838ff02369fa9e393b70f40b6083af0ce595 (diff) | |
download | ruby-e289fcf81a22f1dc6ebcb87861877b463af04b7c.tar.gz |
* lib/rss/{rss,parser,0.9,1.0,2.0}.rb: supported RSS 0.9x/2.0
validation and validation which disregard order of elements.
* test/rss/test_parser.rb: added tests for RSS 0.9x/2.0
validation.
* test/rss/{test_trackback,rss-testcase}.rb: fixed no good method
name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss/2.0.rb')
-rw-r--r-- | lib/rss/2.0.rb | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/lib/rss/2.0.rb b/lib/rss/2.0.rb index c83fb2c393..c6c6db58a7 100644 --- a/lib/rss/2.0.rb +++ b/lib/rss/2.0.rb @@ -4,30 +4,21 @@ module RSS class Rss -# URI = "http://backend.userland.com/rss2" - -# install_ns('', URI) - -# def self.required_uri -# URI -# end - class Channel -# def self.required_uri -# URI -# end - %w(generator ttl).each do |x| install_text_element(x) + install_model(x, '?') end %w(category).each do |x| install_have_child_element(x) + install_model(x, '?') end [ ["image", "?"], + ["language", "?"], ].each do |x, occurs| install_model(x, occurs) end @@ -40,17 +31,33 @@ module RSS EOT rv << super end + + private + alias children09 children + def children + children09 + [@category].compact + end + + alias _tags09 _tags + def _tags + %w(generator ttl category).delete_if do |x| + send(x).nil? + end.collect do |elem| + [nil, elem] + end + _tags09 + end Category = Item::Category -# def Category.required_uri -# URI -# end class Item -# def self.required_uri -# URI -# end + [ + ["comments", "?"], + ["author", "?"], + ].each do |x, occurs| + install_text_element(x) + install_model(x, occurs) + end [ ["pubDate", '?'], @@ -68,20 +75,33 @@ EOT def other_element(convert, indent='') rv = <<-EOT +#{indent}#{author_element(false)} +#{indent}#{comments_element(false)} #{indent}#{pubDate_element(false)} #{indent}#{guid_element(false)} EOT rv << super end + private + alias children09 children + def children + children09 + [@guid].compact + end + + alias _tags09 _tags + def _tags + %w(comments author pubDate guid).delete_if do |x| + send(x).nil? + end.collect do |elem| + [nil, elem] + end + _tags09 + end + class Guid < Element include RSS09 -# def self.required_uri -# URI -# end - [ ["isPermaLink", nil, false] ].each do |name, uri, required| @@ -124,24 +144,7 @@ EOT end RSS09::ELEMENTS.each do |x| -# BaseListener.install_get_text_element(x, Rss::URI, "#{x}=") BaseListener.install_get_text_element(x, nil, "#{x}=") end - module ListenerMixin - private - alias start_rss09 start_rss - def start_rss(tag_name, prefix, attrs, ns) -# check_ns(tag_name, prefix, ns, Rss::URI) - - @rss = Rss.new(attrs['version'], @version, @encoding, @standalone) - @rss.xml_stylesheets = @xml_stylesheets - @last_element = @rss - @proc_stack.push Proc.new { |text, tags| - @rss.validate_for_stream(tags) if @do_validate - } - end - - end - end |