aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rss
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-31 02:10:18 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-31 02:10:18 +0000
commitb7891928a33f7f6452f5e51858144e822e11a9cb (patch)
tree90195a26cbc6255e46c9a6459f64a84a008f345c /lib/rss
parentf8c33000697574d405e822b1bb04430a34784907 (diff)
downloadruby-b7891928a33f7f6452f5e51858144e822e11a9cb.tar.gz
* 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
Diffstat (limited to 'lib/rss')
-rw-r--r--lib/rss/0.9.rb2
-rw-r--r--lib/rss/1.0.rb2
-rw-r--r--lib/rss/2.0.rb2
-rw-r--r--lib/rss/content.rb2
-rw-r--r--lib/rss/dublincore.rb2
-rw-r--r--lib/rss/image.rb2
-rw-r--r--lib/rss/parser.rb34
-rw-r--r--lib/rss/syndication.rb2
-rw-r--r--lib/rss/taxonomy.rb2
9 files changed, 25 insertions, 25 deletions
diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb
index c780cdb66a..a2f66ee28d 100644
--- a/lib/rss/0.9.rb
+++ b/lib/rss/0.9.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
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index 86c19afc70..d48164825f 100644
--- a/lib/rss/1.0.rb
+++ b/lib/rss/1.0.rb
@@ -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
diff --git a/lib/rss/2.0.rb b/lib/rss/2.0.rb
index 4bd46512f4..1ae320f2db 100644
--- a/lib/rss/2.0.rb
+++ b/lib/rss/2.0.rb
@@ -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
diff --git a/lib/rss/content.rb b/lib/rss/content.rb
index 280bbb8d6b..78eefadff1 100644
--- a/lib/rss/content.rb
+++ b/lib/rss/content.rb
@@ -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
diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb
index 016072edf1..d460828da7 100644
--- a/lib/rss/dublincore.rb
+++ b/lib/rss/dublincore.rb
@@ -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
diff --git a/lib/rss/image.rb b/lib/rss/image.rb
index 9cc3c73018..441e83fc2d 100644
--- a/lib/rss/image.rb
+++ b/lib/rss/image.rb
@@ -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)
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index ecfde83762..05af111ad4 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -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)
diff --git a/lib/rss/syndication.rb b/lib/rss/syndication.rb
index c274ff8c82..e71455c6a4 100644
--- a/lib/rss/syndication.rb
+++ b/lib/rss/syndication.rb
@@ -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
diff --git a/lib/rss/taxonomy.rb b/lib/rss/taxonomy.rb
index bec6ea3c17..173214dffb 100644
--- a/lib/rss/taxonomy.rb
+++ b/lib/rss/taxonomy.rb
@@ -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