cocoapods-privacy 0.1.2 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06cfd0105293d04c3f940b48b2a591daa1c361ddceeca67e4c19263984b5e5dd
|
4
|
+
data.tar.gz: bdbba9767ad2127bee8fbbbac60bd2b06adcd3471d29899f6f2a829582f68f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc73b9f26811740f419e0519e34f765ee596e9bb52c17c8767866867d078d697c509a17cf0ee111a4ec8db755550d32b4fda4920cb67bcea3a747c48c218e0fa
|
7
|
+
data.tar.gz: 2142d38a2e33517f88c44b2108c5db12adc40467b95b4135a30692c28cad5c71a81c37b0f5ff34b8b1cfb74823785c4f64b5a8d86960fab385788f77f5ecde93
|
@@ -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|
|
@@ -137,7 +154,9 @@ module PrivacyModule
|
|
137
154
|
|
138
155
|
# 如果不存在引用,创建新的引入xcode引用
|
139
156
|
if resources_group.find_file_by_path(PrivacyUtils.privacy_name).nil?
|
140
|
-
resources_group.new_reference(PrivacyUtils.privacy_name)
|
157
|
+
privacy_file_ref = resources_group.new_reference(PrivacyUtils.privacy_name)
|
158
|
+
target = project.targets.first
|
159
|
+
target.add_file_references([privacy_file_ref]) # 将文件引用添加到 target 中
|
141
160
|
# resources_group.new_file(privacy_file_path)
|
142
161
|
end
|
143
162
|
|
@@ -196,17 +215,23 @@ module PrivacyModule
|
|
196
215
|
|
197
216
|
def self.parse_row(lines)
|
198
217
|
rows = []
|
199
|
-
|
218
|
+
code_stack = [] #栈,用来排除if end 等对spec 的干扰
|
219
|
+
|
200
220
|
lines.each do |line|
|
201
221
|
content = line.strip
|
202
222
|
is_comment = content.start_with?('#')
|
203
223
|
is_spec_start = !is_comment && (content.include?('Pod::Spec.new') || content.include?('.subspec'))
|
204
224
|
is_if = !is_comment && content.start_with?('if')
|
205
225
|
is_end = !is_comment && content.start_with?('end')
|
226
|
+
|
206
227
|
# 排除if end 对spec_end 的干扰
|
207
|
-
|
208
|
-
|
209
|
-
|
228
|
+
code_stack.push('spec') if is_spec_start
|
229
|
+
code_stack.push('if') if is_if
|
230
|
+
stack_last = code_stack.last
|
231
|
+
is_spec_end = is_end && stack_last && stack_last == 'spec'
|
232
|
+
is_if_end = is_end && stack_last && stack_last == 'if'
|
233
|
+
code_stack.pop if is_spec_end || is_if_end
|
234
|
+
|
210
235
|
row = BBRow.new(line, is_comment, is_spec_start, is_spec_end)
|
211
236
|
rows << row
|
212
237
|
end
|
@@ -236,15 +261,20 @@ module PrivacyModule
|
|
236
261
|
|
237
262
|
rows.each do |row|
|
238
263
|
if row.is_spec_start
|
264
|
+
# 获取父spec
|
265
|
+
parent_spec = spec_stack.last
|
266
|
+
|
239
267
|
# 创建 spec
|
240
268
|
name = row.content.split("'")[1]&.strip || default_name
|
241
269
|
alias_name = row.content.split("|")[1]&.strip
|
242
|
-
full_name =
|
270
|
+
full_name = parent_spec ? parent_spec.uniq_full_name_in_parent(name) : name
|
271
|
+
|
243
272
|
spec = BBSpec.new(name,alias_name,full_name)
|
244
273
|
spec.rows << row
|
274
|
+
spec.parent = parent_spec
|
245
275
|
|
246
276
|
# 当存在 spec 时,存储在 spec.rows 中;不存在时,直接存储在外层
|
247
|
-
(
|
277
|
+
(parent_spec ? parent_spec.rows : result_rows ) << spec
|
248
278
|
|
249
279
|
# spec 入栈
|
250
280
|
spec_stack.push(spec)
|