Class: FTPRepository
- Inherits:
-
Object
- Object
- FTPRepository
- Defined in:
- lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb
Instance Attribute Summary collapse
-
#ftps_host ⇒ Object
readonly
Returns the value of attribute ftps_host.
-
#ftps_password ⇒ Object
readonly
Returns the value of attribute ftps_password.
-
#ftps_remote_path ⇒ Object
readonly
Returns the value of attribute ftps_remote_path.
-
#ftps_username ⇒ Object
readonly
Returns the value of attribute ftps_username.
Instance Method Summary collapse
- #archive_exist?(archive_filename) ⇒ Boolean
- #download(archive_filename, destination_path) ⇒ Object
-
#initialize(host, config) ⇒ FTPRepository
constructor
A new instance of FTPRepository.
- #login ⇒ Object
- #upload(archive_filename, archive_path) ⇒ Object
Constructor Details
#initialize(host, config) ⇒ FTPRepository
Returns a new instance of FTPRepository.
9 10 11 12 13 14 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 9 def initialize(host, config) @ftps_host = config[:region] @ftps_remote_path = host @ftps_username = config[:aws_access_key_id] @ftps_password = config[:secret_access_key] end |
Instance Attribute Details
#ftps_host ⇒ Object (readonly)
Returns the value of attribute ftps_host.
4 5 6 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 4 def ftps_host @ftps_host end |
#ftps_password ⇒ Object (readonly)
Returns the value of attribute ftps_password.
7 8 9 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 7 def ftps_password @ftps_password end |
#ftps_remote_path ⇒ Object (readonly)
Returns the value of attribute ftps_remote_path.
5 6 7 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 5 def ftps_remote_path @ftps_remote_path end |
#ftps_username ⇒ Object (readonly)
Returns the value of attribute ftps_username.
6 7 8 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 6 def ftps_username @ftps_username end |
Instance Method Details
#archive_exist?(archive_filename) ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 25 def archive_exist?(archive_filename) ftps = login files = ftps.list ftps.close return !files.select { |f| f.include? "#{@ftps_remote_path}/#{archive_filename}" }.empty? end |
#download(archive_filename, destination_path) ⇒ Object
32 33 34 35 36 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 32 def download(archive_filename, destination_path) ftps = login ftps.getbinaryfile("#{@ftps_remote_path}/#{archive_filename}", destination_path) ftps.close end |
#login ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 16 def login # Connect to a host using explicit FTPS and do not verify the host's cert ftps = DoubleBagFTPS.new ftps.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE) ftps.connect(@ftps_host) ftps.login(@ftps_username, @ftps_password) ftps end |
#upload(archive_filename, archive_path) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 38 def upload(archive_filename, archive_path) ftps = login files = ftps.list ftps.mkdir(@ftps_remote_path) if files.select { |f| f.include? @ftps_remote_path }.empty? ftps.putbinaryfile(archive_path, "#{@ftps_remote_path}/#{archive_filename}") ftps.close end |