ruby-changes:23402
From: nobu <ko1@a...>
Date: Tue, 24 Apr 2012 14:54:38 +0900 (JST)
Subject: [ruby-changes:23402] nobu:r35453 (trunk): * lib/optparse.rb (OptionParser#to_a): String#to_a is no longer
nobu 2012-04-24 14:54:08 +0900 (Tue, 24 Apr 2012) New Revision: 35453 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35453 Log: * lib/optparse.rb (OptionParser#to_a): String#to_a is no longer defined. [ruby-dev:45568][Bug #6348] Modified files: trunk/ChangeLog trunk/lib/optparse.rb trunk/test/optparse/test_summary.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35452) +++ ChangeLog (revision 35453) @@ -1,3 +1,8 @@ +Tue Apr 24 14:54:03 2012 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (OptionParser#to_a): String#to_a is no longer + defined. [ruby-dev:45568][Bug #6348] + Tue Apr 24 12:46:50 2012 Marc-Andre Lafortune <ruby-core@m...> * hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods. Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 35452) +++ lib/optparse.rb (revision 35453) @@ -1065,13 +1065,13 @@ # # Returns option summary string. # - def help; summarize(banner.to_s.sub(/\n?\z/, "\n")) end + def help; summarize("#{banner}".sub(/\n?\z/, "\n")) end alias to_s help # # Returns option summary list. # - def to_a; summarize(banner.to_a.dup) end + def to_a; summarize([*banner]) end # # Checks if an argument is given twice, in which case an ArgumentError is Index: test/optparse/test_summary.rb =================================================================== --- test/optparse/test_summary.rb (revision 35452) +++ test/optparse/test_summary.rb (revision 35453) @@ -18,4 +18,21 @@ assert_match(/description 2/, s[1]) assert_match(/last-option/, s[-1]) end + + def test_banner + o = OptionParser.new("foo bar") + assert_equal("foo bar", o.banner) + end + + def test_banner_from_progname + o = OptionParser.new + o.program_name = "foobar" + assert_equal("Usage: foobar [options]\n", o.help) + end + + def test_summary + o = OptionParser.new("foo bar") + assert_equal("foo bar\n", o.to_s) + assert_equal(["foo bar"], o.to_a) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/