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.



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

def app_path
  not_implemented_error!(__method__)
end

#archsArray<MachO>? Also known as: architectures

Returns:

  • (Array<MachO>, nil)


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

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)


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

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
78
# File 'lib/app_info/apple.rb', line 75

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

#bundle_idObject



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

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

#bundle_nameObject



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

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

#clear!Object

This method is abstract.

Subclass and override #clear! to implement.



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

def clear!
  not_implemented_error!(__method__)
end

#contentsString

Returns contents path of contents.

Returns:

  • (String)

    contents path of contents



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

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

#deviceObject

See Also:



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

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

#devicesObject



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

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

#display_nameObject



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

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

#distribution_nameString?

Returns:

  • (String, nil)


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

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

#expired_dateObject



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

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)


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

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

#icons(_uncrush: true) ⇒ Object

This method is abstract.

Subclass and override #icons to implement.



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

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

#identifierObject



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

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

#infoInfoPlist

Returns:



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

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

#info_pathObject

This method is abstract.

Subclass and override #info_path to implement.



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

def info_path
  not_implemented_error!(__method__)
end

#ipad?Object

See Also:



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

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

#iphone?Object

See Also:



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

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

#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
78
# File 'lib/app_info/apple.rb', line 75

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

#min_sdk_versionObject



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

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

#mobileprovisionMobileProvision

Returns:



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

def mobileprovision
  return unless mobileprovision?

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

#mobileprovision?Boolean

Returns:

  • (Boolean)


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

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

#mobileprovision_pathObject

This method is abstract.

Subclass and override #mobileprovision_path to implement.



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

def mobileprovision_path
  not_implemented_error!(__method__)
end

#nameObject

See Also:



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

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

#platformObject

See Also:



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

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

#profile_nameObject



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

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

#release_typeString

Returns:

  • (String)


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

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

#release_versionObject



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

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

#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)


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

def stored?
  not_implemented_error!(__method__)
end

#team_identifierObject



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

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

#team_nameObject



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

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

#universal?Object



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

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