cocoapods-aomi-bin 0.1.7 → 0.1.8
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d60564dc2567c05414925657a0bfcc79c03e29346af7799a236e824a48b522b
|
4
|
+
data.tar.gz: c58a951a5261bd33adff5d05e133385a3cc225059b103769a0fb8af333072917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a21bb3fff848840bf1a72671bfc09fadec1dbf67c2103a1958a897065f6fd3d2f69332715bc0afe2e64ed4fc39f2ae3490a3a5b8c3e9eb4df155bf718b522c85
|
7
|
+
data.tar.gz: 352d771b8a7731af97c00ac7f83753178f2a8d7bbab02d188d1e4f45f31246f8cb523e2b6d26167034a6766eae96a2ce83b8b95675d37a443cf8c7304898dd48
|
@@ -20,12 +20,14 @@ module Pod
|
|
20
20
|
@file_type = argv.option('file-type', 'm,h')
|
21
21
|
@file_name = argv.option('file-name', 'gen_cn_key.csv')
|
22
22
|
@cn_keys = []
|
23
|
+
@key_map = {}
|
23
24
|
super
|
24
25
|
end
|
25
26
|
|
26
27
|
def run
|
27
28
|
handle_files
|
28
29
|
gen_csv
|
30
|
+
# update_source_header
|
29
31
|
end
|
30
32
|
|
31
33
|
def csv_file_name
|
@@ -38,9 +40,9 @@ module Pod
|
|
38
40
|
file = File.join(@current_path, csv_file_name)
|
39
41
|
FileUtils.rm_rf(file) if File.exist?(file)
|
40
42
|
CSV.open(file, 'wb:utf-8') do |csv|
|
41
|
-
csv << %w[国际化key 中文 英文
|
43
|
+
csv << %w[国际化key 中文 英文 所在文件 文件路径]
|
42
44
|
@cn_keys.each do |k|
|
43
|
-
csv << [k[:key], k[:cn], k[:en], k[:
|
45
|
+
csv << [k[:key], k[:cn], k[:en], k[:fname], k[:dirname]]
|
44
46
|
end
|
45
47
|
end
|
46
48
|
UI.puts "生成csv文件完成.\n文件路径:#{File.absolute_path(file)}".green
|
@@ -66,11 +68,79 @@ module Pod
|
|
66
68
|
|
67
69
|
def handle_line(file, line)
|
68
70
|
line.scan(zh_ch_reg) do |str|
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
fname = File.basename(file)
|
72
|
+
dir_name = File.dirname(file)
|
73
|
+
mod_name = framework_name(dir_name)
|
74
|
+
key = "#{mod_name}.#{File.basename(file, '.*')}.#{rand(36**8).to_s(36)}"
|
75
|
+
cn_str = str[2, str.length - 3]
|
76
|
+
en_str = cn_str.gsub(/[\u4e00-\u9fa5]/, 'x')
|
77
|
+
@cn_keys << { key: key, cn: cn_str, en: en_str, fname: fname, dirname: dir_name }
|
72
78
|
end
|
73
79
|
end
|
80
|
+
|
81
|
+
def framework_name(path)
|
82
|
+
mod_name = 'Main'
|
83
|
+
if /pods/i =~ path
|
84
|
+
ary = path.split('/')
|
85
|
+
index = ary.find_index { |p| p.eql?('Pods') }
|
86
|
+
if index
|
87
|
+
i = index + 1
|
88
|
+
mod_name = ary[i]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
mod_name
|
92
|
+
end
|
93
|
+
|
94
|
+
def handle_static_line(file, line)
|
95
|
+
line.scan(zh_ch_reg) do |str|
|
96
|
+
ma = line.match(/\*.*=/)
|
97
|
+
key = ma[0][1, ma[0].length - 2].strip
|
98
|
+
@key_map[key.to_sym] = str
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def update_source_header
|
103
|
+
Dir.glob("#{@current_path}/**/*.{m,h}").each do |f|
|
104
|
+
if f =~ /Pods/
|
105
|
+
handler_file(f) if f =~ %r{Pods/MLF} || f =~ %r{Pods/MLU} || f =~ %r{Pods/MLN}
|
106
|
+
else
|
107
|
+
handler_file(f)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def handler_file(file)
|
113
|
+
puts "#{File.absolute_path(file)} \n"
|
114
|
+
File.chmod(0o644, file)
|
115
|
+
str = file_string(file)
|
116
|
+
File.open(file, 'w+') do |f|
|
117
|
+
f.write(str)
|
118
|
+
end
|
119
|
+
File.chmod(0o444, file) if file =~ /Pods/
|
120
|
+
end
|
121
|
+
|
122
|
+
def file_string(file)
|
123
|
+
str = ''
|
124
|
+
File.open(file, 'r+') do |f|
|
125
|
+
f.each_line do |line|
|
126
|
+
str += format_string(f, line)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
str
|
130
|
+
end
|
131
|
+
|
132
|
+
def format_string(file, line)
|
133
|
+
result = line
|
134
|
+
unless /static/ =~ line
|
135
|
+
@key_map.each_key do |key|
|
136
|
+
n_key = /#{key.to_s}\s/
|
137
|
+
n_val = "#{@key_map[key]}\s"
|
138
|
+
result = result.gsub(n_key, n_val)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
result
|
142
|
+
end
|
143
|
+
|
74
144
|
end
|
75
145
|
end
|
76
146
|
end
|
@@ -126,16 +126,23 @@ module Pod
|
|
126
126
|
def handle_modify_source
|
127
127
|
UI.puts '修改源码开始'
|
128
128
|
Dir.glob("#{@current_path}/**/*.{#{@modify_file_type}}").each do |f|
|
129
|
-
handle_modify_file f if File.stat(f).writable?
|
129
|
+
# handle_modify_file f if File.stat(f).writable?
|
130
|
+
if f =~ /Pods/
|
131
|
+
handle_modify_file(f) if f =~ %r{Pods/ML}
|
132
|
+
else
|
133
|
+
handle_modify_file(f)
|
134
|
+
end
|
130
135
|
end
|
131
136
|
UI.puts '修改源码结束'
|
132
137
|
end
|
133
138
|
|
134
139
|
def handle_modify_file(file)
|
140
|
+
File.chmod(0o644, file)
|
135
141
|
str = modify_file_string(file)
|
136
142
|
File.open(file, 'w+') do |f|
|
137
143
|
f.write(str)
|
138
144
|
end
|
145
|
+
File.chmod(0o444, file) if file =~ /Pods/
|
139
146
|
end
|
140
147
|
|
141
148
|
def modify_file_string(file)
|
@@ -173,8 +180,8 @@ module Pod
|
|
173
180
|
def find_key_by_cn_val(file, val)
|
174
181
|
file_name = File.basename(file, '.*')
|
175
182
|
cn_key = val[2, val.length - 3]
|
176
|
-
index = @key_map.values.find_index { |obj|
|
177
|
-
index ||= @key_map.values.find_index { |obj|
|
183
|
+
index = @key_map.values.find_index { |obj| cn_key.eql?(obj[:zh]) && /#{file_name}/ =~ obj[:key] }
|
184
|
+
index ||= @key_map.values.find_index { |obj| cn_key.eql?(obj[:zh]) }
|
178
185
|
@key_map.values[index][:key] if index
|
179
186
|
end
|
180
187
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-aomi-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|