class AppInfo::DSYM

DSYM parser

Attributes

file[R]

Public Class Methods

new(file) click to toggle source
# File lib/app_info/dsym.rb, line 10
def initialize(file)
  @file = file
end

Public Instance Methods

app_path() click to toggle source
# File lib/app_info/dsym.rb, line 66
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() click to toggle source
# File lib/app_info/dsym.rb, line 47
def build_version
  info.try(:[], 'CFBundleVersion')
end
bundle_id()
Alias for: identifier
clear!() click to toggle source
# File lib/app_info/dsym.rb, line 76
def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

  @contents = nil
  @app_path = nil
  @info = nil
  @object = nil
  @macho_type = nil
end
contents() click to toggle source
# File lib/app_info/dsym.rb, line 88
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
            # fix filename is xxx.app.dSYM/Contents
            dsym_dir = dsym_dir.split('/')[0] if dsym_dir.include?('/')
          end

          f_path = File.join(path, f.name)
          FileUtils.mkdir_p(File.dirname(f_path))
          f.extract(f_path) unless File.exist?(f_path)
        end
      end

      @contents = File.join(@contents, dsym_dir)
    end
  end

  @contents
end
file_type() click to toggle source
# File lib/app_info/dsym.rb, line 14
def file_type
  AppInfo::Platform::DSYM
end
identifier() click to toggle source
# File lib/app_info/dsym.rb, line 51
def identifier
  info.try(:[], 'CFBundleIdentifier').sub('com.apple.xcode.dsym.', '')
end
Also aliased as: bundle_id
info() click to toggle source
# File lib/app_info/dsym.rb, line 56
def info
  return nil unless File.exist?(info_path)

  @info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: info_path).value)
end
info_path() click to toggle source
# File lib/app_info/dsym.rb, line 62
def info_path
  @info_path ||= File.join(contents, 'Contents', 'Info.plist')
end
macho_type() click to toggle source
# File lib/app_info/dsym.rb, line 22
def macho_type
  @macho_type ||= ::MachO.open(app_path)
end
machos() click to toggle source
# File lib/app_info/dsym.rb, line 26
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() click to toggle source
# File lib/app_info/dsym.rb, line 18
def object
  @object ||= File.basename(app_path)
end
release_version() click to toggle source
# File lib/app_info/dsym.rb, line 43
def release_version
  info.try(:[], 'CFBundleShortVersionString')
end