[前][次][番号順一覧][スレッド一覧]

ruby-changes:33478

From: nobu <ko1@a...>
Date: Fri, 11 Apr 2014 10:31:07 +0900 (JST)
Subject: [ruby-changes:33478] nobu:r45557 (trunk): envutil.rb: filter kwargs

nobu	2014-04-11 10:31:00 +0900 (Fri, 11 Apr 2014)

  New Revision: 45557

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45557

  Log:
    envutil.rb: filter kwargs
    
    * test/ruby/envutil.rb (EnvUtil#invoke_ruby): add stdout_filter
      and stderr_filter optional keyword arguments, which filter
      stdout and stderr outputs respectively.

  Modified files:
    trunk/test/ruby/envutil.rb
Index: test/ruby/envutil.rb
===================================================================
--- test/ruby/envutil.rb	(revision 45556)
+++ test/ruby/envutil.rb	(revision 45557)
@@ -31,7 +31,9 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L31
   LANG_ENVS = %w"LANG LC_ALL LC_CTYPE"
 
   def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false,
-                  encoding: nil, timeout: 10, reprieve: 1, **opt)
+                  encoding: nil, timeout: 10, reprieve: 1,
+                  stdout_filter: nil, stderr_filter: nil,
+                  **opt)
     in_c, in_p = IO.pipe
     out_p, out_c = IO.pipe if capture_stdout
     err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout
@@ -85,6 +87,8 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L87
       err_p.close if capture_stderr && capture_stderr != :merge_to_stdout
       Process.wait pid
       status = $?
+      stdout = stdout_filter.call(stdout) if stdout_filter
+      stderr = stderr_filter.call(stderr) if stderr_filter
       return stdout, stderr, status
     end
   ensure

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]