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

* lib/rss, sample/rss, test/rss:

- 0.1.7 -> 0.1.8.
  - supported <itunes:XXX>.
  - reverted backward incompatibility API changes introduced 0.1.7.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2007-08-05 03:03:05 +00:00
parent 43009063c7
commit 71976790ec
43 changed files with 3055 additions and 1457 deletions

View file

@ -222,25 +222,22 @@ module RSS
@@accessor_bases[uri][tag_name] = accessor_base.chomp("=")
end
def def_get_text_element(uri, name, file, line)
register_uri(uri, name)
unless private_instance_methods(false).include?("start_#{name}".to_sym)
module_eval(<<-EOT, file, line)
def start_#{name}(name, prefix, attrs, ns)
def def_get_text_element(uri, element_name, file, line)
register_uri(uri, element_name)
method_name = "start_#{element_name}"
unless private_method_defined?(method_name)
define_method(method_name) do |name, prefix, attrs, ns|
uri = _ns(ns, prefix)
if self.class.uri_registered?(uri, #{name.inspect})
if self.class.uri_registered?(uri, element_name)
start_get_text_element(name, prefix, ns, uri)
else
start_else_element(name, prefix, attrs, ns)
end
end
EOT
__send!("private", "start_#{name}")
private(method_name)
end
end
end
end
module ListenerMixin
@ -368,10 +365,10 @@ module RSS
def start_else_element(local, prefix, attrs, ns)
class_name = self.class.class_name(_ns(ns, prefix), local)
current_class = @last_element.class
if current_class.const_defined?(class_name)
next_class = nil
begin
next_class = current_class.const_get(class_name)
start_have_something_element(local, prefix, attrs, ns, next_class)
else
rescue NameError
if !@do_validate or @ignore_unknown_element
@proc_stack.push(nil)
else
@ -382,6 +379,9 @@ module RSS
raise NotExpectedTagError.new(local, _ns(ns, prefix), parent)
end
end
if next_class
start_have_something_element(local, prefix, attrs, ns, next_class)
end
end
NAMESPLIT = /^(?:([\w:][-\w\d.]*):)?([\w:][-\w\d.]*)/
@ -460,7 +460,7 @@ module RSS
previous = @last_element
next_element = klass.new(@do_validate, attributes)
previous.__send!(:set_next_element, tag_name, next_element)
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?