Class: AppInfo::Macos

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/app_info/macos.rb

Overview

MacOS App parser

Defined Under Namespace

Modules: ExportType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Macos

Returns a new instance of Macos.



22
23
24
# File 'lib/app_info/macos.rb', line 22

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#app_pathObject



127
128
129
# File 'lib/app_info/macos.rb', line 127

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

#archsObject Also known as: architectures



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

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

#binary_pathObject



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

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



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/app_info/macos.rb', line 131

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

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

#contentsObject



144
145
146
# File 'lib/app_info/macos.rb', line 144

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

#distribution_nameObject



42
43
44
# File 'lib/app_info/macos.rb', line 42

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

#hide_developer_certificatesObject



87
88
89
# File 'lib/app_info/macos.rb', line 87

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

#icons(convert: true) ⇒ Object



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

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

#infoObject



119
120
121
# File 'lib/app_info/macos.rb', line 119

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

#info_pathObject



123
124
125
# File 'lib/app_info/macos.rb', line 123

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

#mobileprovisionObject



91
92
93
94
95
# File 'lib/app_info/macos.rb', line 91

def mobileprovision
  return unless mobileprovision?

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

#mobileprovision?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/app_info/macos.rb', line 97

def mobileprovision?
  File.exist?(mobileprovision_path)
end

#mobileprovision_pathObject



101
102
103
# File 'lib/app_info/macos.rb', line 101

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

#osObject Also known as: file_type



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

def os
  AppInfo::Platform::MACOS
end

#release_typeObject



46
47
48
49
50
51
52
53
54
# File 'lib/app_info/macos.rb', line 46

def release_type
  if stored?
    ExportType::APPSTORE
  elsif mobileprovision?
    ExportType::RELEASE
  else
    ExportType::DEBUG
  end
end

#size(human_size: false) ⇒ Object



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

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

#store_pathObject



105
106
107
# File 'lib/app_info/macos.rb', line 105

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

#stored?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/app_info/macos.rb', line 56

def stored?
  File.exist?(store_path)
end