ruby-changes:10382
From: nobu <ko1@a...>
Date: Sun, 1 Feb 2009 16:10:20 +0900 (JST)
Subject: [ruby-changes:10382] Ruby:r21926 (trunk): * lib/optparse.rb (Switch#summarize): strips an equal sign from
nobu 2009-02-01 16:10:08 +0900 (Sun, 01 Feb 2009) New Revision: 21926 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21926 Log: * lib/optparse.rb (Switch#summarize): strips an equal sign from short option, and fills right sides in shorter lines. [ruby-talk:326414] Modified files: trunk/ChangeLog trunk/lib/optparse.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 21925) +++ ChangeLog (revision 21926) @@ -1,3 +1,9 @@ +Sun Feb 1 16:10:06 2009 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (Switch#summarize): strips an equal sign from + short option, and fills right sides in shorter lines. + [ruby-talk:326414] + Sun Feb 1 05:19:43 2009 Nobuyoshi Nakada <nobu@r...> * variable.c (rb_const_get_0), vm_insnhelper.c (vm_get_ev_const): Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 21925) +++ lib/optparse.rb (revision 21926) @@ -384,10 +384,16 @@ left[-1] << if left[-1].empty? then ' ' * 4 else ', ' end << s end - left[0] << arg if arg + if arg + left[0] << (left[1] ? arg.sub(/\A(\[?)=/, '\1') + ',' : arg) + end mlen = left.collect {|ss| ss.length}.max.to_i while mlen > width and l = left.shift mlen = left.collect {|ss| ss.length}.max.to_i if l.length == mlen + if l.length < width and (r = right[0]) and !r.empty? + l = l.to_s.ljust(width) + ' ' + r + right.shift + end yield(indent + l) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/