Class: IpaReader::IpaFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ipa_reader/ipa_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ IpaFile

Returns a new instance of IpaFile.



11
12
13
14
15
16
17
18
# File 'lib/ipa_reader/ipa_file.rb', line 11

def initialize(file_path)
  self.file_path = file_path
  info_plist_file = nil
  regex = /Payload\/[^\/]+.app\/Info.plist/
  Zip::ZipFile.foreach(file_path) { |f| info_plist_file = f if f.name.match(regex) }
  cf_plist = CFPropertyList::List.new(:data => self.read_file(regex), :format => CFPropertyList::List::FORMAT_BINARY)
  self.plist = cf_plist.value.to_rb
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



10
11
12
# File 'lib/ipa_reader/ipa_file.rb', line 10

def file_path
  @file_path
end

#plistObject

Returns the value of attribute plist.



10
11
12
# File 'lib/ipa_reader/ipa_file.rb', line 10

def plist
  @plist
end

Instance Method Details

#bundle_identifierObject



65
66
67
68
# File 'lib/ipa_reader/ipa_file.rb', line 65

def bundle_identifier
  puts plist["CFBundleIdentifier"].class
  plist["CFBundleIdentifier"]
end

#icon_fileObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ipa_reader/ipa_file.rb', line 48

def icon_file
  if plist["CFBundleIconFiles"]
    data = read_file(Regexp.new("#{plist["CFBundleIconFiles"][0]}$"))
  elsif plist["CFBundleIconFile"]
    data = read_file(Regexp.new("#{plist["CFBundleIconFile"]}$"))
  end
  if data
    IpaReader::PngFile.normalize_png(data)
  else
    nil
  end
end

#icon_prerenderedObject



70
71
72
# File 'lib/ipa_reader/ipa_file.rb', line 70

def icon_prerendered
  plist["UIPrerenderedIcon"] == true
end

#minimum_os_versionObject



36
37
38
# File 'lib/ipa_reader/ipa_file.rb', line 36

def minimum_os_version
  plist["MinimumOSVersion"].match(/[\d\.]*/)[0]
end

#mobile_provision_fileObject



61
62
63
# File 'lib/ipa_reader/ipa_file.rb', line 61

def mobile_provision_file
  read_file(/embedded\.mobileprovision$/)
end

#nameObject



28
29
30
# File 'lib/ipa_reader/ipa_file.rb', line 28

def name
  plist["CFBundleDisplayName"]
end

#read_file(regex) ⇒ Object



74
75
76
77
78
# File 'lib/ipa_reader/ipa_file.rb', line 74

def read_file(regex)
  file = nil
  Zip::ZipFile.foreach(self.file_path) { |f| file = f if f.name.match(regex) }
  file.get_input_stream.read
end

#short_versionObject



24
25
26
# File 'lib/ipa_reader/ipa_file.rb', line 24

def short_version
  plist["CFBundleShortVersionString"]
end

#target_os_versionObject



32
33
34
# File 'lib/ipa_reader/ipa_file.rb', line 32

def target_os_version
  plist["DTPlatformVersion"].match(/[\d\.]*/)[0]
end

#url_schemesObject



40
41
42
43
44
45
46
# File 'lib/ipa_reader/ipa_file.rb', line 40

def url_schemes
  if plist["CFBundleURLTypes"] && plist["CFBundleURLTypes"][0] && plist["CFBundleURLTypes"][0]["CFBundleURLSchemes"]
    plist["CFBundleURLTypes"][0]["CFBundleURLSchemes"]
  else
    []
  end
end

#versionObject



20
21
22
# File 'lib/ipa_reader/ipa_file.rb', line 20

def version
  plist["CFBundleVersion"]
end