ruby-changes:9033
From: akr <ko1@a...>
Date: Sun, 7 Dec 2008 17:45:49 +0900 (JST)
Subject: [ruby-changes:9033] Ruby:r20569 (trunk): * lib/open3.rb (Open3.capture3): renamed from Open3.poutput3.
akr 2008-12-07 17:45:31 +0900 (Sun, 07 Dec 2008) New Revision: 20569 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20569 Log: * lib/open3.rb (Open3.capture3): renamed from Open3.poutput3. (Open3.capture2): renamed from Open3.poutput2. (lOpen3.capture2e): renamed from Open3.poutput2e. Modified files: trunk/ChangeLog trunk/lib/open3.rb trunk/test/test_open3.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20568) +++ ChangeLog (revision 20569) @@ -1,3 +1,9 @@ +Sun Dec 7 17:44:06 2008 Tanaka Akira <akr@f...> + + * 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 <akr@f...> * lib/open3.rb (Open3.poutput3): :binmode option implemented. Index: lib/open3.rb =================================================================== --- lib/open3.rb (revision 20568) +++ lib/open3.rb (revision 20569) @@ -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 @@ 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 @@ # 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 #=> #<Process::Status: pid 32682 exit 0> @@ -230,16 +230,16 @@ # # 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 @@ [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 @@ # 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 @@ # 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 @@ [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 @@ # 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 @@ [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. Index: test/test_open3.rb =================================================================== --- test/test_open3.rb (revision 20568) +++ test/test_open3.rb (revision 20569) @@ -123,28 +123,28 @@ } 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/