Class: Fastlane::Sftp::Uploader
- Inherits:
-
Object
- Object
- Fastlane::Sftp::Uploader
- Defined in:
- lib/fastlane/plugin/sftp/helper/uploader.rb
Overview
Responsible for performing upload SFTP operations
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#host ⇒ Object
These want to be an input parameters:.
-
#options ⇒ Object
Returns the value of attribute options.
-
#password ⇒ Object
Returns the value of attribute password.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
-
#rsa_keypath ⇒ Object
Returns the value of attribute rsa_keypath.
-
#rsa_keypath_passphrase ⇒ Object
Returns the value of attribute rsa_keypath_passphrase.
-
#target_dir ⇒ Object
Returns the value of attribute target_dir.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options) ⇒ Uploader
constructor
A new instance of Uploader.
-
#upload ⇒ Object
Upload files.
Constructor Details
#initialize(options) ⇒ Uploader
Returns a new instance of Uploader.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 28 def initialize() self. = unless .nil? self.host = [:server_url] self.user = [:server_user] self.password = [:server_password] self.rsa_keypath = [:server_key] self.rsa_keypath_passphrase = [:server_key_passphrase] self.files = [:file_paths] self.target_dir = [:target_dir] end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
26 27 28 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 26 def files @files end |
#host ⇒ Object
These want to be an input parameters:
19 20 21 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 19 def host @host end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 13 def @options end |
#password ⇒ Object
Returns the value of attribute password.
21 22 23 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 21 def password @password end |
#root_path ⇒ Object
Returns the value of attribute root_path.
25 26 27 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 25 def root_path @root_path end |
#rsa_keypath ⇒ Object
Returns the value of attribute rsa_keypath.
22 23 24 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 22 def rsa_keypath @rsa_keypath end |
#rsa_keypath_passphrase ⇒ Object
Returns the value of attribute rsa_keypath_passphrase.
23 24 25 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 23 def rsa_keypath_passphrase @rsa_keypath_passphrase end |
#target_dir ⇒ Object
Returns the value of attribute target_dir.
24 25 26 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 24 def target_dir @target_dir end |
#user ⇒ Object
Returns the value of attribute user.
20 21 22 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 20 def user @user end |
Instance Method Details
#upload ⇒ Object
Upload files
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fastlane/plugin/sftp/helper/uploader.rb', line 43 def upload # Login & Upload all files using RSA key or username/password UI.('upload...') session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase) if session.nil? return false end UI.('Uploading files...') session.sftp.connect do |sftp| Helper::SftpHelper.remote_mkdir(sftp, Helper::SftpHelper.generate_remote_path(user, target_dir)) path = target_dir uploads = [] files.each do |file| next unless Helper::SftpHelper.check_file(file) re = Helper::SftpHelper.get_target_file_path(file, target_dir) if File.directory?(file) Helper::SftpHelper.remote_mkdir(sftp, re) end uploads.push(upload_file(sftp, file, re)) end uploads.each(&:wait) # Lists the entries in a directory for verification sftp.dir.foreach(path) do |entry| UI.(entry.longname) end end session.close return true end |