Class: ReadIpa::IpaFile

Inherits:
Object
  • Object
show all
Defined in:
lib/read_ipa/ipa_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject

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

#plistObject

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_identifierObject



95
96
97
# File 'lib/read_ipa/ipa_file.rb', line 95

def bundle_identifier
  @info_plist.bundle_identifier
end

#executable_fileObject



87
88
89
# File 'lib/read_ipa/ipa_file.rb', line 87

def executable_file
  read_file(executable_file_name)
end

#executable_file_nameObject



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_fileObject



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_prerenderedObject



99
100
101
# File 'lib/read_ipa/ipa_file.rb', line 99

def icon_prerendered
  @info_plist.icon_prerendered
end

#minimum_os_versionObject



46
47
48
# File 'lib/read_ipa/ipa_file.rb', line 46

def minimum_os_version
  @info_plist.minimum_os_version
end

#mobile_provision_fileObject



91
92
93
# File 'lib/read_ipa/ipa_file.rb', line 91

def mobile_provision_file
  read_file("embedded.mobileprovision")
end

#nameObject



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_versionObject



34
35
36
# File 'lib/read_ipa/ipa_file.rb', line 34

def short_version
  @info_plist.short_version
end

#target_os_versionObject



42
43
44
# File 'lib/read_ipa/ipa_file.rb', line 42

def target_os_version
  @info_plist.target_os_version
end

#url_schemesObject



50
51
52
# File 'lib/read_ipa/ipa_file.rb', line 50

def url_schemes
  @info_plist.url_schemes
end

#versionObject



30
31
32
# File 'lib/read_ipa/ipa_file.rb', line 30

def version
  @info_plist.version
end