From 3d8fa5556164f3aa2f6f1733ffe4a96fc4f33ed8 Mon Sep 17 00:00:00 2001 From: kou Date: Mon, 5 Jul 2004 15:15:04 +0000 Subject: [PATCH] * lib/rss/{trackback,syndication,dublincore,content}.rb: worked with ruby 1.6 again. * test/rss/rss-assertions.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++++ lib/rss/content.rb | 6 ++-- lib/rss/dublincore.rb | 6 ++-- lib/rss/syndication.rb | 6 ++-- lib/rss/trackback.rb | 65 +++++++++++++++++++------------------- test/rss/rss-assertions.rb | 12 +++++++ 6 files changed, 63 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index a88ce52f7b..a5d3321c1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jul 5 23:56:42 2004 Kouhei Sutou + + * lib/rss/{trackback,syndication,dublincore,content}.rb: worked + with ruby 1.6 again. + + * test/rss/rss-assertions.rb: ditto. + Mon Jul 5 22:54:39 2004 Tanaka Akira * lib/uri/common.rb (Kernel#URI): new global method for parsing URIs. diff --git a/lib/rss/content.rb b/lib/rss/content.rb index fae0b687be..a8ed962644 100644 --- a/lib/rss/content.rb +++ b/lib/rss/content.rb @@ -13,8 +13,10 @@ module RSS ELEMENTS = [] - def self.included(mod) - mod.module_eval(<<-EOC) + def self.append_features(klass) + super + + klass.module_eval(<<-EOC) %w(encoded).each do |x| install_text_element("\#{CONTENT_PREFIX}_\#{x}") end diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb index dcf8e46c65..c757b6279b 100644 --- a/lib/rss/dublincore.rb +++ b/lib/rss/dublincore.rb @@ -13,8 +13,10 @@ module RSS ELEMENTS = [] - def self.included(mod) - mod.module_eval(<<-EOC) + def self.append_features(klass) + super + + klass.module_eval(<<-EOC) %w(title description creator subject publisher contributor type format identifier source language relation coverage rights).each do |x| diff --git a/lib/rss/syndication.rb b/lib/rss/syndication.rb index 8c10688b57..aca39bb374 100644 --- a/lib/rss/syndication.rb +++ b/lib/rss/syndication.rb @@ -13,8 +13,10 @@ module RSS ELEMENTS = [] - def self.included(mod) - mod.module_eval(<<-EOC) + def self.append_features(klass) + super + + klass.module_eval(<<-EOC) %w(updatePeriod updateFrequency).each do |x| install_text_element("\#{SY_PREFIX}_\#{x}") end diff --git a/lib/rss/trackback.rb b/lib/rss/trackback.rb index 493e742453..ae33ff8854 100644 --- a/lib/rss/trackback.rb +++ b/lib/rss/trackback.rb @@ -3,24 +3,23 @@ require 'rss/2.0' module RSS - TRACKBACK_PREFIX = 'trackback' - TRACKBACK_URI = 'http://madskills.com/public/xml/rss/module/trackback/' + TRACKBACK_PREFIX = 'trackback' + TRACKBACK_URI = 'http://madskills.com/public/xml/rss/module/trackback/' - RDF.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) - Rss.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) + RDF.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) + Rss.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) module BaseTrackBackModel - def trackback_validate(tags) - raise unless @do_validate - counter = {} - %w(ping about).each do |x| + def trackback_validate(tags) + counter = {} + %w(ping about).each do |x| counter["#{TRACKBACK_PREFIX}_#{x}"] = 0 end - tags.each do |tag| - key = "#{TRACKBACK_PREFIX}_#{tag}" - raise UnknownTagError.new(tag, TRACKBACK_URI) unless counter.has_key?(key) - counter[key] += 1 + tags.each do |tag| + key = "#{TRACKBACK_PREFIX}_#{tag}" + raise UnknownTagError.new(tag, TRACKBACK_URI) unless counter.has_key?(key) + counter[key] += 1 if tag != "about" and counter[key] > 1 raise TooMuchTagError.new(tag, tag_name) end @@ -33,8 +32,8 @@ module RSS end end - module TrackBackModel10 - extend BaseModel + module TrackBackModel10 + extend BaseModel include BaseTrackBackModel def self.append_features(klass) @@ -211,24 +210,24 @@ module RSS EOC end end - - private - def new_with_content(klass, content) - obj = klass.new - obj.content = content - obj - end - - def new_with_content_if_need(klass, content) - if content.is_a?(klass) - content - else - new_with_content(klass, content) - end - end - end + private + def new_with_content(klass, content) + obj = klass.new + obj.content = content + obj + end + + def new_with_content_if_need(klass, content) + if content.is_a?(klass) + content + else + new_with_content(klass, content) + end + end + + class Ping < Element include RSS09 @@ -288,9 +287,9 @@ module RSS end end - class RDF - class Item; include TrackBackModel10; end - end + class RDF + class Item; include TrackBackModel10; end + end class Rss class Channel diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb index db9c39dd28..ad7da1f6b4 100644 --- a/test/rss/rss-assertions.rb +++ b/test/rss/rss-assertions.rb @@ -1,4 +1,16 @@ # -*- 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 +end module RSS module Assertions