Class: IPA::IPAFile
- Inherits:
-
Object
- Object
- IPA::IPAFile
- Defined in:
- lib/ipa.rb
Constant Summary collapse
- MAPPED_INFO_KEYS =
{ :name => 'CFBundleName', :display_name => 'CFBundleDisplayName', :identifier => 'CFBundleIdentifier', :icon_path => 'CFBundleIconFile', :icon_paths => 'CFBundleIconFiles', :is_iphone => 'LSRequiresIPhoneOS', :app_category => 'LSApplicationCategoryType', :version => 'CFBundleVersion', :version_string => 'CFBundleShortVersionString', :minimum_os_version => 'MinimumOSVersion', :device_family => 'UIDeviceFamily' }
Class Method Summary collapse
Instance Method Summary collapse
- #artwork ⇒ Object
- #close ⇒ Object
-
#icons ⇒ Object
Note: The returned pngs are crushed by Apple during the ipa creation.
- #info ⇒ Object
-
#initialize(filename, &block) ⇒ IPAFile
constructor
A new instance of IPAFile.
- #payload_file(filename) {|data| ... } ⇒ Object
- #payload_path(filename = nil) ⇒ Object
Constructor Details
#initialize(filename, &block) ⇒ IPAFile
Returns a new instance of IPAFile.
31 32 33 34 35 36 37 |
# File 'lib/ipa.rb', line 31 def initialize(filename, &block) @zipfile = Zip::ZipFile.open(filename) unless block.nil? yield self close end end |
Class Method Details
Instance Method Details
#artwork ⇒ Object
99 100 101 |
# File 'lib/ipa.rb', line 99 def artwork payload_file('iTunesArtwork') end |
#close ⇒ Object
39 40 41 |
# File 'lib/ipa.rb', line 39 def close @zipfile.close end |
#icons ⇒ Object
Note: The returned pngs are crushed by Apple during the ipa creation. To uncrush use: ‘xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations crushed.png uncrushed.png`
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ipa.rb', line 68 def icons paths = [] path_keys = ['CFBundleIcons', 'CFBundleIcons~ipad'] path_keys.each do |path_key| icons = info && (info[path_key] && info[path_key]['CFBundlePrimaryIcon'] && (info[path_key]['CFBundlePrimaryIcon']['CFBundleIconFile'] || info[path_key]['CFBundlePrimaryIcon']['CFBundleIconFiles'])) paths.push(*icons) end paths << 'Icon.png' if paths.size == 0 unless paths.is_a?(Array) paths = [paths] end paths = paths.map do |path| begin @zipfile.entries.entries.map { |e| File.basename(e.name) }.select { |name| name.start_with?(path) } rescue Exception => e STDERR.puts "\n\nException #{e}\n\n" nil end end.flatten.compact.map do |path| [path, Proc.new { payload_file(path) }] end Hash[paths] end |
#info ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/ipa.rb', line 57 def info if @info_plist.nil? data = payload_file('Info.plist') plist = CFPropertyList::List.new(:data => data) @info_plist = CFPropertyList.native_types(plist.value) end @info_plist end |
#payload_file(filename) {|data| ... } ⇒ Object
51 52 53 54 55 |
# File 'lib/ipa.rb', line 51 def payload_file(filename, &block) data = @zipfile.read(payload_path(filename)) yield data unless block.nil? data end |
#payload_path(filename = nil) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ipa.rb', line 43 def payload_path(filename = nil) @payload_path ||= File.join('Payload', @zipfile.dir.entries('Payload'). first{ |name| name =~ /\.app$/ }) filename.nil? ? @payload_path : File.join(@payload_path, filename) end |