class Antenna::IPA

Attributes

app_name[RW]
bundle_icon_files[RW]
filename[RW]
info_plist[RW]

Public Class Methods

new(filename) click to toggle source
# File lib/antenna/ipa.rb, line 9
def initialize(filename)
  @filename = filename
  @bundle_icon_files = {}

  Zip::File.open(filename) do |zipfile|
    # Determine app name
    @app_name = zipfile.dir.entries('Payload').
      select { |file| file =~ /.app$/ }.
      first
    raise "Unable to determine app name from #{filename}" unless @app_name

    # Find and read Info.plist
    infoplist_entry = zipfile.get_entry("Payload/#{@app_name}/Info.plist")
    infoplist_data = infoplist_entry.get_input_stream.read
    @info_plist = Antenna::InfoPlist.new(infoplist_data)
    raise "Unable to find Info.plist in #{filename}" unless @info_plist
  end
end

Public Instance Methods

bundle_icon(size, resolution=1) click to toggle source

Returns icon image data for given pixel size and resolution (defaults to 1).

# File lib/antenna/ipa.rb, line 29
def bundle_icon(size, resolution=1)
  icon_data = nil
  if resolutions = @info_plist.bundle_icons[size]
    if filename = resolutions[resolution]
      icon_glob = "Payload/#{@app_name}/#{filename}*.png"
      Zip::File.open(@filename) do |zipfile|
        zipfile.glob(icon_glob).each do |icon|
          icon_data = icon.get_input_stream.read
        end
      end
    end
  end
  icon_data
end
input_stream() click to toggle source
# File lib/antenna/ipa.rb, line 44
def input_stream
  File.open(@filename, "r")
end