class Toolshed::ServerAdministration::SCP

Handles SCP file from one place to another

Attributes

local_path[R]
password[R]
remote_host[R]
remote_path[R]
ssh_options[R]
username[R]
verbose_output[R]

Public Class Methods

new(options = nil) click to toggle source
# File lib/toolshed/server_administration/scp.rb, line 15
def initialize(options = nil)
  options ||= {}
  @password = options[:password]
  @remote_host = options[:remote_host]
  @remote_path = options[:remote_path]
  @local_path = options[:local_path]
  @username = options[:username]
  @verbose_output = options[:verbose_output]
  @ssh_options = options[:ssh_options]
  @ssh_options ||= {}
  @ssh_options.merge!(password: password_from_config(password))
end

Public Instance Methods

download() click to toggle source
# File lib/toolshed/server_administration/scp.rb, line 28
def download
  Toolshed.logger.info "Attempting to SCP from #{username}@#{remote_host}:#{remote_path} to #{local_path}." # rubocop:disable LineLength
  Net::SCP.download!(remote_host, username, remote_path, local_path, ssh: ssh_options, recursive: true) # rubocop:disable LineLength
  on_complete
end
upload() click to toggle source
# File lib/toolshed/server_administration/scp.rb, line 34
def upload
  Toolshed.logger.info "Attempting to SCP from #{local_path} to #{username}@#{remote_host}:#{remote_path}." # rubocop:disable LineLength
  Net::SCP.upload!(remote_host, username, local_path, remote_path, ssh: ssh_options, recursive: true) # rubocop:disable LineLength
  on_complete
end

Private Instance Methods

on_complete() click to toggle source
# File lib/toolshed/server_administration/scp.rb, line 42
def on_complete
  Toolshed.logger.info ''
  Toolshed.logger.info 'SCP file transfer has completed.'
end