class Fastlane::Helper::ZipFileGenerator
Public Class Methods
new(input_dir, output_file)
click to toggle source
Initialize with the directory to zip and the location of the output archive.
# File lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb, line 11 def initialize(input_dir, output_file) @input_dir = input_dir @output_file = output_file end
Public Instance Methods
write()
click to toggle source
Zip the input directory.
# File lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb, line 17 def write entries = Dir.entries(@input_dir) - %w[. ..] ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile| write_entries(entries, '', zipfile) end end
Private Instance Methods
put_into_archive(disk_file_path, zipfile, zipfile_path)
click to toggle source
# File lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb, line 47 def put_into_archive(disk_file_path, zipfile, zipfile_path) zipfile.add(zipfile_path, disk_file_path) end
recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
click to toggle source
# File lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb, line 41 def recursively_deflate_directory(disk_file_path, zipfile, zipfile_path) zipfile.mkdir(zipfile_path) subdir = Dir.entries(disk_file_path) - %w[. ..] write_entries(subdir, zipfile_path, zipfile) end
write_entries(entries, path, zipfile)
click to toggle source
A helper method to make the recursion work.
# File lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb, line 28 def write_entries(entries, path, zipfile) entries.each do |e| zipfile_path = path == '' ? e : File.join(path, e) disk_file_path = File.join(@input_dir, zipfile_path) if File.directory?(disk_file_path) recursively_deflate_directory(disk_file_path, zipfile, zipfile_path) else put_into_archive(disk_file_path, zipfile, zipfile_path) end end end