[Rubygems-developers] PATCH: normalize summary specification into
one line
Gavin Sinclair
gsinclair at soyabean.com.au
Sat Apr 17 15:52:55 EDT 2004
When creating a gemspec for ruby-dict, this is how I defined the
summary:
s.summary = <<-EOF
A Ruby implementation of the DICT protocol (RFC 2229) for using online
dictionaries. It includes an application 'rdict' for looking up words
from the command-line.
EOF
There's an implicit assumption when they are displayed that summaries
are one line. So I modified specification.rb to accept multi-line
summaries and normalize them into one line.
+
+ ##
+ # Sets the summary of the Specification, but normalizes the formatting into one line.
+ #
+ # summary:: [String] The summary text
+ #
+ def summary=(summary)
+ @summary = summary.strip.gsub(/(\w-)\n\s*(\w)/, '\1\2').gsub(/\n\s*/, " ")
+ end
I think this is a reasonable thing to do, but others may disagree, so
I've posted the patch here instead of committing it. Notice that the
first gsub is to handle hyphenated words with a newline in the middle.
Thoughts? Complete patch below so you can try it if you wish.
If you guys like the idea, I'll put more effort into implementation,
and also cover the "description" field, before committing.
Cheers,
Gavin
Index: lib/rubygems/specification.rb
===================================================================
RCS file: /var/cvs/rubygems/rubygems/lib/rubygems/specification.rb,v
retrieving revision 1.27
diff -u -r1.27 specification.rb
--- lib/rubygems/specification.rb 11 Apr 2004 11:50:37 -0000 1.27
+++ lib/rubygems/specification.rb 17 Apr 2004 05:14:27 -0000
@@ -174,6 +174,15 @@
end
@version = version
end
+
+ ##
+ # Sets the summary of the Specification, but normalises the formatting into one line.
+ #
+ # summary:: [String] The summary text
+ #
+ def summary=(summary)
+ @summary = summary.strip.gsub(/(\w-)\n\s*(\w)/, '\1\2').gsub(/\n\s*/, " ")
+ end
##
# Helper method if the require path is singular
More information about the Rubygems-developers
mailing list