Module: AppInfo::Helper::Archive
Instance Method Summary collapse
- #tempdir(file, prefix:) ⇒ Object
-
#unarchive(file, path: nil) ⇒ Object
Unarchive zip file.
Instance Method Details
#tempdir(file, prefix:) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/app_info/helper.rb', line 85 def tempdir(file, prefix:) dest_path ||= File.join(File.dirname(file), prefix) dest_file = File.join(dest_path, File.basename(file)) Dir.mkdir(dest_path, 0_700) unless Dir.exist?(dest_path) dest_file end |
#unarchive(file, path: nil) ⇒ Object
Unarchive zip file
source: github.com/soffes/lagunitas/blob/master/lib/lagunitas/ipa.rb
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/app_info/helper.rb', line 67 def unarchive(file, path: nil) path = path ? "#{path}-" : '' root_path = "#{Dir.mktmpdir}/AppInfo-#{path}#{SecureRandom.hex}" 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 |