aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rss/rss.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-06 17:43:05 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-06 17:43:05 +0000
commite289fcf81a22f1dc6ebcb87861877b463af04b7c (patch)
treeef88a6dfdfc68d57025eb98ab6fe8d237c3adccd /lib/rss/rss.rb
parent9800838ff02369fa9e393b70f40b6083af0ce595 (diff)
downloadruby-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/rss.rb')
-rw-r--r--lib/rss/rss.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index 9c616238fe..b06cf68d81 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -35,6 +35,20 @@ class Time
end
end
+module Enumerable
+ unless instance_methods.include?("sort_by")
+ def sort_by
+ collect do |x|
+ [yield(x), x]
+ end.sort do |x, y|
+ x[0] <=> y[0]
+ end.collect! do |x|
+ x[1]
+ end
+ end
+ end
+end
+
require "English"
require "rss/utils"
require "rss/converter"
@@ -42,7 +56,9 @@ require "rss/xml-stylesheet"
module RSS
- VERSION = "0.0.8"
+ VERSION = "0.0.9"
+
+ URI = "http://purl.org/rss/1.0/"
DEBUG = false
@@ -298,8 +314,6 @@ EOC
end
- URI = "http://purl.org/rss/1.0/"
-
class Element
extend BaseModel
@@ -314,7 +328,7 @@ EOC
TAG_NAME = name.split('::').last.downcase
- @@must_call_validators = {::RSS::URI => ''}
+ @@must_call_validators = {}
def self.must_call_validators
@@must_call_validators
@@ -427,6 +441,7 @@ EOC
end
def validate_for_stream(tags)
+ validate_attribute
__validate(tags, false)
end
@@ -504,6 +519,11 @@ EOC
do_redo = false
not_shift = false
tag = nil
+ element_names = model.collect {|elem| elem[0]}
+ if tags
+ tags_size = tags.size
+ tags = tags.sort_by {|x| element_names.index(x) || tags_size}
+ end
model.each_with_index do |elem, i|