Class: AppInfo::Proguard

Inherits:
Object show all
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 collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Proguard

Returns a new instance of Proguard.



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

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



11
12
13
# File 'lib/app_info/proguard.rb', line 11

def file
  @file
end

Instance Method Details

#clear!Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/app_info/proguard.rb', line 89

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

#contentsObject



85
86
87
# File 'lib/app_info/proguard.rb', line 85

def contents
  @contents ||= Util.unarchive(@file, path: 'proguard')
end

#file_typeObject



17
18
19
# File 'lib/app_info/proguard.rb', line 17

def file_type
  AppInfo::Platform::PROGUARD
end

#manifestObject



66
67
68
69
70
# File 'lib/app_info/proguard.rb', line 66

def manifest
  return unless manifest?

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

#manifest?Boolean

Returns:

  • (Boolean)


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

def manifest?
  File.exist?(manifest_path)
end

#manifest_pathObject



76
77
78
# File 'lib/app_info/proguard.rb', line 76

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

#mapping?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/app_info/proguard.rb', line 27

def mapping?
  File.exist?(mapping_path)
end

#mapping_pathObject



72
73
74
# File 'lib/app_info/proguard.rb', line 72

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

#package_nameObject



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

def package_name
  return unless manifest?

  manifest.root.attributes['package']
end

#releasd_versionObject



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

def releasd_version
  return unless manifest?

  manifest.root.attributes['package']
end

#symbol?Boolean Also known as: resource?

Returns:

  • (Boolean)


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

def symbol?
  File.exist?(symbol_path)
end

#symbol_pathObject Also known as: resource_path



80
81
82
# File 'lib/app_info/proguard.rb', line 80

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

#uuidObject Also known as: debug_id



21
22
23
24
# File 'lib/app_info/proguard.rb', line 21

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_codeObject Also known as: build_version



59
60
61
62
63
# File 'lib/app_info/proguard.rb', line 59

def version_code
  return unless manifest?

  manifest.root.attributes['versionCode']
end

#version_nameObject Also known as: release_version



52
53
54
55
56
# File 'lib/app_info/proguard.rb', line 52

def version_name
  return unless manifest?

  manifest.root.attributes['versionName']
end