Class: AppInfo::Apple

Inherits:
File
  • Object
show all
Extended by:
Forwardable
Includes:
Helper::Archive, Helper::HumanFileSize
Defined in:
lib/app_info/apple.rb

Overview

Apple base parser for ipa and macos file

Direct Known Subclasses

IPA, Macos

Defined Under Namespace

Modules: ExportType

Constant Summary

Constants included from Helper::HumanFileSize

Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods included from Helper::Archive

#tempdir, #unarchive

Methods included from Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#format, #initialize, #not_implemented_error!

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#app_pathObject

This method is abstract.

Subclass and override #app_path to implement.



178
179
180
# File 'lib/app_info/apple.rb', line 178

def app_path
  not_implemented_error!(__method__)
end

#archsArray<MachO>? Also known as: architectures

Returns:

  • (Array<MachO>, nil)


119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/app_info/apple.rb', line 119

def archs
  return unless ::File.exist?(binary_path)

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

#build_typeString

return iOS build configuration, not correct in macOS app.

Returns:

  • (String)


108
109
110
111
112
113
114
115
116
# File 'lib/app_info/apple.rb', line 108

def build_type
  if mobileprovision?
    return ExportType::RELEASE if macos?

    devices ? ExportType::ADHOC : ExportType::ENTERPRISE
  else
    ExportType::DEBUG
  end
end

#build_versionObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#bundle_idObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#bundle_nameObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#clear!Object

This method is abstract.

Subclass and override #clear! to implement.



183
184
185
# File 'lib/app_info/apple.rb', line 183

def clear!
  not_implemented_error!(__method__)
end

#contentsString

Returns contents path of contents.

Returns:

  • (String)

    contents path of contents



188
189
190
# File 'lib/app_info/apple.rb', line 188

def contents
  @contents ||= unarchive(@file, prefix: format.to_s)
end

#deviceObject

See Also:



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#devicesObject



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

def_delegators :mobileprovision, :devices, :team_name, :team_identifier,
:profile_name, :expired_date

#display_nameObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#distribution_nameString?

Returns:

  • (String, nil)


93
94
95
# File 'lib/app_info/apple.rb', line 93

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

#expired_dateObject



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

def_delegators :mobileprovision, :devices, :team_name, :team_identifier,
:profile_name, :expired_date

#hide_developer_certificatesnil

force remove developer certificate data from #mobileprovision method

Returns:

  • (nil)


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

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

#icons(_uncrush: true) ⇒ Object

This method is abstract.

Subclass and override #icons to implement.



135
136
137
# File 'lib/app_info/apple.rb', line 135

def icons(_uncrush: true)
  not_implemented_error!(__method__)
end

#identifierObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#infoInfoPlist

Returns:



168
169
170
# File 'lib/app_info/apple.rb', line 168

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

#info_pathObject

This method is abstract.

Subclass and override #info_path to implement.



173
174
175
# File 'lib/app_info/apple.rb', line 173

def info_path
  not_implemented_error!(__method__)
end

#ipad?Object

See Also:



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#iphone?Object

See Also:



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#manufacturerSymbol

Returns Manufacturer.

Returns:



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

def manufacturer
  Manufacturer::APPLE
end

#min_os_versionObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#min_sdk_versionObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#mobileprovisionMobileProvision

Returns:



151
152
153
154
155
# File 'lib/app_info/apple.rb', line 151

def mobileprovision
  return unless mobileprovision?

  @mobileprovision ||= MobileProvision.new(mobileprovision_path)
end

#mobileprovision?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/app_info/apple.rb', line 158

def mobileprovision?
  ::File.exist?(mobileprovision_path)
end

#mobileprovision_pathObject

This method is abstract.

Subclass and override #mobileprovision_path to implement.



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

def mobileprovision_path
  not_implemented_error!(__method__)
end

#nameObject

See Also:



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#platformObject

See Also:



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#profile_nameObject



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

def_delegators :mobileprovision, :devices, :team_name, :team_identifier,
:profile_name, :expired_date

#release_typeString

Returns:

  • (String)


98
99
100
101
102
103
104
# File 'lib/app_info/apple.rb', line 98

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

#release_versionObject



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version

#size(human_size: false) ⇒ Integer, String

return file size

Examples:

Read file size in integer

aab.size                    # => 3618865

Read file size in human readabale

aab.size(human_size: true)  # => '3.45 MB'

Parameters:

  • human_size (Boolean) (defaults to: false)

    Convert integer value to human readable.

Returns:

  • (Integer, String)


43
44
45
# File 'lib/app_info/apple.rb', line 43

def size(human_size: false)
  file_to_human_size(@file, human_size: human_size)
end

#stored?Boolean

This method is abstract.

Subclass and override #stored? to implement.

Returns:

  • (Boolean)


140
141
142
# File 'lib/app_info/apple.rb', line 140

def stored?
  not_implemented_error!(__method__)
end

#team_identifierObject



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

def_delegators :mobileprovision, :devices, :team_name, :team_identifier,
:profile_name, :expired_date

#team_nameObject



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

def_delegators :mobileprovision, :devices, :team_name, :team_identifier,
:profile_name, :expired_date

#universal?Object



75
76
77
# File 'lib/app_info/apple.rb', line 75

def_delegators :info, :device, :platform, :iphone?, :ipad?, :universal?, :macos?,
:build_version, :name, :release_version, :identifier, :bundle_id,
:display_name, :bundle_name, :min_sdk_version, :min_os_version