diff --git a/ChangeLog b/ChangeLog index ef1c6add20..bcb655b8e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Apr 25 05:46:12 2012 Nobuyoshi Nakada + + * lib/optparse.rb (OptionParser#to_a): split for each lines. + [ruby-dev:45568][Bug #6348] + Tue Apr 24 21:57:53 2012 Tanaka Akira * ext/socket/raddrinfo.c (init_unix_addrinfo): show actual path length diff --git a/lib/optparse.rb b/lib/optparse.rb index da022c9450..dcb67604e2 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1071,7 +1071,7 @@ XXX # # Returns option summary list. # - def to_a; summarize("#{banner}".split) end + def to_a; summarize("#{banner}".split(/^/)) end # # Checks if an argument is given twice, in which case an ArgumentError is diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb index 2fad5f04dc..d7771733a3 100644 --- a/test/optparse/test_summary.rb +++ b/test/optparse/test_summary.rb @@ -33,6 +33,6 @@ class TestOptionParser::SummaryTest < TestOptionParser def test_summary o = OptionParser.new("foo\nbar") assert_equal("foo\nbar\n", o.to_s) - assert_equal(["foo", "bar"], o.to_a) + assert_equal(["foo\n", "bar"], o.to_a) end end