Class: IpaReader::IpaFile
- Inherits:
-
Object
- Object
- IpaReader::IpaFile
- Defined in:
- lib/ipa_reader/ipa_file.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#plist ⇒ Object
Returns the value of attribute plist.
Instance Method Summary collapse
- #bundle_identifier ⇒ Object
- #icon_file ⇒ Object
- #icon_prerendered ⇒ Object
-
#initialize(file_path) ⇒ IpaFile
constructor
A new instance of IpaFile.
- #minimum_os_version ⇒ Object
- #mobile_provision_file ⇒ Object
- #name ⇒ Object
- #read_file(regex) ⇒ Object
- #short_version ⇒ Object
- #target_os_version ⇒ Object
- #url_schemes ⇒ Object
- #version ⇒ Object
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_path ⇒ Object
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 |
#plist ⇒ Object
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_identifier ⇒ Object
65 66 67 68 |
# File 'lib/ipa_reader/ipa_file.rb', line 65 def bundle_identifier puts plist["CFBundleIdentifier"].class plist["CFBundleIdentifier"] end |
#icon_file ⇒ Object
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_prerendered ⇒ Object
70 71 72 |
# File 'lib/ipa_reader/ipa_file.rb', line 70 def icon_prerendered plist["UIPrerenderedIcon"] == true end |
#minimum_os_version ⇒ Object
36 37 38 |
# File 'lib/ipa_reader/ipa_file.rb', line 36 def minimum_os_version plist["MinimumOSVersion"].match(/[\d\.]*/)[0] end |
#mobile_provision_file ⇒ Object
61 62 63 |
# File 'lib/ipa_reader/ipa_file.rb', line 61 def mobile_provision_file read_file(/embedded\.mobileprovision$/) end |
#name ⇒ Object
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_version ⇒ Object
24 25 26 |
# File 'lib/ipa_reader/ipa_file.rb', line 24 def short_version plist["CFBundleShortVersionString"] end |
#target_os_version ⇒ Object
32 33 34 |
# File 'lib/ipa_reader/ipa_file.rb', line 32 def target_os_version plist["DTPlatformVersion"].match(/[\d\.]*/)[0] end |
#url_schemes ⇒ Object
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 |
#version ⇒ Object
20 21 22 |
# File 'lib/ipa_reader/ipa_file.rb', line 20 def version plist["CFBundleVersion"] end |