Class: AppInfo::DSYM
Overview
DSYM parser
Defined Under Namespace
Classes: MachO
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #app_path ⇒ Object
- #build_version ⇒ Object
- #clear! ⇒ Object
- #contents ⇒ Object
- #file_type ⇒ Object
- #identifier ⇒ Object (also: #bundle_id)
- #info ⇒ Object
- #info_path ⇒ Object
-
#initialize(file) ⇒ DSYM
constructor
A new instance of DSYM.
- #macho_type ⇒ Object
- #machos ⇒ Object
- #object ⇒ Object
- #release_version ⇒ Object
Constructor Details
#initialize(file) ⇒ DSYM
Returns a new instance of DSYM.
11 12 13 |
# File 'lib/app_info/dsym.rb', line 11 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/app_info/dsym.rb', line 9 def file @file end |
Instance Method Details
#app_path ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/app_info/dsym.rb', line 67 def app_path unless @app_path path = File.join(contents, 'Contents', 'Resources', 'DWARF') name = Dir.entries(path).reject { |f| ['.', '..'].include?(f) }.first @app_path = File.join(path, name) end @app_path end |
#build_version ⇒ Object
48 49 50 |
# File 'lib/app_info/dsym.rb', line 48 def build_version info.try(:[], 'CFBundleVersion') end |
#clear! ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/app_info/dsym.rb', line 77 def clear! return unless @contents FileUtils.rm_rf(@contents) @contents = nil @app_path = nil @info = nil @object = nil @macho_type = nil end |
#contents ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/app_info/dsym.rb', line 89 def contents unless @contents if File.directory?(@file) @contents = @file else dsym_dir = nil @contents = Util.unarchive(@file, path: 'dsym') do |path, zip_file| zip_file.each do |f| unless dsym_dir dsym_dir = f.name dsym_dir = dsym_dir.split('/')[0] # fix filename is xxx.app.dSYM/Contents end f_path = File.join(path, f.name) zip_file.extract(f, f_path) unless File.exist?(f_path) end end @contents = File.join(@contents, dsym_dir) end end @contents end |
#file_type ⇒ Object
15 16 17 |
# File 'lib/app_info/dsym.rb', line 15 def file_type AppInfo::Platform::DSYM end |
#identifier ⇒ Object Also known as: bundle_id
52 53 54 |
# File 'lib/app_info/dsym.rb', line 52 def identifier info.try(:[], 'CFBundleIdentifier').sub('com.apple.xcode.dsym.', '') end |
#info ⇒ Object
57 58 59 60 61 |
# File 'lib/app_info/dsym.rb', line 57 def info return nil unless File.exist?(info_path) @info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: info_path).value) end |
#info_path ⇒ Object
63 64 65 |
# File 'lib/app_info/dsym.rb', line 63 def info_path @info_path ||= File.join(contents, 'Contents', 'Info.plist') end |
#macho_type ⇒ Object
23 24 25 |
# File 'lib/app_info/dsym.rb', line 23 def macho_type @macho_type ||= ::MachO.open(app_path) end |
#machos ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/app_info/dsym.rb', line 27 def machos @machos ||= case macho_type when ::MachO::MachOFile [MachO.new(macho_type, File.size(app_path))] else size = macho_type.fat_archs.each_with_object([]) do |arch, obj| obj << arch.size end machos = [] macho_type.machos.each_with_index do |file, i| machos << MachO.new(file, size[i]) end machos end end |
#object ⇒ Object
19 20 21 |
# File 'lib/app_info/dsym.rb', line 19 def object @object ||= File.basename(app_path) end |
#release_version ⇒ Object
44 45 46 |
# File 'lib/app_info/dsym.rb', line 44 def release_version info.try(:[], 'CFBundleShortVersionString') end |