mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/parser.rb: @@setter -> @@setters.
* lib/rss/parser.rb (RSS::BaseListener.register_uri) (RSS::BaseListener.uri_registered?) (RSS::BaseListener.install_get_text_element): swapped the first argument and the second argument. * lib/rss/taxonomy.rb: swapped the first argument and the second argument for RSS::BaseListener.install_get_text_element. * lib/rss/image.rb: ditto. * lib/rss/syndication.rb: ditto. * lib/rss/dublincore.rb: ditto. * lib/rss/parser.rb: ditto. * lib/rss/1.0.rb: ditto. * lib/rss/2.0.rb: ditto. * lib/rss/0.9.rb: ditto. * lib/rss/content.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8c3300069
commit
b7891928a3
10 changed files with 46 additions and 25 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
Thu Mar 31 11:07:50 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/parser.rb: @@setter -> @@setters.
|
||||
|
||||
* lib/rss/parser.rb
|
||||
(RSS::BaseListener.register_uri)
|
||||
(RSS::BaseListener.uri_registered?)
|
||||
(RSS::BaseListener.install_get_text_element):
|
||||
swapped the first argument and the second argument.
|
||||
|
||||
* lib/rss/taxonomy.rb: swapped the first argument and the second
|
||||
argument for RSS::BaseListener.install_get_text_element.
|
||||
* lib/rss/image.rb: ditto.
|
||||
* lib/rss/syndication.rb: ditto.
|
||||
* lib/rss/dublincore.rb: ditto.
|
||||
* lib/rss/parser.rb: ditto.
|
||||
* lib/rss/1.0.rb: ditto.
|
||||
* lib/rss/2.0.rb: ditto.
|
||||
* lib/rss/0.9.rb: ditto.
|
||||
* lib/rss/content.rb: ditto.
|
||||
|
||||
Thu Mar 31 11:00:36 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/parser.rb
|
||||
|
|
|
@ -645,7 +645,7 @@ module RSS
|
|||
end
|
||||
|
||||
RSS09::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x, nil, "#{x}=")
|
||||
BaseListener.install_get_text_element(nil, x, "#{x}=")
|
||||
end
|
||||
|
||||
module ListenerMixin
|
||||
|
|
|
@ -629,7 +629,7 @@ module RSS
|
|||
end
|
||||
|
||||
RSS10::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x, URI, "#{x}=")
|
||||
BaseListener.install_get_text_element(URI, x, "#{x}=")
|
||||
end
|
||||
|
||||
module ListenerMixin
|
||||
|
|
|
@ -163,7 +163,7 @@ EOT
|
|||
end
|
||||
|
||||
RSS09::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x, nil, "#{x}=")
|
||||
BaseListener.install_get_text_element(nil, x, "#{x}=")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ module RSS
|
|||
prefix_size = CONTENT_PREFIX.size + 1
|
||||
ContentModel::ELEMENTS.uniq!
|
||||
ContentModel::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x[prefix_size..-1], CONTENT_URI, "#{x}=")
|
||||
BaseListener.install_get_text_element(CONTENT_URI, x[prefix_size..-1], "#{x}=")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -59,7 +59,7 @@ module RSS
|
|||
|
||||
prefix_size = DC_PREFIX.size + 1
|
||||
DublinCoreModel::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x[prefix_size..-1], DC_URI, "#{x}=")
|
||||
BaseListener.install_get_text_element(DC_URI, x[prefix_size..-1], "#{x}=")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ module RSS
|
|||
%w(width height).each do |tag|
|
||||
full_name = "#{IMAGE_PREFIX}_#{tag}"
|
||||
install_text_element(full_name)
|
||||
BaseListener.install_get_text_element(tag, IMAGE_URI, "#{full_name}=")
|
||||
BaseListener.install_get_text_element(IMAGE_URI, tag, "#{full_name}=")
|
||||
end
|
||||
|
||||
def initialize(about=nil, resource=nil)
|
||||
|
|
|
@ -123,26 +123,17 @@ module RSS
|
|||
|
||||
class << self
|
||||
|
||||
@@setter = {}
|
||||
@@setters = {}
|
||||
@@registered_uris = {}
|
||||
|
||||
def install_setter(uri, tag_name, setter)
|
||||
@@setter[uri] ||= {}
|
||||
@@setter[uri][tag_name] = setter
|
||||
end
|
||||
|
||||
def register_uri(name, uri)
|
||||
@@registered_uris[name] ||= {}
|
||||
@@registered_uris[name][uri] = nil
|
||||
end
|
||||
|
||||
def uri_registered?(name, uri)
|
||||
@@registered_uris[name].has_key?(uri)
|
||||
@@setters[uri] ||= {}
|
||||
@@setters[uri][tag_name] = setter
|
||||
end
|
||||
|
||||
def setter(uri, tag_name)
|
||||
begin
|
||||
@@setter[uri][tag_name]
|
||||
@@setters[uri][tag_name]
|
||||
rescue NameError
|
||||
nil
|
||||
end
|
||||
|
@ -150,13 +141,22 @@ module RSS
|
|||
|
||||
def available_tags(uri)
|
||||
begin
|
||||
@@setter[uri].keys
|
||||
@@setters[uri].keys
|
||||
rescue NameError
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def install_get_text_element(name, uri, setter)
|
||||
def register_uri(uri, name)
|
||||
@@registered_uris[name] ||= {}
|
||||
@@registered_uris[name][uri] = nil
|
||||
end
|
||||
|
||||
def uri_registered?(uri, name)
|
||||
@@registered_uris[name].has_key?(uri)
|
||||
end
|
||||
|
||||
def install_get_text_element(uri, name, setter)
|
||||
install_setter(uri, name, setter)
|
||||
def_get_text_element(uri, name, *get_file_and_line_from_caller(1))
|
||||
end
|
||||
|
@ -164,12 +164,12 @@ module RSS
|
|||
private
|
||||
|
||||
def def_get_text_element(uri, name, file, line)
|
||||
register_uri(name, uri)
|
||||
register_uri(uri, name)
|
||||
unless private_instance_methods(false).include?("start_#{name}")
|
||||
module_eval(<<-EOT, file, line)
|
||||
def start_#{name}(name, prefix, attrs, ns)
|
||||
uri = ns[prefix]
|
||||
if self.class.uri_registered?(#{name.inspect}, uri)
|
||||
if self.class.uri_registered?(uri, #{name.inspect})
|
||||
if @do_validate
|
||||
tags = self.class.available_tags(uri)
|
||||
unless tags.include?(name)
|
||||
|
|
|
@ -79,7 +79,7 @@ module RSS
|
|||
prefix_size = SY_PREFIX.size + 1
|
||||
SyndicationModel::ELEMENTS.uniq!
|
||||
SyndicationModel::ELEMENTS.each do |x|
|
||||
BaseListener.install_get_text_element(x[prefix_size..-1], SY_URI, "#{x}=")
|
||||
BaseListener.install_get_text_element(SY_URI, x[prefix_size..-1], "#{x}=")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module RSS
|
|||
|
||||
%w(link).each do |x|
|
||||
if const_defined? :Listener
|
||||
Listener.install_get_text_element(x, TAXO_NS, "#{TAXO_PREFIX}_#{x}=")
|
||||
Listener.install_get_text_element(TAXO_NS, x, "#{TAXO_PREFIX}_#{x}=")
|
||||
end
|
||||
TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{x}"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue