summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/open3.rb46
-rw-r--r--test/test_open3.rb16
3 files changed, 37 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 0448abe..1d064b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Dec 7 17:44:06 2008 Tanaka Akira <akr@fsij.org>
+
+ * 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@fsij.org>
* lib/open3.rb (Open3.poutput3): :binmode option implemented.
diff --git a/lib/open3.rb b/lib/open3.rb
index a094773..c29a622 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 #=> #<Process::Status: pid 32682 exit 0>
@@ -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 b0b9475..d891eed 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