summaryrefslogtreecommitdiff
path: root/lib/rss
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 04:23:09 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 04:23:09 +0000
commit1f84e89cf45158c2ddca44b7823bbcadbca9d732 (patch)
tree74322fcc1cc7d03a01f24da5882c08ba02f6785d /lib/rss
parenta3035403104c322b9326739bcc9c7ef7e3b45bcf (diff)
* lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 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/branches/ruby_1_8@14753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss')
-rw-r--r--lib/rss/parser.rb30
-rw-r--r--lib/rss/rss.rb2
2 files changed, 17 insertions, 15 deletions
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index 0c76d8fdff..9e4919223c 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -194,11 +194,7 @@ module RSS
# return the tag_names for setters associated with uri
def available_tags(uri)
- begin
- @@accessor_bases[uri].keys
- rescue NameError
- []
- end
+ (@@accessor_bases[uri] || {}).keys
end
# register uri against this name.
@@ -221,11 +217,13 @@ module RSS
# retrieve class_name for the supplied uri and tag_name
# If it doesn't exist, capitalize the tag_name
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)
@@ -448,12 +446,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
@@ -482,14 +482,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
@@ -510,9 +514,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 2fe7ca9fb7..04dfdf8052 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -52,7 +52,7 @@ require "rss/xml-stylesheet"
module RSS
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
URI = "http://purl.org/rss/1.0/"