/
gt_scp.rb
33 lines (29 loc) · 917 Bytes
/
gt_scp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module GrowlTransfer
class GTScp
def initialize(output)
@output = output
end
def download(remote, local_path)
@output.puts "Downloading #{remote}"
params = remote.split(":")
file = params.last.split("/").last
if params[0].include? '@'
server = params[0].split('@').last
user = params[0].split('@').first
else
server = params[0]
user = ENV['USER']
end
Net::SCP.start(server, user) do |scp|
scp.download!(params[1], local_path, {:recursive => true, :verbose => true}) do |ch, name, sent, total|
# => progress?
end
end
@output.puts "Finished!"
g = Growl.new "localhost", "GrowlTransfer",
["GrowlTransfer Notification"]
g.notify "GrowlTransfer Notification", "#{file}",
"Download complete"
end
end
end