ruby-changes:9357
From: nobu <ko1@a...>
Date: Sun, 21 Dec 2008 12:23:40 +0900 (JST)
Subject: [ruby-changes:9357] Ruby:r20895 (ruby_1_8, trunk): * lib/optparse.rb (SPLAT_PROC): fix for regexp.
nobu 2008-12-21 12:23:19 +0900 (Sun, 21 Dec 2008) New Revision: 20895 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20895 Log: * lib/optparse.rb (SPLAT_PROC): fix for regexp. [ruby-dev:37514] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/lib/optparse.rb branches/ruby_1_8/test/optparse/test_reqarg.rb branches/ruby_1_8/version.h trunk/ChangeLog trunk/lib/optparse.rb trunk/test/optparse/test_reqarg.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20894) +++ ChangeLog (revision 20895) @@ -1,3 +1,7 @@ +Sun Dec 21 12:23:16 2008 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (SPLAT_PROC): fix for regexp. [ruby-dev:37514] + Sun Dec 21 10:43:10 2008 TAKANO Mitsuhiro (takano32) <tak@n...> * sample/test.rb: rescue exception. Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 20894) +++ lib/optparse.rb (revision 20895) @@ -996,7 +996,7 @@ end private :notwice - SPLAT_PROC = proc {|*a| a} + SPLAT_PROC = proc {|*a| next *a} # # Creates an OptionParser::Switch from the parameters. The parsed argument # value is passed to the given block, where it can be processed. Index: test/optparse/test_reqarg.rb =================================================================== --- test/optparse/test_reqarg.rb (revision 20894) +++ test/optparse/test_reqarg.rb (revision 20895) @@ -60,4 +60,16 @@ assert_equal(%w"", no_error {@opt.parse!(%w"--opt=foo")}) assert_equal("foo", @flag) end + + class TestOptionParser::WithPattern < TestOptionParser + def test_pattern + pat = num = nil + @opt.def_option("--pattern=VAL", /(\w+)(?:\s*:\s*(\w+))?/) {|x, y, z| pat = [x, y, z]} + @opt.def_option("-T NUM", /\A[1-4]\z/) {|n| num = n} + no_error {@opt.parse!(%w"--pattern=key:val")} + assert_equal(%w"key:val key val", pat, '[ruby-list:45645]') + no_error {@opt.parse!(%w"-T 4")} + assert_equal("4", num, '[ruby-dev:37514]') + end + end end Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 20894) +++ ruby_1_8/ChangeLog (revision 20895) @@ -1,3 +1,7 @@ +Sun Dec 21 12:23:16 2008 Nobuyoshi Nakada <nobu@r...> + + * lib/optparse.rb (SPLAT_PROC): fix for regexp. [ruby-dev:37514] + Fri Dec 19 20:42:35 2008 Takeyuki FUJIOKA <xibbar@r...> * lib/cgi/session.rb: ignore session_id options fixed.[Bug #605] Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 20894) +++ ruby_1_8/version.h (revision 20895) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-12-19" +#define RUBY_RELEASE_DATE "2008-12-21" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20081219 +#define RUBY_RELEASE_CODE 20081221 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 21 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8/lib/optparse.rb =================================================================== --- ruby_1_8/lib/optparse.rb (revision 20894) +++ ruby_1_8/lib/optparse.rb (revision 20895) @@ -996,7 +996,7 @@ end private :notwice - SPLAT_PROC = proc {|*a| a} + SPLAT_PROC = proc {|*a| next *a} # # Creates an OptionParser::Switch from the parameters. The parsed argument # value is passed to the given block, where it can be processed. Index: ruby_1_8/test/optparse/test_reqarg.rb =================================================================== --- ruby_1_8/test/optparse/test_reqarg.rb (revision 20894) +++ ruby_1_8/test/optparse/test_reqarg.rb (revision 20895) @@ -60,4 +60,16 @@ assert_equal(%w"", no_error {@opt.parse!(%w"--opt=foo")}) assert_equal("foo", @flag) end + + class TestOptionParser::WithPattern < TestOptionParser + def test_pattern + pat = num = nil + @opt.def_option("--pattern=VAL", /(\w+)(?:\s*:\s*(\w+))?/) {|x, y, z| pat = [x, y, z]} + @opt.def_option("-T NUM", /\A[1-4]\z/) {|n| num = n} + no_error {@opt.parse!(%w"--pattern=key:val")} + assert_equal(%w"key:val key val", pat, '[ruby-list:45645]') + no_error {@opt.parse!(%w"-T 4")} + assert_equal("4", num, '[ruby-dev:37514]') + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/