Class: Zine::UploaderSFTP

Inherits:
Object
  • Object
show all
Defined in:
lib/zine/uploader_sftp.rb

Overview

Deploy changes to a remote host, via SFTP

Defined Under Namespace

Classes: Node

Instance Method Summary collapse

Constructor Details

#initialize(build_dir, options, credentials, delete_file_array, upload_file_array) ⇒ UploaderSFTP

Returns a new instance of UploaderSFTP.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zine/uploader_sftp.rb', line 14

def initialize(build_dir, options, credentials, delete_file_array,
               upload_file_array)
  return unless options['method'] == 'sftp'

  @build_dir = build_dir
  @host = options['host']
  @path = options['path_or_repo']
  @verbose = options['verbose']
  @credentials = credentials
  @delete_file_array = delete_file_array
  @upload_file_array = upload_file_array
end

Instance Method Details

#uploadObject



27
28
29
30
31
32
33
34
35
# File 'lib/zine/uploader_sftp.rb', line 27

def upload
  delete
  deploy
rescue Errno::ENETUNREACH
  puts Rainbow("Unable to connect to #{@host}").red
rescue Net::SSH::AuthenticationFailed, NameError
  puts Rainbow("Authentication failed for #{@host}").red
  puts 'Check your credential file, and maybe run ssh-add?'
end