cocoapods-scancode 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-scancode/gem_version.rb +1 -1
- data/lib/cocoapods-scancode/trig.rb +96 -91
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2960636db8b9cceecd82e9b14a465c993735de73fe31a7858e310b173867731b
|
4
|
+
data.tar.gz: b1d06f1d9e703dba070940b5b70878748e723095f2cf143b777724c05b79903b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 735eda5bd69e5bc0b89500a35b5cf8f1b46a5b1253fe7835f4e60259e5ba7109809585c7b1a59dcfbfb80c9c0349b06606fe5878b6d8bf360d0ffc063b3588f2
|
7
|
+
data.tar.gz: 30f5c4ff49ffa6336f740e5095243cbc7e5250dd9b8e660d08caaf3177f0c4261883f86e873458c623a025d3f0c18dfdb24d8820068b9ffde0030f6ca410ceeb
|
@@ -63,7 +63,8 @@ class LocalizedScan
|
|
63
63
|
break
|
64
64
|
end
|
65
65
|
end
|
66
|
-
puts bundPath
|
66
|
+
puts "\e[34m app里所有模块的多语言都在这里#{bundPath}\e[0m"
|
67
|
+
|
67
68
|
Find.find(bundPath) do |filePath|
|
68
69
|
if filePath.end_with?("Localizable.strings")
|
69
70
|
self.findKey(filePath)
|
@@ -105,122 +106,126 @@ class LocalizedScan
|
|
105
106
|
end
|
106
107
|
|
107
108
|
def self.scan
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
elsif fileName.end_with?".swift"
|
114
|
-
self.scanKeyInSwiftCode(fileName)
|
115
|
-
end
|
109
|
+
Find.find ("./") do |fileName|
|
110
|
+
if fileName.end_with?(".m") or fileName.end_with?(".swift")
|
111
|
+
self.scanKeyInOcCode(fileName,:endWithSwift=> fileName.end_with?(".swift"))
|
112
|
+
end
|
113
|
+
end
|
116
114
|
end
|
117
|
-
end
|
118
115
|
|
119
|
-
|
116
|
+
def self.scanKeyInOcCode(path=nil,endWithSwift:false)
|
120
117
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
118
|
+
file = File.open(path,"r:utf-8") do |file|
|
119
|
+
block = ""
|
120
|
+
file.each_line do |line|
|
121
|
+
block += line
|
122
|
+
if line.end_with?(endWithSwift ? "\n":";\n")
|
123
|
+
#处理block
|
124
|
+
self.filterKeyInBLock(block,path)
|
125
|
+
block = ""
|
126
|
+
end
|
129
127
|
end
|
130
128
|
end
|
129
|
+
file.close
|
130
|
+
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
|
+
def self.filterKeyInBLock(block,filePath)
|
133
134
|
|
134
|
-
|
135
|
+
#localizedString(forKey: "common_guide_board_edit1" .swift
|
136
|
+
# localizedStringForKey : @ "home_switch_position" comment:@"切换家庭" .m
|
137
|
+
block.scan(/localizedString\(?forkey\s*:\s*@?\s*"(.+?)",?\s*comment/im) do |matched|
|
138
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
139
|
+
# p matched[0] +":" + filePath
|
140
|
+
end
|
141
|
+
# swift:LMBundleNSLocalizedString("abc", "测试")
|
142
|
+
# oc : LMBundleNSLocalizedString(@"voice_guide_title", @"Hi,我是小乔")
|
143
|
+
block.scan(/LMBundleNSLocalizedString\s*\(\s*@?\s*"(.+?)",\s*/im) do |matched|
|
144
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
145
|
+
end
|
135
146
|
|
136
|
-
|
137
|
-
|
138
|
-
file = File.open(path,"r:utf-8") do |file|
|
139
|
-
block = ""
|
140
|
-
file.each_line do |line|
|
141
|
-
block += line
|
142
|
-
if line.end_with?"\n"
|
143
|
-
#处理block
|
144
|
-
self.filterKeyInSwiftBLock(block,path)
|
145
|
-
block = ""
|
147
|
+
block.scan(/LMCALanuage\(\s*@\s*?"(.*?)"\s*,/im) do |matched|
|
148
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
146
149
|
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
file.close
|
150
150
|
|
151
|
-
|
152
|
-
|
153
|
-
def self.filterKeyInSwiftBLock(block,filePath)
|
154
|
-
keywords = ['LMBundleNSLocalizedString(','LHLocalizedTool.localizedString(forKey:']
|
155
|
-
keywords.each do |keyword|
|
156
|
-
tempBlock = block
|
157
|
-
while tempBlock.index(keyword) != nil do
|
158
|
-
#左引号
|
159
|
-
left = tempBlock.index(keyword)
|
160
|
-
# puts left
|
161
|
-
# puts tempBlock[left]
|
162
|
-
left = tempBlock.index('"',left+1)
|
163
|
-
right = tempBlock.index('"',left+1)
|
164
|
-
# puts right
|
165
|
-
# puts tempBlock[right]
|
166
|
-
key = tempBlock[left+1...right]
|
167
|
-
if @@defineKeyDic[key] == nil
|
168
|
-
print 'swift未定义的key:',key,"\n"
|
169
|
-
item = UnDefineKeyItem.new(key,filePath)
|
170
|
-
@@undefineKeyDic[key] = item
|
151
|
+
block.scan(/LMCTLanuage\(\s*@\s*?"(.*?)"\s*,/im) do |matched|
|
152
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
171
153
|
end
|
172
|
-
|
173
|
-
|
154
|
+
|
155
|
+
block.scan(/LMIrcodeLocalizedString\(\s*@\s*?"(.*?)"\s*,/im) do |matched|
|
156
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
157
|
+
|
158
|
+
# p matched[0] +":" + filePath
|
159
|
+
end
|
160
|
+
|
161
|
+
block.scan(/LMLTLanuage\(\s*@\s*?"(.*?)"\s*,/im) do |matched|
|
162
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
163
|
+
|
164
|
+
# p matched[0] +":" + filePath
|
165
|
+
end
|
166
|
+
|
167
|
+
block.scan(/kLMPositionFrameworkNSLocalized\(\s*@\s*?"(.*?)"\s*,/im) do |matched|
|
168
|
+
self.checkKey(:key=>matched[0],:filePath=>filePath)
|
169
|
+
# p matched[0] +":" + filePath
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.checkKey(key:nil,filePath:"")
|
175
|
+
if @@defineKeyDic[key] == nil
|
176
|
+
# print '未定义的key:',key,"\n"
|
177
|
+
item = UnDefineKeyItem.new(key,filePath)
|
178
|
+
@@undefineKeyDic[key] = item
|
174
179
|
end
|
175
180
|
end
|
176
181
|
|
177
|
-
def self.
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
left = tempBlock.index(keyword) + keyword.length-1
|
190
|
-
# puts left
|
191
|
-
# puts tempBlock[left]
|
192
|
-
right = tempBlock.index('"',left+1)
|
193
|
-
# puts right
|
194
|
-
# puts tempBlock[right]
|
195
|
-
key = tempBlock[left+1...right]
|
196
|
-
#
|
197
|
-
if @@defineKeyDic[key] == nil
|
198
|
-
# print '未定义的key:',key,"\n"
|
199
|
-
item = UnDefineKeyItem.new(key,filePath)
|
200
|
-
@@undefineKeyDic[key] = item
|
182
|
+
def self.printUndefineKey
|
183
|
+
resultHas = {}
|
184
|
+
@@undefineKeyDic.each_value do |item|
|
185
|
+
path_list =item.printFilePath.split("/")
|
186
|
+
if path_list[1] == "Pods"
|
187
|
+
module_name = path_list[2]
|
188
|
+
if resultHas.has_key? module_name
|
189
|
+
list = resultHas[module_name]
|
190
|
+
list << item
|
191
|
+
else
|
192
|
+
list = [item]
|
193
|
+
resultHas[module_name] = list
|
201
194
|
end
|
202
|
-
|
195
|
+
else
|
196
|
+
module_name = path_list[1]
|
197
|
+
if resultHas.has_key? module_name
|
198
|
+
list = resultHas[module_name]
|
199
|
+
list << item
|
200
|
+
else
|
201
|
+
list = [item]
|
202
|
+
resultHas[module_name] = list
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
resultHas.each do |module_name,list|
|
207
|
+
puts "\e[32m 模块名称:#{module_name}\e[0m"
|
208
|
+
list.each_with_index do |item,index|
|
209
|
+
print "#{index+1}"
|
210
|
+
puts "\e[31m #{item.printKey}\e[0m"
|
211
|
+
puts " 文件路径:#{item.printFilePath}"
|
203
212
|
end
|
204
213
|
end
|
214
|
+
puts "\e[32m 未识别key总数:#{@@undefineKeyDic.values.size}\e[0m"
|
205
215
|
end
|
206
216
|
|
207
217
|
def self.pipLine
|
208
218
|
self.loadBundleKey
|
209
219
|
self.scan
|
210
|
-
|
211
|
-
# puts model
|
212
|
-
# end
|
213
|
-
|
214
|
-
num = 0
|
215
|
-
@@undefineKeyDic.each_value do |item|
|
216
|
-
num += 1
|
217
|
-
puts "#{num}:#{item.printKey} filepath:#{item.printFilePath}"
|
218
|
-
end
|
220
|
+
self.printUndefineKey
|
219
221
|
end
|
222
|
+
# def make_color(str, color)
|
223
|
+
# colors = {:red => 31, :green => 32, :blue => 34}
|
224
|
+
# puts "\e[#{colors[color]}m #{str}\e[0m"
|
225
|
+
# end
|
220
226
|
|
221
227
|
end
|
222
228
|
|
223
|
-
|
224
229
|
# str = 'localizedStringForKey:@"key"'
|
225
230
|
# LocalizedScan.filterKeyInBLock(str)
|
226
231
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-scancode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeremylu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/cocoapods-scancode/gem_version.rb
|
52
52
|
- lib/cocoapods-scancode/trig.rb
|
53
53
|
- lib/cocoapods_plugin.rb
|
54
|
-
homepage: https://github.com/
|
54
|
+
homepage: https://github.com/cherishandjay/scancode
|
55
55
|
licenses:
|
56
56
|
- MIT
|
57
57
|
metadata: {}
|