Sha256: ef8a0fa2d4cff3c96d76ac6d7cdba3921e403e249ebcf7fb7de71b336c4ba6bc

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

require 'zip'
require 'fileutils'

module Lagunitas
  class IPA
    def initialize(path)
      @path = path
    end

    def app
      @app ||= App.new(app_path)
    end

    def app_path
      @app_path ||= Dir.glob(File.join(contents, 'Payload', '*.app')).first
    end

    def cleanup
      return unless @contents
      FileUtils.rm_rf(@contents)
      @contents = nil
    end

    private

    def contents
      return if @contents
      @contents = "tmp/lagunitas-#{SecureRandom.hex}"

      Zip::File.open(@path) do |zip_file|
        zip_file.each do |f|
          f_path = File.join(@contents, f.name)
          FileUtils.mkdir_p(File.dirname(f_path))
          zip_file.extract(f, f_path) unless File.exist?(f_path)
        end
      end

      @contents
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lagunitas-0.0.2 lib/lagunitas/ipa.rb