Sha256: dae1fb2de827ff3382442dac1cd6107c008abaa49602a3d8276f9b6e06636ab1

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'albacore/support/albacore_helper'
require 'net/sftp'

class Sftp
	include YAMLConfig
	include Logging
	
	attr_accessor :server, :username, :password, :upload_files, :port, :key, :debug
  
	def initialize
		super()
		@upload_files = {}
	end	
	
	def get_connection_options
		options = {}
		options[:verbose] = :debug if @debug == true
		options[:password] = @password if @password
		options[:port] = @port if @port
		options[:keys] = [@key] if @key
		options
	end
  
	def upload()
		warn_about_key if @key
    
		Net::SFTP.start(@server, @username, get_connection_options) do |sftp|
			@logger.debug "Starting File Upload"
			@upload_files.each {|local_file, remote_file|
				@logger.debug "Uploading #{local_file} to #{remote_file}"
				sftp.upload!(local_file, remote_file)
			}
		end
	end

	def warn_about_key()
		info.debug 'When using a key, you need an SSH-Agent running to manage the keys.'
		info.debug 'On Windows, a recommended agent is called Pageant, downloadable from the Putty site.'
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
albacore-0.0.8 lib/albacore/sftp.rb