Module: AppEntitlementsStatistics::Helper::Archive
- Defined in:
- lib/cocoapods-entitlements-statistics/app_entitlements_statistics/helper.rb
Instance Method Summary collapse
- #tempdir(file, prefix:, system: false) ⇒ Object
-
#unarchive(file, path: nil) ⇒ Object
Unarchive zip file.
Instance Method Details
#tempdir(file, prefix:, system: false) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/helper.rb', line 76 def tempdir(file, prefix:, system: false) dest_path = if system Dir.mktmpdir("appinfo-#{prefix}-#{File.basename(file, '.*')}-", '/tmp') else File.join(File.dirname(file), prefix) end dest_file = File.join(dest_path, File.basename(file)) FileUtils.mkdir_p(dest_path, mode: 0_700) unless system dest_file end |
#unarchive(file, path: nil) ⇒ Object
Unarchive zip file
source: github.com/soffes/lagunitas/blob/master/lib/lagunitas/ipa.rb
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/helper.rb', line 56 def unarchive(file, path: nil) path = path ? "#{path}-" : '' root_path = "#{Dir.mktmpdir}/AppInfo-#{path}#{SecureRandom.hex}" # puts root_path Zip::File.open(file) do |zip_file| if block_given? yield root_path, zip_file else zip_file.each do |f| f_path = File.join(root_path, f.name) FileUtils.mkdir_p(File.dirname(f_path)) zip_file.extract(f, f_path) unless File.exist?(f_path) end end end root_path end |