Class: Pliney::IPA

Inherits:
Object
  • Object
show all
Defined in:
lib/pliney/ipa.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zipfile) ⇒ IPA

Returns a new instance of IPA.



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

def initialize(zipfile)
    @zipfile = zipfile
end

Instance Attribute Details

#zipfileObject (readonly)

TODO - creating an ipa from scratch? def self.create(path)

new(Zip::File.open(path, Zip::File::CREATE))

end



24
25
26
# File 'lib/pliney/ipa.rb', line 24

def zipfile
  @zipfile
end

Class Method Details

.from_path(path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/pliney/ipa.rb', line 8

def self.from_path(path)
    ipa = new(Zip::File.open(path))
    if block_given?
        ret = yield(ipa)
        ipa.close
        return ret
    else
        return ipa
    end
end

Instance Method Details

#appdirObject



30
31
32
# File 'lib/pliney/ipa.rb', line 30

def appdir
    @appdir ||= find_appdir
end

#bundle_identifierObject



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

def bundle_identifier
    return info_plist["CFBundleIdentifier"]
end

#bundle_short_versionObject



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

def bundle_short_version
    return info_plist["CFBundleShortVersionString"]
end

#bundle_versionObject



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

def bundle_version
    return info_plist["CFBundleVersion"]
end

#closeObject



76
77
78
# File 'lib/pliney/ipa.rb', line 76

def close
    @zipfile.close
end

#executable_entryObject



68
69
70
# File 'lib/pliney/ipa.rb', line 68

def executable_entry
    return get_entry(executable_path)
end

#executable_pathObject



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

def executable_path
    return appdir.join(info_plist["CFBundleExecutable"])
end

#find_appdirObject



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

def find_appdir
    if e = @zipfile.find{|ent| ent.directory? and ent.name =~ /^Payload\/[^\/]*\.app\/$/ }
        return Pathname(e.name)
    end
end

#get_entry(path) ⇒ Object



80
81
82
# File 'lib/pliney/ipa.rb', line 80

def get_entry(path)
    return @zipfile.find_entry(path.to_s)
end

#info_plistObject



48
49
50
# File 'lib/pliney/ipa.rb', line 48

def info_plist
    return parse_plist_entry(appdir.join("Info.plist"))
end

#lsObject



72
73
74
# File 'lib/pliney/ipa.rb', line 72

def ls
    return @zipfile.entries.map{|e| e.name}
end

#parse_plist_entry(path) ⇒ Object



34
35
36
# File 'lib/pliney/ipa.rb', line 34

def parse_plist_entry(path)
    Pliney.parse_plist(read_path(path))
end

#provisioning_profileObject



84
85
86
87
88
89
90
91
92
# File 'lib/pliney/ipa.rb', line 84

def provisioning_profile
    begin
        profile_data = read_path(appdir.join("embedded.mobileprovision"))
    rescue Errno::ENOENT
        return nil
    end

    ProvisioningProfile.from_asn1(profile_data)
end

#read_path(path, *args) ⇒ Object



44
45
46
# File 'lib/pliney/ipa.rb', line 44

def read_path(path, *args)
    return @zipfile.get_input_stream(path.to_s){|sio| sio.read(*args)}
end