class AppInfo::Macos
MacOS App parser
Attributes
file[R]
Public Class Methods
new(file)
click to toggle source
# File lib/app_info/macos.rb, line 22 def initialize(file) @file = file end
Public Instance Methods
app_path()
click to toggle source
# File lib/app_info/macos.rb, line 127 def app_path @app_path ||= Dir.glob(File.join(contents, '*.app')).first end
archs()
click to toggle source
# 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
Also aliased as: architectures
binary_path()
click to toggle source
# 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!()
click to toggle source
# 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
contents()
click to toggle source
# File lib/app_info/macos.rb, line 144 def contents @contents ||= Util.unarchive(@file, path: 'macos') end
distribution_name()
click to toggle source
# File lib/app_info/macos.rb, line 42 def distribution_name "#{profile_name} - #{team_name}" if profile_name && team_name end
hide_developer_certificates()
click to toggle source
# File lib/app_info/macos.rb, line 87 def hide_developer_certificates mobileprovision.delete('DeveloperCertificates') if mobileprovision? end
icons(convert: true)
click to toggle source
# 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
info()
click to toggle source
# File lib/app_info/macos.rb, line 119 def info @info ||= InfoPlist.new(info_path) end
info_path()
click to toggle source
# File lib/app_info/macos.rb, line 123 def info_path @info_path ||= File.join(app_path, 'Contents', 'Info.plist') end
mobileprovision()
click to toggle source
# File lib/app_info/macos.rb, line 91 def mobileprovision return unless mobileprovision? @mobileprovision ||= MobileProvision.new(mobileprovision_path) end
mobileprovision?()
click to toggle source
# File lib/app_info/macos.rb, line 97 def mobileprovision? File.exist?(mobileprovision_path) end
mobileprovision_path()
click to toggle source
# File lib/app_info/macos.rb, line 101 def mobileprovision_path @mobileprovision_path ||= File.join(app_path, 'Contents', 'embedded.provisionprofile') end
os()
click to toggle source
# File lib/app_info/macos.rb, line 30 def os AppInfo::Platform::MACOS end
Also aliased as: file_type
release_type()
click to toggle source
# 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)
click to toggle source
# File lib/app_info/macos.rb, line 26 def size(human_size: false) AppInfo::Util.file_size(@file, human_size) end
store_path()
click to toggle source
# File lib/app_info/macos.rb, line 105 def store_path @store_path ||= File.join(app_path, 'Contents', '_MASReceipt', 'receipt') end
stored?()
click to toggle source
# File lib/app_info/macos.rb, line 56 def stored? File.exist?(store_path) end
Private Instance Methods
convert_icns_to_png(data)
click to toggle source
Convert iconv to png file (macOS)
# File lib/app_info/macos.rb, line 166 def convert_icns_to_png(data) require 'icns' require 'image_size' data[:sets] ||= [] file = data[:file] reader = Icns::Reader.new(file) Icns::SIZE_TO_TYPE.each do |size, _| dest_filename = "#{File.basename(file, '.icns')}_#{size}x#{size}.png" dest_file = Util.tempdir(File.join(File.dirname(file), dest_filename), prefix: 'converted') next unless icon_data = reader.image(size: size) File.write(dest_file, icon_data, encoding: Encoding::BINARY) data[:sets] << { name: File.basename(dest_filename), file: dest_file, dimensions: ImageSize.path(dest_file).size } end end
icon_file()
click to toggle source
# File lib/app_info/macos.rb, line 150 def icon_file return @icon_file if @icon_file info.icons.each do |key| next unless value = info[key] file = File.join(app_path, 'Contents', 'Resources', "#{value}.icns") next unless File.file?(file) return @icon_file = file end @icon_file = nil end