Class: AppInfo::Macos

Inherits:
Apple show all
Defined in:
lib/app_info/macos.rb

Overview

MacOS App parser

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 inherited from Apple

#archs, #build_type, #build_version, #bundle_id, #bundle_name, #contents, #device, #devices, #display_name, #distribution_name, #expired_date, #hide_developer_certificates, #identifier, #info, #ipad?, #iphone?, #manufacturer, #min_os_version, #mobileprovision, #mobileprovision?, #name, #platform, #profile_name, #release_type, #release_version, #size, #team_identifier, #team_name, #universal?

Methods included from Helper::Archive

#tempdir, #unarchive

Methods included from Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#device, #format, #initialize, #manufacturer, #not_implemented_error!, #platform, #size

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#app_pathString

Returns:

  • (String)


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

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

#binary_pathString

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
# File 'lib/app_info/macos.rb', line 69

def binary_path
  return @binary_path if @binary_path

  base_path = ::File.join(app_path, 'Contents', 'MacOS')
  binary = info['CFBundleExecutable']
  return ::File.join(base_path, binary) if binary

  @binary_path ||= Dir.glob(::File.join(base_path, '*')).first
end

#clear!Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/app_info/macos.rb', line 89

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

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

#icons(convert: true) ⇒ Array<Hash{Symbol => String, Array<Integer>}>

Full icons metadata

Examples:

uncovert .icons

macos.icons
# => [
#   {
#     name: 'icon.icns',
#     file: '/path/to/icon.icns',
#   }
# ]

coverted .icons

macos.icons(convert: true)
# => [
#   {
#     name: 'converted_icon_32x32.png',
#     file: '/path/to/converted_icon_32x32.png',
#     dimensions: [32, 32]
#   },
#   {
#     name: 'converted_icon_120x120.png',
#     file: '/path/to/converted_icon_120x120.png',
#     dimensions: [120, 120]
#   },
# ]

Parameters:

  • convert (Boolean) (defaults to: true)

    Convert .icons to .png format

Returns:

  • (Array<Hash{Symbol => String, Array<Integer>}>)

    icons paths of icons



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/app_info/macos.rb', line 41

def icons(convert: true)
  return unless icon_file

  data = {
    name: ::File.basename(icon_file),
    file: icon_file
  }

  convert_icns_to_png(data) if convert
  data
end

#info_pathString

Returns:

  • (String)


80
81
82
# File 'lib/app_info/macos.rb', line 80

def info_path
  @info_path ||= ::File.join(app_path, 'Contents', 'Info.plist')
end

#min_sdk_versionObject



13
# File 'lib/app_info/macos.rb', line 13

def_delegators :info, :min_system_version

#mobileprovision_pathString

Returns:

  • (String)


59
60
61
# File 'lib/app_info/macos.rb', line 59

def mobileprovision_path
  @mobileprovision_path ||= ::File.join(app_path, 'Contents', 'embedded.provisionprofile')
end

#store_pathString

Returns:

  • (String)


64
65
66
# File 'lib/app_info/macos.rb', line 64

def store_path
  @store_path ||= ::File.join(app_path, 'Contents', '_MASReceipt', 'receipt')
end

#stored?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/app_info/macos.rb', line 54

def stored?
  ::File.exist?(store_path)
end