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.



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

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#clear!Object



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

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



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

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

#file_typeObject



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

def file_type
  AppInfo::Platform::PROGUARD
end

#manifestObject



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

def manifest
  return unless manifest?

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

#manifest?Boolean

Returns:

  • (Boolean)


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

def manifest?
  File.exist?(manifest_path)
end

#manifest_pathObject



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

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

#mapping?Boolean

Returns:

  • (Boolean)


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

def mapping?
  File.exist?(mapping_path)
end

#mapping_pathObject



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

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

#package_nameObject



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

def package_name
  return unless manifest?

  manifest.root.attributes['package']
end

#releasd_versionObject



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

def releasd_version
  return unless manifest?

  manifest.root.attributes['package']
end

#symbol?Boolean Also known as: resource?

Returns:

  • (Boolean)


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

def symbol?
  File.exist?(symbol_path)
end

#symbol_pathObject Also known as: resource_path



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

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

#uuidObject Also known as: debug_id



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

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



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

def version_code
  return unless manifest?

  manifest.root.attributes['versionCode']
end

#version_nameObject Also known as: release_version



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

def version_name
  return unless manifest?

  manifest.root.attributes['versionName']
end