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' }
Class Method Summary collapse
Instance Method Summary collapse
- #artwork ⇒ Object
- #close ⇒ Object
- #icon ⇒ Object
- #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.
29 30 31 32 33 34 35 |
# File 'lib/ipa.rb', line 29 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
74 75 76 |
# File 'lib/ipa.rb', line 74 def artwork payload_file('iTunesArtwork') end |
#close ⇒ Object
37 38 39 |
# File 'lib/ipa.rb', line 37 def close @zipfile.close end |
#icon ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/ipa.rb', line 64 def icon path = info && info['CFBundleIcons'] && info['CFBundleIcons']['CFBundlePrimaryIcon'] && (info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFile'] || info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'].first) path ||= 'Icon.png' payload_file(path) end |
#info ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/ipa.rb', line 55 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
49 50 51 52 53 |
# File 'lib/ipa.rb', line 49 def payload_file(filename, &block) data = @zipfile.read(payload_path(filename)) yield data unless block.nil? data end |
#payload_path(filename = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ipa.rb', line 41 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 |