Class: ReadIpa::IpaFile
- Inherits:
-
Object
- Object
- ReadIpa::IpaFile
- Defined in:
- lib/read_ipa/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
- #executable_file ⇒ Object
- #executable_file_name ⇒ Object
- #find_existing_path(icon_path) ⇒ Object
- #for_ipad? ⇒ Boolean
- #for_iphone? ⇒ Boolean
- #get_highest_res_icon(icons_file_names) ⇒ 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_png(data) ⇒ Object
- #short_version ⇒ Object
- #target_os_version ⇒ Object
- #url_schemes ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(file_path) ⇒ IpaFile
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/read_ipa/ipa_file.rb', line 10 def initialize(file_path) self.file_path = file_path @zipfile = Zip::File.open(file_path) @zipfile.each do |entry| if /.*\.app\/Info\.plist$/ =~ entry.to_s @app_folder = entry.to_s.gsub(/Info\.plist$/, '') break end end if @app_folder.nil? raise "Could not identify Main app Folder" end plist_str = @zipfile.read(@app_folder + "Info.plist") @info_plist = InfoPlist.new(plist_str) cf_plist = CFPropertyList::List.new(data: plist_str, format: CFPropertyList::List::FORMAT_AUTO) self.plist = cf_plist.value.to_rb end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
9 10 11 |
# File 'lib/read_ipa/ipa_file.rb', line 9 def file_path @file_path end |
#plist ⇒ Object
Returns the value of attribute plist.
9 10 11 |
# File 'lib/read_ipa/ipa_file.rb', line 9 def plist @plist end |
Instance Method Details
#bundle_identifier ⇒ Object
95 96 97 |
# File 'lib/read_ipa/ipa_file.rb', line 95 def bundle_identifier @info_plist.bundle_identifier end |
#executable_file ⇒ Object
87 88 89 |
# File 'lib/read_ipa/ipa_file.rb', line 87 def executable_file read_file(executable_file_name) end |
#executable_file_name ⇒ Object
83 84 85 |
# File 'lib/read_ipa/ipa_file.rb', line 83 def executable_file_name @info_plist.executable_file_name end |
#find_existing_path(icon_path) ⇒ Object
111 112 113 114 115 |
# File 'lib/read_ipa/ipa_file.rb', line 111 def find_existing_path(icon_path) without_extension = icon_path.gsub(/\.png$/i, '') regex = /#{Regexp.quote(@app_folder)}#{Regexp.quote(without_extension)}[(\.png)@~]/ @zipfile.entries.find{|e| e.name =~ regex} end |
#for_ipad? ⇒ Boolean
103 104 105 |
# File 'lib/read_ipa/ipa_file.rb', line 103 def for_ipad? @info_plist.for_ipad? end |
#for_iphone? ⇒ Boolean
107 108 109 |
# File 'lib/read_ipa/ipa_file.rb', line 107 def for_iphone? @info_plist.for_iphone? end |
#get_highest_res_icon(icons_file_names) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/read_ipa/ipa_file.rb', line 62 def get_highest_res_icon(icons_file_names) icon_names = icons_file_names .map{ |icon_path| find_existing_path(icon_path) } .compact .uniq(&:name) highest_res_icon = icon_names .map{|entry| entry.get_input_stream.read} .max_by{|data| read_png(data).width } return nil if highest_res_icon.nil? begin return ApplePng.new(highest_res_icon).data rescue NotValidApplePngError highest_res_icon end end |
#icon_file ⇒ Object
79 80 81 |
# File 'lib/read_ipa/ipa_file.rb', line 79 def icon_file get_highest_res_icon(@info_plist.icon_files) end |
#icon_prerendered ⇒ Object
99 100 101 |
# File 'lib/read_ipa/ipa_file.rb', line 99 def icon_prerendered @info_plist.icon_prerendered end |
#minimum_os_version ⇒ Object
46 47 48 |
# File 'lib/read_ipa/ipa_file.rb', line 46 def minimum_os_version @info_plist.minimum_os_version end |
#mobile_provision_file ⇒ Object
91 92 93 |
# File 'lib/read_ipa/ipa_file.rb', line 91 def mobile_provision_file read_file("embedded.mobileprovision") end |
#name ⇒ Object
38 39 40 |
# File 'lib/read_ipa/ipa_file.rb', line 38 def name @info_plist.name end |
#read_png(data) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/read_ipa/ipa_file.rb', line 54 def read_png(data) begin return ApplePng.new(data) rescue NotValidApplePngError return ChunkyPng::Image.from_datastream(ChunkyPNG::Datastream.from_blob(data)) end end |
#short_version ⇒ Object
34 35 36 |
# File 'lib/read_ipa/ipa_file.rb', line 34 def short_version @info_plist.short_version end |
#target_os_version ⇒ Object
42 43 44 |
# File 'lib/read_ipa/ipa_file.rb', line 42 def target_os_version @info_plist.target_os_version end |
#url_schemes ⇒ Object
50 51 52 |
# File 'lib/read_ipa/ipa_file.rb', line 50 def url_schemes @info_plist.url_schemes end |
#version ⇒ Object
30 31 32 |
# File 'lib/read_ipa/ipa_file.rb', line 30 def version @info_plist.version end |