From c0264efadda2353455ef1d009c258f1cb8fda5bb Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 7 Dec 2008 08:45:31 +0000 Subject: * lib/open3.rb (Open3.capture3): renamed from Open3.poutput3. (Open3.capture2): renamed from Open3.poutput2. (lOpen3.capture2e): renamed from Open3.poutput2e. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/open3.rb | 46 +++++++++++++++++++++++----------------------- test/test_open3.rb | 16 ++++++++-------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0448abea52..1d064b3e90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Dec 7 17:44:06 2008 Tanaka Akira + + * lib/open3.rb (Open3.capture3): renamed from Open3.poutput3. + (Open3.capture2): renamed from Open3.poutput2. + (lOpen3.capture2e): renamed from Open3.poutput2e. + Sun Dec 7 11:48:04 2008 Tanaka Akira * lib/open3.rb (Open3.poutput3): :binmode option implemented. diff --git a/lib/open3.rb b/lib/open3.rb index a094773aad..c29a622c1b 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -15,9 +15,9 @@ # - Open3.popen3 : pipes for stdin, stdout, stderr # - Open3.popen2 : pipes for stdin, stdout # - Open3.popen2e : pipes for stdin, merged stdout and stderr -# - Open3.poutput3 : give a string for stdin. get strings for stdout, stderr -# - Open3.poutput2 : give a string for stdin. get a string for stdout -# - Open3.poutput2e : give a string for stdin. get a string for merged stdout and stderr +# - Open3.capture3 : give a string for stdin. get strings for stdout, stderr +# - Open3.capture2 : give a string for stdin. get a string for stdout +# - Open3.capture2e : give a string for stdin. get a string for merged stdout and stderr # - Open3.pipeline_rw : pipes for first stdin and last stdout of a pipeline # - Open3.pipeline_r : pipe for last stdout of a pipeline # - Open3.pipeline_w : pipe for first stdin of a pipeline @@ -201,9 +201,9 @@ module Open3 private :popen_run end - # Open3.poutput3 captures the standard output and the standard error of a command. + # Open3.capture3 captures the standard output and the standard error of a command. # - # stdout_str, stderr_str, status = Open3.poutput3([env,] cmd... [, opts]) + # stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts]) # # The arguments cmd and opts are passed to Open3.popen3 except opts[:stdin_data]. # @@ -219,9 +219,9 @@ module Open3 # a -> b # } # End - # layouted_graph, dot_log = Open3.poutput3("dot -v", :stdin_data=>graph) + # layouted_graph, dot_log = Open3.capture3("dot -v", :stdin_data=>graph) # - # o, e, s = Open3.poutput3("echo a; sort >&2", :stdin_data=>"foo\nbar\nbaz\n") + # o, e, s = Open3.capture3("echo a; sort >&2", :stdin_data=>"foo\nbar\nbaz\n") # p o #=> "a\n" # p e #=> "bar\nbaz\nfoo\n" # p s #=> # @@ -230,16 +230,16 @@ module Open3 # # However, if the image stored really in a file, # # system("convert", "-thumbnail", "80", filename, "png:-") is better # # because memory consumption. - # # But if the image is stored in a DB or generated by gnuplot Open3.poutput2 example, - # # Open3.poutput3 is considerable. + # # But if the image is stored in a DB or generated by gnuplot Open3.capture2 example, + # # Open3.capture3 is considerable. # # # image = File.read("/usr/share/openclipart/png/animals/mammals/sheep-md-v0.1.png", :binmode=>true) - # thumnail, err, s = Open3.poutput3("convert -thumbnail 80 - png:-", :stdin_data=>image, :binmode=>true) + # thumnail, err, s = Open3.capture3("convert -thumbnail 80 - png:-", :stdin_data=>image, :binmode=>true) # if s.success? # STDOUT.binmode; print thumnail # end # - def poutput3(*cmd, &block) + def capture3(*cmd, &block) if Hash === cmd.last opts = cmd.pop.dup else @@ -262,11 +262,11 @@ module Open3 [out_reader.value, err_reader.value, t.value] } end - module_function :poutput3 + module_function :capture3 - # Open3.poutput2 captures the standard output of a command. + # Open3.capture2 captures the standard output of a command. # - # stdout_str, status = Open3.poutput2([env,] cmd... [, opts]) + # stdout_str, status = Open3.capture2([env,] cmd... [, opts]) # # The arguments cmd and opts are passed to Open3.popen2 except opts[:stdin_data]. # @@ -275,7 +275,7 @@ module Open3 # If opts[:binmode] is true, internal pipes are set to binary mode. # # # factor is a command for integer factorization. - # o, s = Open3.poutput2("factor", :stdin_data=>"42") + # o, s = Open3.capture2("factor", :stdin_data=>"42") # p o #=> "42: 2 3 7\n" # # # generate x**2 graph in png using gnuplot. @@ -288,9 +288,9 @@ module Open3 # 4 5 # e # End - # image, s = Open3.poutput2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true) + # image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true) # - def poutput2(*cmd, &block) + def capture2(*cmd, &block) if Hash === cmd.last opts = cmd.pop.dup else @@ -311,11 +311,11 @@ module Open3 [out_reader.value, t.value] } end - module_function :poutput2 + module_function :capture2 - # Open3.poutput2e captures the standard output and the standard error of a command. + # Open3.capture2e captures the standard output and the standard error of a command. # - # stdout_and_stderr_str, status = Open3.poutput2e([env,] cmd... [, opts]) + # stdout_and_stderr_str, status = Open3.capture2e([env,] cmd... [, opts]) # # The arguments cmd and opts are passed to Open3.popen2e except opts[:stdin_data]. # @@ -326,9 +326,9 @@ module Open3 # Example: # # # capture make log - # make_log, s = Open3.poutput2e("make") + # make_log, s = Open3.capture2e("make") # - def poutput2e(*cmd, &block) + def capture2e(*cmd, &block) if Hash === cmd.last opts = cmd.pop.dup else @@ -349,7 +349,7 @@ module Open3 [outerr_reader.value, t.value] } end - module_function :poutput2e + module_function :capture2e # Open3.pipeline_rw starts a list of commands as a pipeline with pipes # which connects stdin of the first command and stdout of the last command. diff --git a/test/test_open3.rb b/test/test_open3.rb index b0b9475232..d891eed11e 100644 --- a/test/test_open3.rb +++ b/test/test_open3.rb @@ -123,28 +123,28 @@ class TestOpen3 < Test::Unit::TestCase } end - def test_poutput3 - o, e, s = Open3.poutput3(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i") + def test_capture3 + o, e, s = Open3.capture3(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i") assert_equal("io", o) assert_equal("ie", e) assert(s.success?) end - def test_poutput3_flip - o, e, s = Open3.poutput3(RUBY, '-e', 'STDOUT.sync=true; 1000.times { print "o"*1000; STDERR.print "e"*1000 }') + def test_capture3_flip + o, e, s = Open3.capture3(RUBY, '-e', 'STDOUT.sync=true; 1000.times { print "o"*1000; STDERR.print "e"*1000 }') assert_equal("o"*1000000, o) assert_equal("e"*1000000, e) assert(s.success?) end - def test_poutput2 - o, s = Open3.poutput2(RUBY, '-e', 'i=STDIN.read; print i+"o"', :stdin_data=>"i") + def test_capture2 + o, s = Open3.capture2(RUBY, '-e', 'i=STDIN.read; print i+"o"', :stdin_data=>"i") assert_equal("io", o) assert(s.success?) end - def test_poutput2e - oe, s = Open3.poutput2e(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i") + def test_capture2e + oe, s = Open3.capture2e(RUBY, '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i") assert_equal("ioie", oe) assert(s.success?) end -- cgit v1.2.3