Class: AppInfo::IPA

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/app_info/ipa.rb

Overview

IPA parser

Defined Under Namespace

Modules: ExportType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ IPA

Returns a new instance of IPA.



28
29
30
# File 'lib/app_info/ipa.rb', line 28

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



15
16
17
# File 'lib/app_info/ipa.rb', line 15

def file
  @file
end

Instance Method Details

#app_pathObject



146
147
148
# File 'lib/app_info/ipa.rb', line 146

def app_path
  @app_path ||= Dir.glob(File.join(contents, 'Payload', '*.app')).first
end

#archsObject Also known as: architectures



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/app_info/ipa.rb', line 72

def archs
  return unless File.exist?(bundle_path)

  file = MachO.open(bundle_path)
  case file
  when MachO::MachOFile
    [file.cpusubtype]
  else
    file.machos.each_with_object([]) do |arch, obj|
      obj << arch.cpusubtype
    end
  end
end

#build_typeObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/app_info/ipa.rb', line 60

def build_type
  if mobileprovision?
    if devices
      ExportType::ADHOC
    else
      ExportType::ENTERPRISE
    end
  else
    ExportType::DEBUG
  end
end

#bundle_pathObject



138
139
140
# File 'lib/app_info/ipa.rb', line 138

def bundle_path
  @bundle_path ||= File.join(app_path, info.bundle_name)
end

#clear!Object



150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/app_info/ipa.rb', line 150

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

  @contents = nil
  @icons = nil
  @app_path = nil
  @metadata = nil
  @metadata_path = nil
  @info = nil
end

#contentsObject



163
164
165
# File 'lib/app_info/ipa.rb', line 163

def contents
  @contents ||= Util.unarchive(@file, path: 'ios')
end

#distribution_nameObject



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

def distribution_name
  "#{profile_name} - #{team_name}" if profile_name && team_name
end

#frameworksObject



95
96
97
# File 'lib/app_info/ipa.rb', line 95

def frameworks
  @frameworks ||= Framework.parse(app_path)
end

#hide_developer_certificatesObject



99
100
101
# File 'lib/app_info/ipa.rb', line 99

def hide_developer_certificates
  mobileprovision.delete('DeveloperCertificates') if mobileprovision?
end

#infoObject



142
143
144
# File 'lib/app_info/ipa.rb', line 142

def info
  @info ||= InfoPlist.new(app_path)
end

#metadataObject



124
125
126
127
128
# File 'lib/app_info/ipa.rb', line 124

def 
  return unless metadata?

  @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: ).value)
end

#metadata?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/app_info/ipa.rb', line 130

def metadata?
  File.exist?()
end

#metadata_pathObject



134
135
136
# File 'lib/app_info/ipa.rb', line 134

def 
  @metadata_path ||= File.join(contents, 'iTunesMetadata.plist')
end

#mobileprovisionObject



103
104
105
106
107
108
# File 'lib/app_info/ipa.rb', line 103

def mobileprovision
  return unless mobileprovision?
  return @mobileprovision if @mobileprovision

  @mobileprovision = MobileProvision.new(mobileprovision_path)
end

#mobileprovision?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/app_info/ipa.rb', line 110

def mobileprovision?
  File.exist?mobileprovision_path
end

#mobileprovision_pathObject



114
115
116
117
118
119
120
121
122
# File 'lib/app_info/ipa.rb', line 114

def mobileprovision_path
  filename = 'embedded.mobileprovision'
  @mobileprovision_path ||= File.join(@file, filename)
  unless File.exist?(@mobileprovision_path)
    @mobileprovision_path = File.join(app_path, filename)
  end

  @mobileprovision_path
end

#osObject Also known as: file_type



36
37
38
# File 'lib/app_info/ipa.rb', line 36

def os
  AppInfo::Platform::IOS
end

#pluginsObject



91
92
93
# File 'lib/app_info/ipa.rb', line 91

def plugins
  @plugins ||= Plugin.parse(app_path)
end

#release_typeObject



52
53
54
55
56
57
58
# File 'lib/app_info/ipa.rb', line 52

def release_type
  if stored?
    ExportType::RELEASE
  else
    build_type
  end
end

#size(humanable = false) ⇒ Object



32
33
34
# File 'lib/app_info/ipa.rb', line 32

def size(humanable = false)
  AppInfo::Util.file_size(@file, humanable)
end

#stored?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/app_info/ipa.rb', line 87

def stored?
  metadata? ? true : false
end