Class: Fastlane::RearchiveHelper::IPAArchive
- Inherits:
-
Object
- Object
- Fastlane::RearchiveHelper::IPAArchive
- Defined in:
- lib/fastlane/plugin/rearchive/helper/archives/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.
-
#delete(path) ⇒ Object
Delete path inside the ipa.
-
#extract(path) ⇒ Object
Extract files to the temp dir.
-
#initialize(archive_path) ⇒ 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(archive_path) ⇒ IPAArchive
Returns a new instance of IPAArchive.
6 7 8 9 10 11 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 6 def initialize(archive_path) @archive_path = archive_path @temp_dir = Dir.mktmpdir FastlaneCore::UI.verbose("Working in temp dir: #{@temp_dir}") @app_path = self.class.extract_app_path(@archive_path) end |
Class Method Details
.extract_app_path(archive_path) ⇒ Object
56 57 58 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 56 def self.extract_app_path(archive_path) IO.popen("zipinfo -1 #{archive_path.shellescape} \"Payload/*.app/\" | sed -n '1 p'", &:read).strip.chomp("/") end |
Instance Method Details
#app_path(path) ⇒ Object
Returns an archive-relative path to the given application file
19 20 21 22 23 24 25 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 19 def app_path(path) if path.start_with?("/") path.sub(%r{^/}, "") else "#{@app_path}/#{path}" end end |
#delete(path) ⇒ Object
Delete path inside the ipa
49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 49 def delete(path) FastlaneCore::UI.verbose("Deleting #{path}") Dir.chdir(@temp_dir) do system("zip -dq #{@archive_path.shellescape} #{path.shellescape} >/dev/null 2>&1", exception: false) end end |
#extract(path) ⇒ Object
Extract files to the temp dir
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 28 def extract(path) FastlaneCore::UI.verbose("Extracting #{path}") Dir.chdir(@temp_dir) do result = IO.popen("unzip -o -q #{@archive_path.shellescape} #{path.shellescape}", &:read).chomp if $?.exitstatus.nonzero? FastlaneCore::UI.important(result) raise "extract operation failed with exit code #{$?.exitstatus}" end end path end |
#local_path(path) ⇒ Object
Returns the full path to the given file that can be modified
14 15 16 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 14 def local_path(path) "#{@temp_dir}/#{path}" end |
#replace(path) ⇒ Object
Restore extracted files from the temp dir
41 42 43 44 45 46 |
# File 'lib/fastlane/plugin/rearchive/helper/archives/ipa_archive.rb', line 41 def replace(path) FastlaneCore::UI.verbose("Replacing #{path}") Dir.chdir(@temp_dir) do system("zip -q #{@archive_path.shellescape} #{path.shellescape}", exception: true) end end |