Class: Fastlane::ActHelper::IPAArchive
- Inherits:
-
Object
- Object
- Fastlane::ActHelper::IPAArchive
- Defined in:
- lib/fastlane/plugin/act/helper/ipa_archive.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#app_path(path) ⇒ Object
Returns an archive-relative path to the given application file.
- #clean ⇒ Object
- #contains(path = nil) ⇒ Object
-
#delete(path) ⇒ Object
Delete path inside the ipa.
-
#extract(path) ⇒ Object
Extract files to the temp dir.
-
#initialize(ipa_file, app_name = null, temp_dir = null) ⇒ IPAArchive
constructor
A new instance of IPAArchive.
-
#local_path(path) ⇒ Object
Returns the full path to the given file that can be modified.
-
#replace(path) ⇒ Object
Restore extracted files from the temp dir.
Constructor Details
#initialize(ipa_file, app_name = null, temp_dir = null) ⇒ IPAArchive
Returns a new instance of IPAArchive.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 4 def initialize(ipa_file, app_name = null, temp_dir = null) @ipa_file = ipa_file @create_temp_dir = temp_dir.nil? @temp_dir = Dir.mktmpdir if @create_temp_dir UI.verbose("Working in temp dir: #{@temp_dir}") @app_path = "Payload/#{app_name}" if app_name @app_path = IPAArchive.extract_app_path(@ipa_file) unless app_name raise "IPA does not contain #{@app_path}" unless contains("#{@app_path}/") end |
Class Method Details
.extract_app_path(archive_path) ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 67 def self.extract_app_path(archive_path) `zipinfo -1 #{archive_path.shellescape} "Payload/*.app/" | sed -n '1 p'`.strip().chomp('/') end |
Instance Method Details
#app_path(path) ⇒ Object
Returns an archive-relative path to the given application file
23 24 25 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 23 def app_path(path) "#{@app_path}/#{path}" end |
#clean ⇒ Object
62 63 64 65 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 62 def clean `rm -rf #{temp_dir.shellescape}` if @create_temp_dir `rm -rf #{temp_dir.shellescape}/*` unless @create_temp_dir end |
#contains(path = nil) ⇒ Object
57 58 59 60 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 57 def contains(path = nil) `zipinfo -1 #{@ipa_file.shellescape} #{path.shellescape}` $?.exitstatus.zero? end |
#delete(path) ⇒ Object
Delete path inside the ipa
50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 50 def delete(path) UI.verbose("Deleting #{path}") Dir.chdir(@temp_dir) do `zip -dq #{@ipa_file.shellescape} #{path.shellescape}` end end |
#extract(path) ⇒ Object
Extract files to the temp dir
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 28 def extract(path) UI.verbose("Extracting #{path}") Dir.chdir(@temp_dir) do result = `unzip -o -q #{@ipa_file.shellescape} #{path.shellescape}` if $?.exitstatus.nonzero? UI.important result raise "extract operation failed with exit code #{$?.exitstatus}" end end end |
#local_path(path) ⇒ Object
Returns the full path to the given file that can be modified
18 19 20 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 18 def local_path(path) "#{@temp_dir}/#{path}" end |
#replace(path) ⇒ Object
Restore extracted files from the temp dir
42 43 44 45 46 47 |
# File 'lib/fastlane/plugin/act/helper/ipa_archive.rb', line 42 def replace(path) UI.verbose("Replacing #{path}") Dir.chdir(@temp_dir) do `zip -q #{@ipa_file.shellescape} #{path.shellescape}` end end |