You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by vb...@apache.org on 2008/10/21 17:25:16 UTC
svn commit: r706658 - /incubator/buildr/trunk/addon/buildr/drb.rb
Author: vborja
Date: Tue Oct 21 08:25:16 2008
New Revision: 706658
URL: http://svn.apache.org/viewvc?rev=706658&view=rev
Log:
Use delegates for stdio redirection so that $stdin, $stdout, $stderr globals can be cached (eg, fileutils does this) without problem.
Modified:
incubator/buildr/trunk/addon/buildr/drb.rb
Modified: incubator/buildr/trunk/addon/buildr/drb.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/drb.rb?rev=706658&r1=706657&r2=706658&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/drb.rb (original)
+++ incubator/buildr/trunk/addon/buildr/drb.rb Tue Oct 21 08:25:16 2008
@@ -14,6 +14,7 @@
# the License.
+require 'delegate'
require 'drb/drb'
@@ -146,6 +147,9 @@
def setup
unless original
+ # Create the stdio delegator that can be cached (eg by fileutils)
+ delegate_stdio
+
# Lazily load buildr the first time it's needed
require 'buildr'
@@ -174,17 +178,28 @@
DRb.thread.join
end
end
+
+ def delegate_stdio
+ $stdin = SimpleDelegator.new($stdin)
+ $stdout = SimpleDelegator.new($stdout)
+ $stderr = SimpleDelegator.new($stderr)
+ end
def with_config(remote)
@invoked = true
set = lambda do |env|
ARGV.replace env[:argv]
- $stdin, $stdout, $stderr = env.values_at(:in, :out, :err)
+ $stdin.__setobj__(env[:in])
+ $stdout.__setobj__(env[:out])
+ $stderr.__setobj__(env[:err])
Buildr.application.instance_variable_set :@original_dir, env[:dir]
end
original = {
:dir => Buildr.application.instance_variable_get(:@original_dir),
- :argv => ARGV, :in => $stdin, :out => $stdout, :err => $stderr
+ :argv => ARGV,
+ :in => $stdin.__getobj__,
+ :out => $stdout.__getobj__,
+ :err => $stderr.__getobj__
}
begin
set[remote]