cocoapods-privacy 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad82b3ef0ee76d32a2323649deca0e0aade7ac3ce2b4833917b22e99bd4f2842
4
- data.tar.gz: 5907b1321ca9eb9d496335743bff10cb49e666250eabc829e06c7728cb58b2b3
3
+ metadata.gz: 3a01926feebe0e4abec4ba740c40045150fa16eadbde2286bbe9bfeedaa6594d
4
+ data.tar.gz: 43e885178765e82aef94d3b2e0a115fc807c410b389b6c6752ac673dd45de73f
5
5
  SHA512:
6
- metadata.gz: 499e6b195d45c6c87e8717cc0e84e670b8466ca8e8602170dee521af9bcf536a9fd8bc387a2f5097857de43eeb5fe73860030b45431578e629738fa1449af931
7
- data.tar.gz: d6f72bc25b077147fa7e12489a45ca95401a9d9bef3f40efb7cf04feca3e488f94622fc531115a6b710dd31ef6154f947b37bdf85236024c5371dc7da666bd6d
6
+ metadata.gz: 625ebb584fe2db868894a19e7fe8bff1cbf817d3b1026418afaf48588d3ee5ae2bd81bb1c4d265bf03e8a28ffd61b73fceda1457c2c120315b2cb70be0c072d0
7
+ data.tar.gz: e9fc5727cafed29d6afbbd6a9c0f9dd964e1871125215e191103ad7e80342c0ddd2ca0068c213be272c70bedf7e99bf58442545c0b739263f4814607051a22e6
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPrivacy
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -8,6 +8,7 @@ require 'cocoapods-privacy/command'
8
8
  # 3、检索到的内容转换成隐私协议格式写入 隐私清单文件 PrivacyInfo.xcprivacy
9
9
  ##
10
10
  module PrivacyHunter
11
+
11
12
  KTypes = "NSPrivacyAccessedAPITypes"
12
13
  KType = "NSPrivacyAccessedAPIType"
13
14
  KReasons = "NSPrivacyAccessedAPITypeReasons"
@@ -103,12 +104,12 @@ module PrivacyHunter
103
104
  def self.fetch_template_plist_file
104
105
 
105
106
  unless File.exist?(PrivacyUtils.cache_config_file)
106
- raise Informative, "无配置文件,run `pod privacy config config_file' 进行配置"
107
+ raise Pod::Informative, "无配置文件,run `pod privacy config config_file' 进行配置"
107
108
  end
108
109
 
109
110
  template_url = Privacy::Config.instance.api_template_url
110
111
  unless template_url && !template_url.empty?
111
- raise Informative, "配置文件中无 `api.template.url` 配置,请补全后再更新配置 `pod privacy config config_file` "
112
+ raise Pod::Informative, "配置文件中无 `api.template.url` 配置,请补全后再更新配置 `pod privacy config config_file` "
112
113
  end
113
114
 
114
115
  # 目标文件路径
@@ -29,7 +29,7 @@ class BBRow
29
29
  end
30
30
 
31
31
  class BBSpec
32
- attr_accessor :name, :alias_name, :full_name, :rows, :privacy_sources, :privacy_file
32
+ attr_accessor :name, :alias_name, :full_name, :parent, :rows, :privacy_sources, :privacy_file
33
33
 
34
34
  def initialize(name,alias_name,full_name)
35
35
  @rows = []
@@ -40,6 +40,23 @@ class BBSpec
40
40
  @privacy_file = "Pod/Privacy/#{full_name}/PrivacyInfo.xcprivacy"
41
41
  end
42
42
 
43
+
44
+ def uniq_full_name_in_parent(name)
45
+ names = []
46
+ @rows.each_with_index do |line, index|
47
+ if line && line.is_a?(BBSpec)
48
+ names << line.name
49
+ end
50
+ end
51
+
52
+ #判断names 中是否包含 name,如果包含,那么给name 添加一个 “.diff” 后缀,一直到names 中没有包含name为止
53
+ while names.include?(name)
54
+ name = "#{name}.diff"
55
+ end
56
+
57
+ "#{@full_name}.#{name}"
58
+ end
59
+
43
60
  def privacy_handle(podspec_file_path)
44
61
  source_files_index = 1
45
62
  @rows.each_with_index do |line, index|
@@ -196,17 +213,23 @@ module PrivacyModule
196
213
 
197
214
  def self.parse_row(lines)
198
215
  rows = []
199
- if_stack = [] #排除if end 干扰
216
+ code_stack = [] #栈,用来排除if end 等对spec 的干扰
217
+
200
218
  lines.each do |line|
201
219
  content = line.strip
202
220
  is_comment = content.start_with?('#')
203
221
  is_spec_start = !is_comment && (content.include?('Pod::Spec.new') || content.include?('.subspec'))
204
222
  is_if = !is_comment && content.start_with?('if')
205
223
  is_end = !is_comment && content.start_with?('end')
224
+
206
225
  # 排除if end 对spec_end 的干扰
207
- if_stack.push(true) if is_if
208
- is_spec_end = if_stack.empty? && is_end
209
- if_stack.pop if is_end
226
+ code_stack.push('spec') if is_spec_start
227
+ code_stack.push('if') if is_if
228
+ stack_last = code_stack.last
229
+ is_spec_end = is_end && stack_last && stack_last == 'spec'
230
+ is_if_end = is_end && stack_last && stack_last == 'if'
231
+ code_stack.pop if is_spec_end || is_if_end
232
+
210
233
  row = BBRow.new(line, is_comment, is_spec_start, is_spec_end)
211
234
  rows << row
212
235
  end
@@ -236,15 +259,20 @@ module PrivacyModule
236
259
 
237
260
  rows.each do |row|
238
261
  if row.is_spec_start
262
+ # 获取父spec
263
+ parent_spec = spec_stack.last
264
+
239
265
  # 创建 spec
240
266
  name = row.content.split("'")[1]&.strip || default_name
241
267
  alias_name = row.content.split("|")[1]&.strip
242
- full_name = spec_stack.empty? ? name : "#{spec_stack.last.full_name}.#{name}"
268
+ full_name = parent_spec ? parent_spec.uniq_full_name_in_parent(name) : name
269
+
243
270
  spec = BBSpec.new(name,alias_name,full_name)
244
271
  spec.rows << row
272
+ spec.parent = parent_spec
245
273
 
246
274
  # 当存在 spec 时,存储在 spec.rows 中;不存在时,直接存储在外层
247
- (spec_stack.empty? ? result_rows : spec_stack.last.rows) << spec
275
+ (parent_spec ? parent_spec.rows : result_rows ) << spec
248
276
 
249
277
  # spec 入栈
250
278
  spec_stack.push(spec)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - youhui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-31 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler