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.



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

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#app_pathObject



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

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

#archsObject Also known as: architectures



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

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



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

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

#bundle_pathObject



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

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

#clear!Object



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

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

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

#contentsObject



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

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

#distribution_nameObject



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

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

#frameworksObject



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

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

#hide_developer_certificatesObject



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

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

#infoObject



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

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

#metadataObject



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

def 
  return unless metadata?

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

#metadata?Boolean

Returns:

  • (Boolean)


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

def metadata?
  File.exist?()
end

#metadata_pathObject



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

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

#mobileprovisionObject



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

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

  @mobileprovision = MobileProvision.new(mobileprovision_path)
end

#mobileprovision?Boolean

Returns:

  • (Boolean)


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

def mobileprovision?
  File.exist?mobileprovision_path
end

#mobileprovision_pathObject



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

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



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

def os
  AppInfo::Platform::IOS
end

#pluginsObject



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

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

#release_typeObject



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

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

#size(humanable = false) ⇒ Object



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

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

#stored?Boolean

Returns:

  • (Boolean)


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

def stored?
  metadata? ? true : false
end