diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-08 13:54:07 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-08 13:54:07 +0000 |
commit | 1909f5f1b14167bc24bcccd1500a27a42551fa95 (patch) | |
tree | b34f305a080caa00705e89b43fa7d18d986b1be1 /lib/rss/2.0.rb | |
parent | 037d21402b457af9d96737c7590a800877c6bfd8 (diff) |
* 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/branches/ruby_1_8@6601 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 |