Class: AppInfo::Proguard

Inherits:
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 collapse

Instance Method Summary collapse

Methods included from Helper::Archive

#tempdir, #unarchive

Constructor Details

#initialize(file) ⇒ Proguard

Returns a new instance of Proguard.



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

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#clear!Object



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

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



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

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

#file_typeObject



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

def file_type
  Platform::PROGUARD
end

#manifestObject



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

def manifest
  return unless manifest?

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

#manifest?Boolean

Returns:

  • (Boolean)


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

def manifest?
  File.exist?(manifest_path)
end

#manifest_pathObject



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

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

#mapping?Boolean

Returns:

  • (Boolean)


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

def mapping?
  File.exist?(mapping_path)
end

#mapping_pathObject



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

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

#package_nameObject



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

def package_name
  return unless manifest?

  manifest.root.attributes['package']
end

#releasd_versionObject



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

def releasd_version
  return unless manifest?

  manifest.root.attributes['package']
end

#symbol?Boolean Also known as: resource?

Returns:

  • (Boolean)


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

def symbol?
  File.exist?(symbol_path)
end

#symbol_pathObject Also known as: resource_path



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

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

#uuidObject Also known as: debug_id



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

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



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

def version_code
  return unless manifest?

  manifest.root.attributes['versionCode']
end

#version_nameObject Also known as: release_version



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

def version_name
  return unless manifest?

  manifest.root.attributes['versionName']
end