diff --git a/ChangeLog b/ChangeLog index 4266849122..cddbea83ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 29 00:00:46 2004 Kouhei Sutou + + * lib/rss: rss/parser.rb is always required. + Wed Jan 28 15:09:14 2004 Nobuyoshi Nakada * test/rss/*.rb: remove "test/" prefix. diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb index 467d57ba2d..4f03333d96 100644 --- a/lib/rss/0.9.rb +++ b/lib/rss/0.9.rb @@ -1,4 +1,4 @@ -require "rss/rss" +require "rss/parser" module RSS @@ -413,26 +413,22 @@ EOT end - if const_defined?(:BaseListener) - RSS09::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x, nil, "#{x}=") - end + RSS09::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x, nil, "#{x}=") end - if const_defined?(:ListenerMixin) - module ListenerMixin - private - def start_rss(tag_name, prefix, attrs, ns) - check_ns(tag_name, prefix, ns, nil) - - @rss = Rss.new(attrs['version'], @version, @encoding, @standalone) - @last_element = @rss - @proc_stack.push Proc.new { |text, tags| - @rss.validate_for_stream(tags) if @do_validate - } - end - + module ListenerMixin + private + def start_rss(tag_name, prefix, attrs, ns) + check_ns(tag_name, prefix, ns, nil) + + @rss = Rss.new(attrs['version'], @version, @encoding, @standalone) + @last_element = @rss + @proc_stack.push Proc.new { |text, tags| + @rss.validate_for_stream(tags) if @do_validate + } end + end end diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb index 72b7637122..d3c337eecd 100644 --- a/lib/rss/1.0.rb +++ b/lib/rss/1.0.rb @@ -1,4 +1,4 @@ -require "rss/rss" +require "rss/parser" module RSS @@ -643,10 +643,8 @@ EOT end - if const_defined?(:BaseListener) - RSS10::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x, URI, "#{x}=") - end + RSS10::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x, URI, "#{x}=") end end diff --git a/lib/rss/2.0.rb b/lib/rss/2.0.rb index e43947e400..fd6a242d21 100644 --- a/lib/rss/2.0.rb +++ b/lib/rss/2.0.rb @@ -123,26 +123,22 @@ EOT end - if const_defined?(:BaseListener) - RSS09::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x, Rss::URI, "#{x}=") - end + RSS09::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x, Rss::URI, "#{x}=") end - if const_defined?(:ListenerMixin) - module ListenerMixin - private - def start_rss(tag_name, prefix, attrs, ns) - check_ns(tag_name, prefix, ns, Rss::URI) - - @rss = Rss.new(attrs['version'], @version, @encoding, @standalone) - @last_element = @rss - @proc_stack.push Proc.new { |text, tags| - @rss.validate_for_stream(tags) if @do_validate - } - end - + module ListenerMixin + private + def start_rss(tag_name, prefix, attrs, ns) + check_ns(tag_name, prefix, ns, Rss::URI) + + @rss = Rss.new(attrs['version'], @version, @encoding, @standalone) + @last_element = @rss + @proc_stack.push Proc.new { |text, tags| + @rss.validate_for_stream(tags) if @do_validate + } end + end end diff --git a/lib/rss/content.rb b/lib/rss/content.rb index 64f87d4d5b..3bb82f987c 100644 --- a/lib/rss/content.rb +++ b/lib/rss/content.rb @@ -37,11 +37,9 @@ module RSS class Item; include ContentModel; end end - if const_defined? :BaseListener - prefix_size = CONTENT_PREFIX.size + 1 - ContentModel::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x[prefix_size..-1], CONTENT_URI, "#{x}=") - end + prefix_size = CONTENT_PREFIX.size + 1 + ContentModel::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x[prefix_size..-1], CONTENT_URI, "#{x}=") end end diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb index e9c3fcac2d..c46ab76451 100644 --- a/lib/rss/dublincore.rb +++ b/lib/rss/dublincore.rb @@ -46,11 +46,9 @@ module RSS class Textinput; include DublincoreModel; end end - if const_defined? :BaseListener - prefix_size = DC_PREFIX.size + 1 - DublincoreModel::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x[prefix_size..-1], DC_URI, "#{x}=") - end + prefix_size = DC_PREFIX.size + 1 + DublincoreModel::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x[prefix_size..-1], DC_URI, "#{x}=") end end diff --git a/lib/rss/syndication.rb b/lib/rss/syndication.rb index 74bfbac8e1..39005f64c8 100644 --- a/lib/rss/syndication.rb +++ b/lib/rss/syndication.rb @@ -71,11 +71,9 @@ module RSS class Channel; include SyndicationModel; end end - if const_defined? :BaseListener - prefix_size = SY_PREFIX.size + 1 - SyndicationModel::ELEMENTS.each do |x| - BaseListener.install_get_text_element(x[prefix_size..-1], SY_URI, "#{x}=") - end + prefix_size = SY_PREFIX.size + 1 + SyndicationModel::ELEMENTS.each do |x| + BaseListener.install_get_text_element(x[prefix_size..-1], SY_URI, "#{x}=") end end diff --git a/lib/rss/utils.rb b/lib/rss/utils.rb index 32940cf2a8..cd0f9da739 100644 --- a/lib/rss/utils.rb +++ b/lib/rss/utils.rb @@ -9,10 +9,10 @@ module RSS [file, line] end - def html_escape(s) - s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(//, ">").gsub(/