Class: AppParser::Ipa

Inherits:
Object
  • Object
show all
Includes:
AppIcon
Defined in:
lib/app_parser/ipa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AppIcon

#icon, #largest_icon, #smallest_icon, #sorted_icons

Constructor Details

#initialize(file_name) ⇒ Ipa

Returns a new instance of Ipa.



13
14
15
16
17
# File 'lib/app_parser/ipa.rb', line 13

def initialize(file_name)
  @zip_file = Zip::File.new(file_name)
  @iphone_icons = search_icons
  @ipad_icons = search_icons(ipad: true)
end

Instance Attribute Details

#ipad_iconsObject (readonly)

Returns the value of attribute ipad_icons.



11
12
13
# File 'lib/app_parser/ipa.rb', line 11

def ipad_icons
  @ipad_icons
end

#iphone_iconsObject (readonly)

Returns the value of attribute iphone_icons.



11
12
13
# File 'lib/app_parser/ipa.rb', line 11

def iphone_icons
  @iphone_icons
end

Instance Method Details

#bundle_idObject



35
36
37
# File 'lib/app_parser/ipa.rb', line 35

def bundle_id
  info_plist["CFBundleIdentifier"]
end

#display_nameObject



31
32
33
# File 'lib/app_parser/ipa.rb', line 31

def display_name
  info_plist["CFBundleDisplayName"] || info_plist["CFBundleName"]
end

#icon_data(file_name) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/app_parser/ipa.rb', line 52

def icon_data(file_name)
  Dir.mktmpdir do |tmp_dir|
    src_file = "#{tmp_dir}/src"
    dest_file = "#{tmp_dir}/dest"
    find_entry(file_name).extract(src_file)
    Pngdefry.defry(src_file, dest_file)
    File.binread(dest_file)
  end
end

#iconsObject



48
49
50
# File 'lib/app_parser/ipa.rb', line 48

def icons
  @iphone_icons + @ipad_icons
end

#info_plistObject



62
63
64
65
66
# File 'lib/app_parser/ipa.rb', line 62

def info_plist
  @info_plist ||= CFPropertyList.native_types(
    CFPropertyList::List.new(data: read_file("Info.plist"), format: CFPropertyList::List::FORMAT_AUTO).value
  )
end

#mobileprovisionObject



68
69
70
71
72
# File 'lib/app_parser/ipa.rb', line 68

def mobileprovision
  @mobileprovision ||= CFPropertyList.native_types(
    CFPropertyList::List.new(data: read_file("embedded.mobileprovision").match(%r{<\?xml.*</plist>}m)[0], format: CFPropertyList::List::FORMAT_AUTO).value
  )
end

#osObject



19
20
21
# File 'lib/app_parser/ipa.rb', line 19

def os
  "ios"
end

#provisioned_devicesObject



39
40
41
# File 'lib/app_parser/ipa.rb', line 39

def provisioned_devices
  mobileprovision["ProvisionedDevices"]
end

#provisions_all_devicesObject

true if In-House



44
45
46
# File 'lib/app_parser/ipa.rb', line 44

def provisions_all_devices
  mobileprovision["ProvisionsAllDevices"] || false
end

#versionObject



23
24
25
# File 'lib/app_parser/ipa.rb', line 23

def version
  info_plist["CFBundleVersion"]
end

#version_stringObject



27
28
29
# File 'lib/app_parser/ipa.rb', line 27

def version_string
  info_plist["CFBundleShortVersionString"]
end