Permalink
Browse files

Support for password based auth

  • Loading branch information...
catsby committed Mar 29, 2011
1 parent 5901b7d commit af9c11834a4dab33fa6cce2e82fc511bb3eb3f26
Showing with 10 additions and 8 deletions.
  1. +4 −4 lib/growl-transfer.rb
  2. +6 −4 lib/growl-transfer/gt_scp.rb
@@ -8,13 +8,13 @@
module GrowlTransfer

DEFAULTS = {
'output' => STDOUT,
'local' => "."
:output => $stdout,
:action => 'download'
}

def self.Download(remote, local)
def self.Download(opts = {})
gd_scp = GTScp.new
gd_scp.download(remote, local)
gd_scp.download(opts[:remote], opts[:local], opts[:username], opts[:password])
end

end
@@ -1,13 +1,13 @@
module GrowlTransfer
class GTTransferObjet
def initialize
@output = GrowlTransfer::DEFAULTS['output']
@output = GrowlTransfer::DEFAULTS[:output]
end
end

class GTScp < GTTransferObjet

def download(remote, local_path)
def download(remote, local_path, username = nil, password = nil)
@output.puts "Downloading #{remote}"
params = remote.split(":")
file = params.last.split("/").last
@@ -20,12 +20,14 @@ def download(remote, local_path)
user = ENV['USER']
end

Net::SCP.start(server, user) do |scp|
user = username unless username.nil?

Net::SCP.start(server, user, :password => password) do |scp|
scp.download!(params[1], local_path, {:recursive => true, :verbose => true}) do |ch, name, sent, total|
# => progress?
end
@output.puts "Finished!"
end
@output.puts "Finished!"
g = Growl.new "localhost", "GrowlTransfer",
["GrowlTransfer Notification"]
g.notify "GrowlTransfer Notification", "#{file}",

0 comments on commit af9c118

Please sign in to comment.