ruby-changes:48268
From: nobu <ko1@a...>
Date: Mon, 23 Oct 2017 23:05:13 +0900 (JST)
Subject: [ruby-changes:48268] nobu:r60383 (trunk): multiple arguments to write
nobu 2017-10-23 23:05:07 +0900 (Mon, 23 Oct 2017) New Revision: 60383 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60383 Log: multiple arguments to write Make write methods of IO-like objects accept multiple arguments, as well as IO#write. Modified files: trunk/ext/openssl/lib/openssl/buffering.rb trunk/test/lib/envutil.rb trunk/test/logger/test_logdevice.rb trunk/test/mkmf/base.rb trunk/test/optparse/test_autoconf.rb trunk/test/optparse/test_kwargs.rb trunk/test/optparse/test_optparse.rb Index: test/mkmf/base.rb =================================================================== --- test/mkmf/base.rb (revision 60382) +++ test/mkmf/base.rb (revision 60383) @@ -49,11 +49,11 @@ module TestMkmf::Base https://github.com/ruby/ruby/blob/trunk/test/mkmf/base.rb#L49 def filter(&block) @filter = block end - def write(s) + def write(*s) if @out - @buffer << s + @buffer.concat(*s) elsif @origin - @origin << s + @origin.write(*s) end end end Index: test/logger/test_logdevice.rb =================================================================== --- test/logger/test_logdevice.rb (revision 60382) +++ test/logger/test_logdevice.rb (revision 60383) @@ -75,7 +75,7 @@ class TestLogDevice < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/logger/test_logdevice.rb#L75 # logdev = d(LogExcnRaiser.new) class << (stderr = '') - alias write << + alias write concat end $stderr, stderr = stderr, $stderr begin Index: test/lib/envutil.rb =================================================================== --- test/lib/envutil.rb (revision 60382) +++ test/lib/envutil.rb (revision 60383) @@ -160,7 +160,7 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L160 def verbose_warning class << (stderr = "".dup) - alias write << + alias write concat end stderr, $stderr, verbose, $VERBOSE = $stderr, stderr, $VERBOSE, true yield stderr Index: test/optparse/test_optparse.rb =================================================================== --- test/optparse/test_optparse.rb (revision 60382) +++ test/optparse/test_optparse.rb (revision 60383) @@ -9,7 +9,7 @@ class TestOptionParser < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/optparse/test_optparse.rb#L9 end class DummyOutput < String - alias write << + alias write concat end def assert_no_error(*args) $stderr, stderr = DummyOutput.new, $stderr Index: test/optparse/test_autoconf.rb =================================================================== --- test/optparse/test_autoconf.rb (revision 60382) +++ test/optparse/test_autoconf.rb (revision 60383) @@ -14,7 +14,7 @@ class TestOptionParser::AutoConf < Test: https://github.com/ruby/ruby/blob/trunk/test/optparse/test_autoconf.rb#L14 end class DummyOutput < String - alias write << + alias write concat end def no_error(*args) $stderr, stderr = DummyOutput.new, $stderr Index: test/optparse/test_kwargs.rb =================================================================== --- test/optparse/test_kwargs.rb (revision 60382) +++ test/optparse/test_kwargs.rb (revision 60383) @@ -14,7 +14,7 @@ class TestOptionParser::KwArg < Test::Un https://github.com/ruby/ruby/blob/trunk/test/optparse/test_kwargs.rb#L14 end class DummyOutput < String - alias write << + alias write concat end def assert_no_error(*args) $stderr, stderr = DummyOutput.new, $stderr Index: ext/openssl/lib/openssl/buffering.rb =================================================================== --- ext/openssl/lib/openssl/buffering.rb (revision 60382) +++ ext/openssl/lib/openssl/buffering.rb (revision 60383) @@ -339,7 +339,8 @@ module OpenSSL::Buffering https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/buffering.rb#L339 # Writes _s_ to the stream. If the argument is not a String it will be # converted using +.to_s+ method. Returns the number of bytes written. - def write(s) + def write(*s) + s = s.size == 1 ? s[0] : s.join("") do_write(s) s.bytesize end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/