10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/itools/podfile_tiled.rb', line 10
def self.podfile_tiled(args)
all_pods = [] exist_pods = [] need_add_pods = [] pod_tag = 1
fileInfo = File.open(args[0])
total_index = 0
fileInfo.each_line do |line|
line_string = line.delete("\n")
if line_string == 'PODS:'
puts "\033[32m开始分析依赖\033[0m"
pod_tag = 1
next
elsif line_string == 'DEPENDENCIES:'
puts "\033[32m开始分析当前Podfile中已添加的依赖项\033[0m"
pod_tag = 2
next
elsif line_string == 'SPEC REPOS:'
pod_tag = 0
puts "\033[32mpodfile.lock分析结束\033[0m"
end
if pod_tag == 1 if line_string[0, 3] == ' -' && !line_string.include?('/')
pod_version = line_string[/\((.*?)\)/, 1]
pod_name =
line_string.gsub(pod_version, '').delete('(').delete(')').delete(
':'
).delete('-').strip
temp_pod = PodInfo.new(pod_name, pod_version)
all_pods << temp_pod
puts "查找到pod库:#{pod_name}, 版本号为:'#{pod_version}' #{all_pods.length}"
end
end
if pod_tag == 2 pod_name
pod_version = line_string[/\((.*?)\)/, 1]
if pod_version
pod_name =
line_string.gsub(pod_version, '').delete('(').delete(')').delete(
':'
).delete('-').strip
else
pod_name = line_string.delete('-').lstrip.rstrip
end
temp_pod = PodInfo.new(pod_name, pod_version)
if pod_version
temp_pod.pod_version = pod_version.delete('=').strip
end
exist_pods << temp_pod
puts "Podfile中已包含 #{pod_name}, 版本号为:'#{pod_version}'"
end
end
temp_exist_pods = []
all_pods.each do |all_pod|
exist_pods.each do |exist_pod|
exist_pod_name = exist_pod.pod_name
if exist_pod_name.include?('/')
exist_pod_name = exist_pod_name.split('/')[0]
end
if all_pod.pod_name == exist_pod_name
temp_exist_pods << all_pod
end
end
end
need_add_pods = all_pods - temp_exist_pods
if need_add_pods.length == 0
puts "\033[32m恭喜!!!无需平铺,当前已全部平铺\033[0m"
else
puts "\033[32m以下为要平铺的库,直接复制粘贴至Podfile中即可:\033[0m"
need_add_pods.each do |to_add|
puts "pod '#{to_add.pod_name}', '#{to_add.pod_version}'"
end
end
end
|