Class: Middleman::Deploy::Methods::Sftp

Inherits:
Ftp
  • Object
show all
Defined in:
lib/middleman-deploy/methods/sftp.rb

Instance Attribute Summary

Attributes inherited from Ftp

#host, #pass, #path, #port, #user

Attributes inherited from Base

#options, #server_instance

Instance Method Summary collapse

Methods inherited from Ftp

#initialize

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Middleman::Deploy::Methods::Ftp

Instance Method Details

#processObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/middleman-deploy/methods/sftp.rb', line 9

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|
    sftp.mkdir(self.path)

    Dir.chdir(self.server_instance.build_dir) do
      filtered_files.each do |filename|
        if File.directory?(filename)
          upload_directory(sftp, filename)
        else
          upload_file(sftp, filename)
        end
      end
    end
  end
end