cocoapods-privacy 0.1.2 → 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: b1138888b85b8d2e4eb857fc7bb3d86f305f8a414b79702a9e898da0c351b7f8
4
- data.tar.gz: e47d7800f08af2b3464f5dcf7cfb77c8e46961d2198acb4e12390df3eeff6df0
3
+ metadata.gz: 3a01926feebe0e4abec4ba740c40045150fa16eadbde2286bbe9bfeedaa6594d
4
+ data.tar.gz: 43e885178765e82aef94d3b2e0a115fc807c410b389b6c6752ac673dd45de73f
5
5
  SHA512:
6
- metadata.gz: e3d5745b2c7c7eaa6cdffe1e9f11a6d6720a8b2fd56d6a7195b6176a99467f2462e5f3e4233d695148ebe38ef07f74ab92525f318bf930bf9dc806f0ba4dfedb
7
- data.tar.gz: 0caa4e0cfe57beadfdbf979bfe9712997e5b9d5193216204ee5eef51292d8d1638522d5f2bb892e978007fda675918cc0aff28688bc26a72fe0bfa55640904ee
6
+ metadata.gz: 625ebb584fe2db868894a19e7fe8bff1cbf817d3b1026418afaf48588d3ee5ae2bd81bb1c4d265bf03e8a28ffd61b73fceda1457c2c120315b2cb70be0c072d0
7
+ data.tar.gz: e9fc5727cafed29d6afbbd6a9c0f9dd964e1871125215e191103ad7e80342c0ddd2ca0068c213be272c70bedf7e99bf58442545c0b739263f4814607051a22e6
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPrivacy
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - youhui