1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/branches/ruby_1_8@6585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2004-07-05 15:15:04 +00:00
parent 74f6b8e7c9
commit d9034d23ce
6 changed files with 63 additions and 39 deletions

View file

@ -1,3 +1,10 @@
Mon Jul 5 23:56:42 2004 Kouhei Sutou <kou@cozmixng.org>
* 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 <akr@m17n.org> Mon Jul 5 22:54:39 2004 Tanaka Akira <akr@m17n.org>
* lib/uri/common.rb (Kernel#URI): new global method for parsing URIs. * lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.

View file

@ -13,8 +13,10 @@ module RSS
ELEMENTS = [] ELEMENTS = []
def self.included(mod) def self.append_features(klass)
mod.module_eval(<<-EOC) super
klass.module_eval(<<-EOC)
%w(encoded).each do |x| %w(encoded).each do |x|
install_text_element("\#{CONTENT_PREFIX}_\#{x}") install_text_element("\#{CONTENT_PREFIX}_\#{x}")
end end

View file

@ -13,8 +13,10 @@ module RSS
ELEMENTS = [] ELEMENTS = []
def self.included(mod) def self.append_features(klass)
mod.module_eval(<<-EOC) super
klass.module_eval(<<-EOC)
%w(title description creator subject publisher %w(title description creator subject publisher
contributor type format identifier source contributor type format identifier source
language relation coverage rights).each do |x| language relation coverage rights).each do |x|

View file

@ -13,8 +13,10 @@ module RSS
ELEMENTS = [] ELEMENTS = []
def self.included(mod) def self.append_features(klass)
mod.module_eval(<<-EOC) super
klass.module_eval(<<-EOC)
%w(updatePeriod updateFrequency).each do |x| %w(updatePeriod updateFrequency).each do |x|
install_text_element("\#{SY_PREFIX}_\#{x}") install_text_element("\#{SY_PREFIX}_\#{x}")
end end

View file

@ -3,24 +3,23 @@ require 'rss/2.0'
module RSS module RSS
TRACKBACK_PREFIX = 'trackback' TRACKBACK_PREFIX = 'trackback'
TRACKBACK_URI = 'http://madskills.com/public/xml/rss/module/trackback/' TRACKBACK_URI = 'http://madskills.com/public/xml/rss/module/trackback/'
RDF.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) RDF.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI)
Rss.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI) Rss.install_ns(TRACKBACK_PREFIX, TRACKBACK_URI)
module BaseTrackBackModel module BaseTrackBackModel
def trackback_validate(tags) def trackback_validate(tags)
raise unless @do_validate counter = {}
counter = {} %w(ping about).each do |x|
%w(ping about).each do |x|
counter["#{TRACKBACK_PREFIX}_#{x}"] = 0 counter["#{TRACKBACK_PREFIX}_#{x}"] = 0
end end
tags.each do |tag| tags.each do |tag|
key = "#{TRACKBACK_PREFIX}_#{tag}" key = "#{TRACKBACK_PREFIX}_#{tag}"
raise UnknownTagError.new(tag, TRACKBACK_URI) unless counter.has_key?(key) raise UnknownTagError.new(tag, TRACKBACK_URI) unless counter.has_key?(key)
counter[key] += 1 counter[key] += 1
if tag != "about" and counter[key] > 1 if tag != "about" and counter[key] > 1
raise TooMuchTagError.new(tag, tag_name) raise TooMuchTagError.new(tag, tag_name)
end end
@ -33,8 +32,8 @@ module RSS
end end
end end
module TrackBackModel10 module TrackBackModel10
extend BaseModel extend BaseModel
include BaseTrackBackModel include BaseTrackBackModel
def self.append_features(klass) def self.append_features(klass)
@ -211,24 +210,24 @@ module RSS
EOC EOC
end 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
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 class Ping < Element
include RSS09 include RSS09
@ -288,9 +287,9 @@ module RSS
end end
end end
class RDF class RDF
class Item; include TrackBackModel10; end class Item; include TrackBackModel10; end
end end
class Rss class Rss
class Channel class Channel

View file

@ -1,4 +1,16 @@
# -*- tab-width: 2 -*- vim: ts=2 # -*- 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 RSS
module Assertions module Assertions