I've played around with the sshpublisher and since I'm forced to use Windows as a platform I had to hack a way to use something other than ssh.
Attached is the diff between my solution and what is currently on CVS.
I can now use putty (pscp and plink actually) to publish stuff from windows using this class.

Take a look and tell me if it makes the cut.
Cheers,
V.-
--
http://www.braveworld.net/riva


____________________________________________________________________
http://www.freemail.gr - äùñåÜí õðçñåóßá çëåêôñïíéêïý ôá÷õäñïìåßïõ.
http://www.freemail.gr - free email service for the Greek-speaking.
RCS file: /var/cvs/rake/rake/lib/rake/contrib/sshpublisher.rb,v
retrieving revision 1.2
diff -u -r1.2 sshpublisher.rb
--- lib/rake/contrib/sshpublisher.rb    16 Nov 2003 22:18:46 -0000      1.2
+++ lib/rake/contrib/sshpublisher.rb    19 Nov 2005 14:31:35 -0000
@@ -3,45 +3,84 @@
 require 'rake/contrib/compositepublisher'
 
 module Rake
-
+  #This is the base class for the SSH publisher classes.
+  #
+  #It can also be used as a single publisher, only it cannot be used in a 
composite publisher (the other SSH classes can).
+  #
+  #This class allows you to set the command to be used for ssh/scp 
communications, so that it can also be used on windows
+  #boxes.
+  #
+  #The default values work for the ssh client on a Linux/MacOS X installation.
+  #== Example on Windows
+  #This shows how SshBAse can be used with the PuTTY utilities
+  # publisher=Rake::SshBase.new('[EMAIL PROTECTED]','remote_dir','local_dir')
+  # publisher.ssh="plink.exe"
+  # publisher.scp="pscp.exe"
+  # publisher.scp_options="-r -q"
+  # #sets the password so that we don't get prompted for every command
+  # publisher.ssh_options="-pw passwd"
+  class SshBasePublisher
+         attr_writer :ssh,:scp,:ssh_options,:scp_options
+         attr_reader :ssh,:scp,:ssh_options,:scp_options
+       def initialize(host, remote_dir, local_dir)
+               @host = host
+               @remote_dir = remote_dir
+               @local_dir = local_dir
+               @ssh="ssh"
+               @scp="ssh"
+               @scp_options="-rq"
+               @ssh_options=""
+       end  
+       # Publish the entire :local_dir to :remote_dir using
+       # SCP.
+       #
+       #Will fail if :remote_dir does not exist.
+       def upload_dir 
+               sh [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]/* 
[EMAIL PROTECTED]:[EMAIL PROTECTED]
+       end
+       
+       # Publish a list of files in :local_dir to :remote_dir.
+       #
+       #Fails if :remote_dir does not exist.
+       def upload_files(*files)
+               files.each do |fn|
+                       sh [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL 
PROTECTED]/#{fn} [EMAIL PROTECTED]:[EMAIL PROTECTED]
+               end
+        end
+       
+       # Publish an entire directory to a fresh remote directory using SSH.
+       def upload_fresh_dir
+               sh [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] rm -rf 
[EMAIL PROTECTED] rescue nil
+               sh [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] mkdir 
[EMAIL PROTECTED]
+               upload_dir
+       end
+  end
   # Publish an entire directory to an existing remote directory using
   # SSH.
-  class SshDirPublisher
-    def initialize(host, remote_dir, local_dir)
-      @host = host
-      @remote_dir = remote_dir
-      @local_dir = local_dir
-    end
-    
+  class SshDirPublisher<SshBasePublisher
     def upload
-      sh %{scp -rq [EMAIL PROTECTED]/* [EMAIL PROTECTED]:[EMAIL PROTECTED]
+      upload_dir
     end
   end
   
   # Publish an entire directory to a fresh remote directory using SSH.
   class SshFreshDirPublisher < SshDirPublisher
     def upload
-      sh %{ssh [EMAIL PROTECTED] rm -rf [EMAIL PROTECTED] rescue nil
-      sh %{ssh [EMAIL PROTECTED] mkdir [EMAIL PROTECTED]
-      super
+      upload_fresh_dir
     end
   end
   
   # Publish a list of files to an existing remote directory.
-  class SshFilePublisher
+  class SshFilePublisher<SshBasePublisher
     # Create a publisher using the give host information.
     def initialize(host, remote_dir, local_dir, *files)
-      @host = host
-      @remote_dir = remote_dir
-      @local_dir = local_dir
+      super(host, remote_dir, local_dir)
       @files = files
     end
     
     # Upload the local directory to the remote directory.
     def upload
-      @files.each do |fn|
-       sh %{scp -q [EMAIL PROTECTED]/#{fn} [EMAIL PROTECTED]:[EMAIL PROTECTED]
-      end
+      upload_files(@files)
     end
   end
 end
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel

Reply via email to