summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 04:20:47 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 04:20:47 +0000
commit9343a2deb3c72047d0aee1449d185d066ca89b44 (patch)
treed52babeefce01e70b0e9a265fdbf3284842fd131
parent0d7405b69fe5f39108ed665429737b3438f979c8 (diff)
* lib/rss/rss.rb, test/rss/test_version.rb: 0.2.2 -> 0.2.3.
* lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name. Reported by Ray Chen. Thanks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/rss/parser.rb30
-rw-r--r--lib/rss/rss.rb2
-rw-r--r--test/rss/test_parser.rb12
-rw-r--r--test/rss/test_version.rb2
5 files changed, 37 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e15a1d29b..a3418a1b84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Dec 28 13:18:47 2007 Kouhei Sutou <kou@cozmixng.org>
+
+ * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.2 -> 0.2.3.
+
+ * lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
+ Reported by Ray Chen. Thanks.
+
Fri Dec 28 13:07:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (os_obj_of): returns an enumerator if no block given. based on
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index 7f5f57a1ea..438c63b4ca 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -178,11 +178,7 @@ module RSS
end
def available_tags(uri)
- begin
- @@accessor_bases[uri].keys
- rescue NameError
- []
- end
+ (@@accessor_bases[uri] || {}).keys
end
def register_uri(uri, name)
@@ -200,11 +196,13 @@ module RSS
end
def class_name(uri, tag_name)
- begin
- @@class_names[uri][tag_name]
- rescue NameError
- tag_name[0,1].upcase + tag_name[1..-1]
+ name = (@@class_names[uri] || {})[tag_name]
+ return name if name
+
+ tag_name = tag_name.gsub(/[_\-]([a-z]?)/) do
+ $1.upcase
end
+ tag_name[0, 1].upcase + tag_name[1..-1]
end
def install_get_text_element(uri, name, accessor_base)
@@ -422,12 +420,14 @@ module RSS
end
def start_have_something_element(tag_name, prefix, attrs, ns, klass)
-
check_ns(tag_name, prefix, ns, klass.required_uri)
+ attributes = collect_attributes(tag_name, prefix, attrs, ns, klass)
+ @proc_stack.push(setup_next_element(tag_name, klass, attributes))
+ end
+ def collect_attributes(tag_name, prefix, attrs, ns, klass)
attributes = {}
klass.get_attributes.each do |a_name, a_uri, required, element_name|
-
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
a_uri = [a_uri]
end
@@ -456,14 +456,18 @@ module RSS
attributes[a_name] = val
end
+ attributes
+ end
+ def setup_next_element(tag_name, klass, attributes)
previous = @last_element
next_element = klass.new(@do_validate, attributes)
previous.set_next_element(tag_name, next_element)
@last_element = next_element
@last_element.parent = previous if klass.need_parent?
@xml_child_mode = @last_element.have_xml_content?
- pr = Proc.new do |text, tags|
+
+ Proc.new do |text, tags|
p(@last_element.class) if DEBUG
if @xml_child_mode
@last_element.content = @xml_element.to_s
@@ -484,9 +488,7 @@ module RSS
end
@last_element = previous
end
- @proc_stack.push(pr)
end
-
end
unless const_defined? :AVAILABLE_PARSER_LIBRARIES
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index 32741b03d1..d00d4c5a47 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -53,7 +53,7 @@ require "rss/xml-stylesheet"
module RSS
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
URI = "http://purl.org/rss/1.0/"
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 59458ef51b..2e8c9be4d3 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -46,5 +46,17 @@ EOR
assert_nil(RSS::Parser.parse(garbage_rss_file))
end
end
+
+ def test_parse_tag_includes_hyphen
+ assert_nothing_raised do
+ RSS::Parser.parse(make_RDF(<<-EOR))
+<xCal:x-calconnect-venue xmlns:xCal="urn:ietf:params:xml:ns:xcal" />
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+EOR
+ end
+ end
end
end
diff --git a/test/rss/test_version.rb b/test/rss/test_version.rb
index a602caf103..8f6771a4f3 100644
--- a/test/rss/test_version.rb
+++ b/test/rss/test_version.rb
@@ -3,7 +3,7 @@ require "rss-testcase"
module RSS
class TestVersion < TestCase
def test_version
- assert_equal("0.2.2", ::RSS::VERSION)
+ assert_equal("0.2.3", ::RSS::VERSION)
end
end
end