Class: FTPRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_hostObject (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_passwordObject (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_pathObject (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_usernameObject (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

Returns:

  • (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 = 
  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 = 
  ftps.getbinaryfile("#{@ftps_remote_path}/#{archive_filename}", destination_path)
  ftps.close
end

#loginObject



16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb', line 16

def 
  # 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.(@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 = 
  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