lib/middleman-deploy/methods/sftp.rb in middleman-deploy-0.2.4 vs lib/middleman-deploy/methods/sftp.rb in middleman-deploy-0.3.0
- old
+ new
@@ -3,16 +3,15 @@
module Middleman
module Deploy
module Methods
class Sftp < Ftp
-
def process
puts "## Deploying via sftp to #{self.user}@#{self.host}:#{path}"
# `nil` is a valid value for user and/or pass.
- Net::SFTP.start(self.host, self.user, :password => self.pass, :port => self.port) do |sftp|
+ Net::SFTP.start(self.host, self.user, password: self.pass, port: self.port) do |sftp|
sftp.mkdir(self.path)
Dir.chdir(self.server_instance.build_dir) do
filtered_files.each do |filename|
if File.directory?(filename)
@@ -23,15 +22,15 @@
end
end
end
end
- protected
+ protected
- def handle_exception(exception)
+ def handle_exception(exception,filename, file_path)
reply = exception.message
- err_code = reply[0,3].to_i
+ err_code = reply[0, 3].to_i
if err_code == 550
sftp.upload(filename, file_path)
end
end
@@ -50,16 +49,14 @@
file_path = "#{self.path}/#{filename}"
begin
sftp.upload(filename, file_path)
rescue Exception => exception
- handle_exception(exception, file_path)
+ handle_exception(exception, filename, file_path)
end
puts "Copied #{filename}"
end
-
end
end
end
end
-