Permalink
Browse files

More comments arround Open3/4

  • Loading branch information...
1 parent d1eb33e commit 93a3421e0d49e862bdd2dd2936b377a16b997e83 @dekellum committed Dec 28, 2011
Showing with 11 additions and 3 deletions.
  1. +1 −1 README.txt
  2. +3 −0 lib/rake/remote_task/open3.rb
  3. +7 −2 lib/rake/remote_task/open4.rb
View
2 README.txt
@@ -45,7 +45,7 @@ To set ssh flags for the login and port:
== REQUIREMENTS:
* rake
-* open4 gem
+* open4 gem (on MRI ruby; not needed for jruby)
== INSTALL:
View
3 lib/rake/remote_task/open3.rb
@@ -1,11 +1,13 @@
require 'open3'
+##
# Implementation of +run+ using stdlib Open3. Currently this is only
# viable on JRuby where the exit status may be obtained. By comparison
# open4 requires a fork which isn't available on JRuby.
module Rake::RemoteOpen3
include Open3
+ ##
# Use ssh to execute +command+ on target_host. If +command+ uses
# sudo, the sudo password will be prompted for then saved for
# subsequent sudo commands.
@@ -78,6 +80,7 @@ def run command
private
+ ##
# Test hook for injecting status (can't set $?)
def test_status
nil
View
9 lib/rake/remote_task/open4.rb
@@ -1,11 +1,16 @@
require 'open4'
+##
+# Implementation of +run+ using Open4. This uses fork underneath and
+# therefore only works where fork works (jruby is a notable exception,
+# see RemoteOpen3)
module Rake::RemoteOpen4
include Open4
##
- # Use ssh to execute +command+ on target_host. If +command+ uses sudo, the
- # sudo password will be prompted for then saved for subsequent sudo commands.
+ # Use ssh to execute +command+ on target_host. If +command+ uses
+ # sudo, the sudo password will be prompted for then saved for
+ # subsequent sudo commands.
def run command
command = "cd #{target_dir} && #{command}" if target_dir
cmd = [ssh_cmd, ssh_flags, target_host, command].flatten

0 comments on commit 93a3421

Please sign in to comment.