summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 06:51:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 06:51:44 +0000
commit4f2b00429e9f98a91ae94f10d2d0435a120ed5e7 (patch)
tree7bf6660bbbad3df05caa86d828170b0fef01f579
parenta9917efd5d99d8ba7a8a573c1f6bfb024cfb316e (diff)
* lib/optparse.rb (OptionParser#to_a): should split by end-of-line
[ruby-dev:45568][Bug #6348] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/optparse.rb2
-rw-r--r--test/optparse/test_summary.rb6
3 files changed, 8 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 731831f..f738539 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-Tue Apr 24 14:54:03 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Apr 24 15:51:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/optparse.rb (OptionParser#to_a): should split by end-of-line
+ [ruby-dev:45568][Bug #6348]
* lib/optparse.rb (OptionParser#to_a): String#to_a is no longer
defined. [ruby-dev:45568][Bug #6348]
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 75c6b76..2306606 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1071,7 +1071,7 @@ XXX
#
# Returns option summary list.
#
- def to_a; summarize([*banner]) 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 bda3b49..2fad5f0 100644
--- a/test/optparse/test_summary.rb
+++ b/test/optparse/test_summary.rb
@@ -31,8 +31,8 @@ class TestOptionParser::SummaryTest < TestOptionParser
end
def test_summary
- o = OptionParser.new("foo bar")
- assert_equal("foo bar\n", o.to_s)
- assert_equal(["foo bar"], o.to_a)
+ o = OptionParser.new("foo\nbar")
+ assert_equal("foo\nbar\n", o.to_s)
+ assert_equal(["foo", "bar"], o.to_a)
end
end