Class: Fastlane::Sftp::Downloader
- Inherits:
-
Object
- Object
- Fastlane::Sftp::Downloader
- Defined in:
- lib/fastlane/plugin/sftp/helper/downloader.rb
Overview
Responsible for performing download SFTP operation
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
-
#download ⇒ Object
Download files.
-
#initialize(options) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(options) ⇒ Downloader
Returns a new instance of Downloader.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/sftp/helper/downloader.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/downloader.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/downloader.rb', line 19 def host @host end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/fastlane/plugin/sftp/helper/downloader.rb', line 13 def @options end |
#password ⇒ Object
Returns the value of attribute password.
21 22 23 |
# File 'lib/fastlane/plugin/sftp/helper/downloader.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/downloader.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/downloader.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/downloader.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/downloader.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/downloader.rb', line 20 def user @user end |
Instance Method Details
#download ⇒ Object
Download files
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fastlane/plugin/sftp/helper/downloader.rb', line 43 def download # Login & Download all files using RSA key or username/password UI.('download...') session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase) if session.nil? return false end UI.('Downloading files...') session.sftp.connect do |sftp| source_files = files.map { |entry| Helper::SftpHelper.generate_remote_path(user, entry) } downloads = sftp_download(sftp, source_files, target_dir) downloads.each(&:wait) # Lists the entries in a directory for verification Dir.entries(target_dir).each do |entry| UI.(entry) end end session.close return true end |