Class: AppInfo::Proguard

Inherits:
File
  • Object
show all
Includes:
Helper::Archive
Defined in:
lib/app_info/proguard.rb

Overview

Proguard parser

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods included from Helper::Archive

#tempdir, #unarchive

Methods inherited from File

#device, #format, #initialize, #not_implemented_error!, #size

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#clear!Object



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/app_info/proguard.rb', line 108

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

#contentsString

Returns contents path of contents.

Returns:

  • (String)

    contents path of contents



104
105
106
# File 'lib/app_info/proguard.rb', line 104

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

#filesObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/app_info/proguard.rb', line 69

def files
  Dir.children(contents).each_with_object([]) do |filename, obj|
    path = ::File.join(contents, filename)
    obj << {
      name: filename,
      path: path,
      size: ::File.size(path)
    }
  end
end

#manifestREXML::Document

Returns:

  • (REXML::Document)


81
82
83
84
85
# File 'lib/app_info/proguard.rb', line 81

def manifest
  return unless manifest?

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

#manifest?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/app_info/proguard.rb', line 36

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

#manifest_pathString

Returns:

  • (String)


93
94
95
# File 'lib/app_info/proguard.rb', line 93

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

#manufacturerSymbol

Returns Manufacturer.

Returns:



14
15
16
# File 'lib/app_info/proguard.rb', line 14

def manufacturer
  Manufacturer::GOOGLE
end

#mapping?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/app_info/proguard.rb', line 31

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

#mapping_pathString

Returns:

  • (String)


88
89
90
# File 'lib/app_info/proguard.rb', line 88

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

#package_nameString?

Returns:

  • (String, nil)


47
48
49
50
51
# File 'lib/app_info/proguard.rb', line 47

def package_name
  return unless manifest?

  manifest.root.attributes['package']
end

#platformSymbol

Returns:



19
20
21
# File 'lib/app_info/proguard.rb', line 19

def platform
  Platform::ANDROID
end

#symbol?Boolean Also known as: resource?

Returns:

  • (Boolean)


41
42
43
# File 'lib/app_info/proguard.rb', line 41

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

#symbol_pathString Also known as: resource_path

Returns:

  • (String)


98
99
100
# File 'lib/app_info/proguard.rb', line 98

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

#uuidString Also known as: debug_id

Returns:

  • (String)


24
25
26
27
# File 'lib/app_info/proguard.rb', line 24

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

#version_codeString? Also known as: build_version

Returns:

  • (String, nil)


62
63
64
65
66
# File 'lib/app_info/proguard.rb', line 62

def version_code
  return unless manifest?

  manifest.root.attributes['versionCode']
end

#version_nameString? Also known as: release_version

Returns:

  • (String, nil)


54
55
56
57
58
# File 'lib/app_info/proguard.rb', line 54

def version_name
  return unless manifest?

  manifest.root.attributes['versionName']
end