Module: AppInfo::Helper::Archive
- Included in:
- Apple, DSYM, AppInfo::HarmonyOS, PE, Proguard
- Defined in:
- lib/app_info/helper/archive.rb
Instance Method Summary collapse
- #tempdir(file, prefix:, system: false) ⇒ Object
-
#unarchive(file, prefix:, dest_path: '/tmp') ⇒ Object
Unarchive zip file.
Instance Method Details
#tempdir(file, prefix:, system: false) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/app_info/helper/archive.rb', line 30 def tempdir(file, prefix:, system: false) base_path = system ? '/tmp' : ::File.dirname(file) full_prefix = "appinfo-#{prefix}-#{::File.basename(file, '.*')}" dest_path = Dir.mktmpdir(full_prefix, base_path) ::File.join(dest_path, ::File.basename(file)) end |
#unarchive(file, prefix:, dest_path: '/tmp') ⇒ Object
Unarchive zip file
source: github.com/soffes/lagunitas/blob/master/lib/lagunitas/ipa.rb
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/app_info/helper/archive.rb', line 13 def unarchive(file, prefix:, dest_path: '/tmp') base_path = Dir.mktmpdir("appinfo-#{prefix}", dest_path) Zip::File.open(file) do |zip_file| if block_given? yield base_path, zip_file else zip_file.each do |f| f_path = ::File.join(base_path, f.name) FileUtils.mkdir_p(::File.dirname(f_path)) zip_file.extract(f, f_path) unless ::File.exist?(f_path) end end end base_path end |