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.



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

def initialize(file_path)
  self.file_path = file_path
  info_plist_file = nil
  Zip::ZipFile.foreach(file_path) { |f| info_plist_file = f if f.name.match(/\/Info.plist/) }
  self.plist = Plist::Binary.decode_binary_plist(self.read_file(/\/Info.plist/))
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



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

def file_path
  @file_path
end

#plistObject

Returns the value of attribute plist.



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

def plist
  @plist
end

Instance Method Details

#bundle_identifierObject



58
59
60
# File 'lib/ipa_reader/ipa_file.rb', line 58

def bundle_identifier
  plist["CFBundleIdentifier"]
end

#icon_fileObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ipa_reader/ipa_file.rb', line 41

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



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

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

#minimum_os_versionObject



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

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

#mobile_provision_fileObject



54
55
56
# File 'lib/ipa_reader/ipa_file.rb', line 54

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

#nameObject



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

def name
  plist["CFBundleDisplayName"]
end

#read_file(regex) ⇒ Object



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

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

#target_os_versionObject



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

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

#url_schemesObject



33
34
35
36
37
38
39
# File 'lib/ipa_reader/ipa_file.rb', line 33

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

#versionObject



17
18
19
# File 'lib/ipa_reader/ipa_file.rb', line 17

def version
  plist["CFBundleVersion"]
end