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.



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

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



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

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

#archsObject Also known as: architectures



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

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



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

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

#bundle_pathObject



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

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

#cleanup!Object



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/app_info/ipa.rb', line 140

def cleanup!
  return unless @contents

  FileUtils.rm_rf(@contents)

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

#distribution_nameObject



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

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

#hide_developer_certificatesObject



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

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

#infoObject



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

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

#metadataObject



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

def 
  return unless metadata?

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

#metadata?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/app_info/ipa.rb', line 120

def metadata?
  File.exist?()
end

#metadata_pathObject



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

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

#mobileprovisionObject



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

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

  @mobileprovision = MobileProvision.new(mobileprovision_path)
end

#mobileprovision?Boolean

Returns:

  • (Boolean)


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

def mobileprovision?
  File.exist?mobileprovision_path
end

#mobileprovision_pathObject



104
105
106
107
108
109
110
111
112
# File 'lib/app_info/ipa.rb', line 104

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



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

def os
  AppInfo::Platform::IOS
end

#release_typeObject



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

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

#size(humanable = false) ⇒ Object



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

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

#stored?Boolean

Returns:

  • (Boolean)


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

def stored?
  metadata? ? true : false
end