Class: AppInfo::Macos
- Extended by:
- Forwardable
- Defined in:
- lib/app_info/macos.rb
Overview
MacOS App parser
Defined Under Namespace
Modules: ExportType
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #app_path ⇒ Object
- #archs ⇒ Object (also: #architectures)
- #binary_path ⇒ Object
- #clear! ⇒ Object
- #contents ⇒ Object
- #distribution_name ⇒ Object
- #hide_developer_certificates ⇒ Object
- #icons(convert: true) ⇒ Object
- #info ⇒ Object
- #info_path ⇒ Object
-
#initialize(file) ⇒ Macos
constructor
A new instance of Macos.
- #mobileprovision ⇒ Object
- #mobileprovision? ⇒ Boolean
- #mobileprovision_path ⇒ Object
- #os ⇒ Object (also: #file_type)
- #release_type ⇒ Object
- #size(human_size: false) ⇒ Object
- #store_path ⇒ Object
- #stored? ⇒ Boolean
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
#file ⇒ Object (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_path ⇒ Object
127 128 129 |
# File 'lib/app_info/macos.rb', line 127 def app_path @app_path ||= Dir.glob(File.join(contents, '*.app')).first end |
#archs ⇒ Object 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_path ⇒ Object
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 |
#contents ⇒ Object
144 145 146 |
# File 'lib/app_info/macos.rb', line 144 def contents @contents ||= Util.unarchive(@file, path: 'macos') end |
#distribution_name ⇒ Object
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_certificates ⇒ Object
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 |
#info ⇒ Object
119 120 121 |
# File 'lib/app_info/macos.rb', line 119 def info @info ||= InfoPlist.new(info_path) end |
#info_path ⇒ Object
123 124 125 |
# File 'lib/app_info/macos.rb', line 123 def info_path @info_path ||= File.join(app_path, 'Contents', 'Info.plist') end |
#mobileprovision ⇒ Object
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
97 98 99 |
# File 'lib/app_info/macos.rb', line 97 def mobileprovision? File.exist?(mobileprovision_path) end |
#mobileprovision_path ⇒ Object
101 102 103 |
# File 'lib/app_info/macos.rb', line 101 def mobileprovision_path @mobileprovision_path ||= File.join(app_path, 'Contents', 'embedded.provisionprofile') end |
#os ⇒ Object Also known as: file_type
30 31 32 |
# File 'lib/app_info/macos.rb', line 30 def os AppInfo::Platform::MACOS end |
#release_type ⇒ Object
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_path ⇒ Object
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
56 57 58 |
# File 'lib/app_info/macos.rb', line 56 def stored? File.exist?(store_path) end |