Class: AppPermissionStatistics::Extracter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#defalut_store_path, #entitlements_yaml_name, #report_file_name, #versions_yaml_name
#createsig
#tempdir, #unarchive
Constructor Details
#initialize(file, store_path = nil) ⇒ Extracter
Returns a new instance of Extracter.
21
22
23
24
|
# File 'lib/app_permission_statistics/extracter.rb', line 21
def initialize(file, store_path = nil)
@file = file
@store_path = store_path
end
|
Instance Attribute Details
Returns the value of attribute file.
18
19
20
|
# File 'lib/app_permission_statistics/extracter.rb', line 18
def file
@file
end
|
#store_path ⇒ Object
Returns the value of attribute store_path.
19
20
21
|
# File 'lib/app_permission_statistics/extracter.rb', line 19
def store_path
@store_path
end
|
Instance Method Details
118
119
120
|
# File 'lib/app_permission_statistics/extracter.rb', line 118
def app_path
@app_path ||= Dir.glob(File.join(contents, 'Payload', '*.app')).first
end
|
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/app_permission_statistics/extracter.rb', line 122
def clear!
return unless @contents
FileUtils.rm_rf(@contents)
@contents = nil
@app_path = nil
@info_path = nil
@info = nil
@pre_version = nil
end
|
106
107
108
|
# File 'lib/app_permission_statistics/extracter.rb', line 106
def contents
@contents ||= unarchive(@file, path: 'ios')
end
|
#entitlements_path ⇒ Object
114
115
116
|
# File 'lib/app_permission_statistics/extracter.rb', line 114
def entitlements_path
@entitlements_path ||= File.join(app_path, 'Runner.entitlements')
end
|
#entitlementsInfo ⇒ Object
86
87
88
|
# File 'lib/app_permission_statistics/extracter.rb', line 86
def entitlementsInfo
@entitlementsInfo ||= EntitlementsPlist.new(entitlements_path)
end
|
67
68
69
70
71
72
73
74
|
# File 'lib/app_permission_statistics/extracter.rb', line 67
def
capabilities_info = {}
capabilities_info["In-App Purchase"] = true
capabilities_info = capabilities_info.merge(entitlementsInfo.enabled_capabilities)
capabilities_info = capabilities_info.merge(plistInfo.backgroundModes)
capabilities_info = capabilities_info.merge(plistInfo.enabled_capabilities)
capabilities_info
end
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/app_permission_statistics/extracter.rb', line 26
def
capabilities_summary = Hash.new
capabilities =
capabilities.each do |key,value|
capabilities_summary[key] = createsig(value)
end
usage_desc_summary = Hash.new
usage_desc = plistInfo.permis_usagedescription
usage_desc.each do |key,value|
usage_desc_summary[key] = createsig(value)
end
yaml_content = {
'Capabilities_Summary' => capabilities_summary,
'Capabilities' => capabilities,
'PermissionsUsageDescription_Summary' => usage_desc_summary,
'PermissionsUsageDescription' => usage_desc
}
yaml_name = entitlements_yaml_name(plistInfo.version, plistInfo.identifier, path: @store_path)
File.open(yaml_name, "w") { |file| file.write(yaml_content.to_yaml) }
update_versions
yaml_content
end
|
#info_path ⇒ Object
110
111
112
|
# File 'lib/app_permission_statistics/extracter.rb', line 110
def info_path
@info_path ||= File.join(app_path, 'Info.plist')
end
|
#mobileprovision ⇒ Object
76
77
78
79
80
|
# File 'lib/app_permission_statistics/extracter.rb', line 76
def mobileprovision
return unless mobileprovision?
return @mobileprovision if @mobileprovision
@mobileprovision = MobileProvision.new(mobileprovision_path)
end
|
#mobileprovision? ⇒ Boolean
91
92
93
|
# File 'lib/app_permission_statistics/extracter.rb', line 91
def mobileprovision?
File.exist?(mobileprovision_path)
end
|
#mobileprovision_path ⇒ Object
95
96
97
98
99
100
101
102
103
|
# File 'lib/app_permission_statistics/extracter.rb', line 95
def mobileprovision_path
filename = 'embedded.mobileprovision'
@mobileprovision_path ||= File.join(@file, filename)
unless File.exist?(@mobileprovision_path)
@mobileprovision_path = File.join(app_path, filename)
end
@mobileprovision_path
end
|
#plistInfo ⇒ Object
82
83
84
|
# File 'lib/app_permission_statistics/extracter.rb', line 82
def plistInfo
@plistInfo ||= InfoPlist.new(info_path)
end
|
#update_versions ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/app_permission_statistics/extracter.rb', line 53
def update_versions
yaml_name = versions_yaml_name(plistInfo.identifier, path: @store_path)
yaml_content = [ ]
if File.exist?(yaml_name)
yaml_content = YAML.load_file(yaml_name)
end
version = plistInfo.version
if !yaml_content.include?(version)
yaml_content.push(version)
yaml_content.sort{|x,y| y<=>x } unless yaml_content.size < 2
File.open(yaml_name, "w") { |file| file.write(yaml_content.to_yaml) }
end
end
|