Class: IPA::IPAFile

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(filename, &block) ⇒ IPAFile

Returns a new instance of IPAFile.



30
31
32
33
34
35
36
# File 'lib/ipa.rb', line 30

def initialize(filename, &block)
	@zipfile = Zip::ZipFile.open(filename)
	unless block.nil?
		yield self
		close
	end
end

Class Method Details

.open(filename, &block) ⇒ Object



26
27
28
# File 'lib/ipa.rb', line 26

def self.open(filename, &block)
	IPAFile.new(filename, &block)
end

Instance Method Details

#artworkObject



65
66
67
# File 'lib/ipa.rb', line 65

def artwork
	payload_file('iTunesArtwork')
end

#closeObject



38
39
40
# File 'lib/ipa.rb', line 38

def close
	@zipfile.close
end

#iconObject



61
62
63
# File 'lib/ipa.rb', line 61

def icon
	payload_file('Icon.png')
end

#infoObject



56
57
58
59
# File 'lib/ipa.rb', line 56

def info 
	@info_plist ||= Plist::Binary::decode_binary_plist(
		payload_file('Info.plist'))
end

#payload_file(filename) {|data| ... } ⇒ Object

Yields:

  • (data)


50
51
52
53
54
# File 'lib/ipa.rb', line 50

def payload_file(filename, &block)
	data = @zipfile.read(payload_path(filename))
	yield data unless block.nil?
	data
end

#payload_path(filename = nil) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/ipa.rb', line 42

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