Class: Fastlane::Helper::ApplitoolsifyHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb

Class Method Summary collapse

Class Method Details

.applitoolsify(file_to_process, app_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 17

def self.applitoolsify(file_to_process, app_name)
  Dir.mktmpdir do |tmpdir|
    zip_ufg_lib = get_ufg_lib(tmpdir)
    framework_zip_entries = get_framework_filenames(zip_ufg_lib)

    Zip.continue_on_exists_proc = true
    Zip::File.open(file_to_process, create: false) do |zipfile|
      framework_zip_entries.each do |zip_entry|
        new_path = get_new_path(zip_entry.to_s, app_name)
        ext_path = extract_zip_entry(tmpdir, zip_ufg_lib, zip_entry)
        zipfile.add(new_path, ext_path)
      end
    end
    # require 'pry'
    # binding.pry
  end
end

.extract_zip_entry(tmpdir, zip_ufg_lib, zip_entry) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 50

def self.extract_zip_entry(tmpdir, zip_ufg_lib, zip_entry)
  lib_path = File.basename(zip_ufg_lib, File.extname(zip_ufg_lib))
  ext_path = File.join(tmpdir, lib_path, zip_entry.name)
  dirname = File.dirname(ext_path)
  FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
  zip_entry.extract ext_path
  ext_path
end

.get_framework_filenames(zip_ufg_lib) ⇒ Object



43
44
45
46
47
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 43

def self.get_framework_filenames(zip_ufg_lib)
  input_filenames = []
  Zip::File.open(zip_ufg_lib) {|zip_file| input_filenames = zip_file.select {|entry| entry.file? } }
  input_filenames
end

.get_new_path(zip_path, app_name) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 59

def self.get_new_path(zip_path, app_name)
  if zip_path.to_s.start_with?('__MACOSX')
    File.join(zip_path.to_s.split('/').insert(1, app_name, 'Frameworks'))
  else
    File.join(app_name, 'Frameworks', zip_path.to_s)
  end
end

.get_ufg_lib(tmpdir) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 35

def self.get_ufg_lib(tmpdir)
  url = 'https://applitools.jfrog.io/artifactory/ufg-mobile/UFG_lib.xcframework.zip'
  filename = File.basename(url)
  where = File.expand_path(filename, tmpdir)
  open(url) {|cloud| File.write(where, cloud.read) } unless File.exist?(where)
  where
end

.show_messageObject

class methods that you define here become available in your action as ‘Helper::ApplitoolsifyHelper.your_method`



13
14
15
# File 'lib/fastlane/plugin/applitoolsify/helper/applitoolsify_helper.rb', line 13

def self.show_message
  UI.message("Hello from the applitoolsify plugin helper!")
end