Sha256: e1f38ed36c854507b79b19d4efced3ef90f44a623c3dff376d2d6ecdc3a9e9f7

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

require 'uuidtools'
require 'rexml/document'

module AppInfo
  # Proguard parser
  class Proguard < File
    include Helper::Archive

    NAMESPACE = UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, 'icyleaf.com')

    def file_type
      Format::PROGUARD
    end

    def uuid
      # Similar to https://docs.sentry.io/workflow/debug-files/#proguard-uuids
      UUIDTools::UUID.sha1_create(NAMESPACE, ::File.read(mapping_path)).to_s
    end
    alias debug_id uuid

    def mapping?
      ::File.exist?(mapping_path)
    end

    def manifest?
      ::File.exist?(manifest_path)
    end

    def symbol?
      ::File.exist?(symbol_path)
    end
    alias resource? symbol?

    def package_name
      return unless manifest?

      manifest.root.attributes['package']
    end

    def releasd_version
      return unless manifest?

      manifest.root.attributes['package']
    end

    def version_name
      return unless manifest?

      manifest.root.attributes['versionName']
    end
    alias release_version version_name

    def version_code
      return unless manifest?

      manifest.root.attributes['versionCode']
    end
    alias build_version version_code

    def manifest
      return unless manifest?

      @manifest ||= REXML::Document.new(::File.new(manifest_path))
    end

    def mapping_path
      @mapping_path ||= Dir.glob(::File.join(contents, '*mapping*.txt')).first
    end

    def manifest_path
      @manifest_path ||= ::File.join(contents, 'AndroidManifest.xml')
    end

    def symbol_path
      @symbol_path ||= ::File.join(contents, 'R.txt')
    end
    alias resource_path symbol_path

    def contents
      @contents ||= unarchive(@file, prefix: 'proguard')
    end

    def clear!
      return unless @contents

      FileUtils.rm_rf(@contents)

      @contents = nil
      @manifest = nil
      @mapping_path = nil
      @metadata_path = nil
      @manifest_path = nil
      @symbol_path = nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
app-info-3.0.0.beta1 lib/app_info/proguard.rb