From 1d5e40eb288dcc4a6e4ca8932aaa42eade00f877 Mon Sep 17 00:00:00 2001 From: kou Date: Wed, 19 Jul 2006 14:54:52 +0000 Subject: * lib/rss/parser.rb, lib/rss/utils.rb: added documents. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/rss/parser.rb | 8 ++++++++ lib/rss/utils.rb | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index c20797cce..4166692aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Jul 19 23:53:05 2006 Kouhei Sutou + + * lib/rss/parser.rb, lib/rss/utils.rb: added documents. + Tue Jul 18 22:10:13 2006 Yukihiro Matsumoto * process.c (rb_f_system): block SIGCHLD during the process diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb index 6f5696eda..033bc123a 100644 --- a/lib/rss/parser.rb +++ b/lib/rss/parser.rb @@ -7,6 +7,10 @@ module RSS class NotWellFormedError < Error attr_reader :line, :element + + # Create a new NotWellFormedError for an error at +line+ + # in +element+. If a block is given the return value of + # the block ends up in the error message. def initialize(line=nil, element=nil) message = "This is not well formed XML" if element or line @@ -85,6 +89,10 @@ module RSS end private + + # Try to get the XML associated with +rss+. + # Return +rss+ if it already looks like XML, or treat it as a URI, + # or a file to get the XML, def normalize_rss(rss) return rss if maybe_xml?(rss) diff --git a/lib/rss/utils.rb b/lib/rss/utils.rb index 031ff3072..b242a7229 100644 --- a/lib/rss/utils.rb +++ b/lib/rss/utils.rb @@ -1,6 +1,8 @@ module RSS module Utils module_function + + # Convert a name_with_underscores to CamelCase. def to_class_name(name) name.split(/_/).collect do |part| "#{part[0, 1].upcase}#{part[1..-1]}" @@ -12,11 +14,14 @@ module RSS [file, line.to_i] end + # escape '&', '"', '<' and '>' for use in HTML. def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/