cocoapods-aomi-bin 0.1.6 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-lhj-bin/command/bin.rb +2 -0
- data/lib/cocoapods-lhj-bin/command/bin/init.rb +7 -3
- data/lib/cocoapods-lhj-bin/command/bin/local/fetch.rb +90 -10
- data/lib/cocoapods-lhj-bin/command/bin/local/filter.rb +85 -0
- data/lib/cocoapods-lhj-bin/command/bin/local/local.rb +65 -25
- data/lib/cocoapods-lhj-bin/command/bin/local/micro_service.rb +90 -0
- data/lib/cocoapods-lhj-bin/config/local_config.rb +52 -0
- data/lib/cocoapods-lhj-bin/gem_version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8581691289d5161199dd5f1169a37499e00d3dbe2f1197599f77ebd1724ad80d
|
4
|
+
data.tar.gz: cd27e27a2df116550292744b2f4797d4fe5218f3059373c173653f6aab771163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aca5282ce3545156241bc926bae0f4da242ea36140f19fbc01494c55d39d8c69a7c56928f3f4b26132b693208fcf945aac62827830e0020761a3bf03f08c1c2f
|
7
|
+
data.tar.gz: 6efcbd3de94086bc98d9bf98466ccfd5c92cdfe510db59c025a84b4c4d0db7f2608d08b0f527fa8b4d1e55ffd448c6af0c0f499e0389e76ecfff088c479cc2e1
|
@@ -8,6 +8,8 @@ require 'cocoapods-lhj-bin/command/bin/install'
|
|
8
8
|
require 'cocoapods-lhj-bin/command/bin/import'
|
9
9
|
require 'cocoapods-lhj-bin/command/bin/local/local'
|
10
10
|
require 'cocoapods-lhj-bin/command/bin/local/fetch'
|
11
|
+
require 'cocoapods-lhj-bin/command/bin/local/filter'
|
12
|
+
require 'cocoapods-lhj-bin/command/bin/local/micro_service'
|
11
13
|
require 'cocoapods-lhj-bin/command/bin/local/upload'
|
12
14
|
require 'cocoapods-lhj-bin/command/bin/trans'
|
13
15
|
require 'cocoapods-lhj-bin/command/bin/lhj'
|
@@ -35,9 +35,13 @@ module Pod
|
|
35
35
|
require 'open-uri'
|
36
36
|
|
37
37
|
UI.puts "开始下载配置文件...\n"
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
str = ''
|
39
|
+
URI.open(url) do |f|
|
40
|
+
f.each_line do |line|
|
41
|
+
str += line
|
42
|
+
end
|
43
|
+
end
|
44
|
+
contents = YAML.safe_load(str)
|
41
45
|
UI.puts "开始同步配置文件...\n"
|
42
46
|
CBin.config.sync_config(contents.to_hash)
|
43
47
|
UI.puts "设置完成.\n".green
|
@@ -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
|
@@ -48,25 +50,103 @@ module Pod
|
|
48
50
|
|
49
51
|
def handle_files
|
50
52
|
Dir.glob("#{@current_path}/**/*.{#{@file_type}}").each do |f|
|
51
|
-
|
53
|
+
dir_name = File.dirname(f)
|
54
|
+
if /Pods/ =~ f
|
55
|
+
mod_name = framework_name(dir_name)
|
56
|
+
handle_file f if /^ML/ =~ mod_name
|
57
|
+
else
|
58
|
+
handle_file f
|
59
|
+
end
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
63
|
+
def zh_ch_reg
|
64
|
+
/@"[^"]*[\u4e00-\u9fa5]+[^"]*"/
|
65
|
+
end
|
66
|
+
|
55
67
|
def handle_file(file)
|
56
68
|
File.open(file, 'r') do |f|
|
57
69
|
f.each_line do |line|
|
58
|
-
handle_line(file, line) if line =~
|
70
|
+
handle_line(file, line) if zh_ch_reg =~ line && !((/DDLog/ =~ line) || (/NSLog/ =~ line))
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
62
74
|
|
63
75
|
def handle_line(file, line)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
76
|
+
line.scan(zh_ch_reg) do |str|
|
77
|
+
fname = File.basename(file)
|
78
|
+
dir_name = File.dirname(file)
|
79
|
+
mod_name = framework_name(dir_name)
|
80
|
+
key = "#{mod_name}.#{File.basename(file, '.*')}.#{rand(36**8).to_s(36)}"
|
81
|
+
cn_str = str[2, str.length - 3]
|
82
|
+
en_str = cn_str.gsub(/[\u4e00-\u9fa5]/, 'x')
|
83
|
+
@cn_keys << { key: key, cn: cn_str, en: en_str, fname: fname, dirname: dir_name }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def framework_name(path)
|
88
|
+
mod_name = 'Main'
|
89
|
+
if /pods/i =~ path
|
90
|
+
ary = path.split('/')
|
91
|
+
index = ary.find_index { |p| p.eql?('Pods') }
|
92
|
+
if index
|
93
|
+
i = index + 1
|
94
|
+
mod_name = ary[i]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
mod_name
|
98
|
+
end
|
99
|
+
|
100
|
+
def handle_static_line(file, line)
|
101
|
+
line.scan(zh_ch_reg) do |str|
|
102
|
+
ma = line.match(/\*.*=/)
|
103
|
+
key = ma[0][1, ma[0].length - 2].strip
|
104
|
+
@key_map[key.to_sym] = str
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def update_source_header
|
109
|
+
Dir.glob("#{@current_path}/**/*.{m,h}").each do |f|
|
110
|
+
if f =~ /Pods/
|
111
|
+
dir_name = File.dirname(f)
|
112
|
+
mod_name = framework_name(dir_name)
|
113
|
+
handle_file f if /^ML/ =~ mod_name
|
114
|
+
else
|
115
|
+
handler_file f
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def handler_file(file)
|
121
|
+
puts "#{File.absolute_path(file)} \n"
|
122
|
+
File.chmod(0o644, file)
|
123
|
+
str = file_string(file)
|
124
|
+
File.open(file, 'w+') do |f|
|
125
|
+
f.write(str)
|
126
|
+
end
|
127
|
+
File.chmod(0o444, file) if file =~ /Pods/
|
128
|
+
end
|
129
|
+
|
130
|
+
def file_string(file)
|
131
|
+
str = ''
|
132
|
+
File.open(file, 'r+') do |f|
|
133
|
+
f.each_line do |line|
|
134
|
+
str += format_string(f, line)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
str
|
138
|
+
end
|
139
|
+
|
140
|
+
def format_string(file, line)
|
141
|
+
result = line
|
142
|
+
unless /static/ =~ line
|
143
|
+
@key_map.each_key do |key|
|
144
|
+
n_key = /#{key.to_s}\s/
|
145
|
+
n_val = "#{@key_map[key]}\s"
|
146
|
+
result = result.gsub(n_key, n_val)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
result
|
70
150
|
end
|
71
151
|
end
|
72
152
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Bin < Command
|
8
|
+
class Filter < Bin
|
9
|
+
self.summary = '过滤重复对象'
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
@current_path = argv.shift_argument || Dir.pwd
|
13
|
+
@file_type = argv.option('file-type', 'm,h')
|
14
|
+
@file_name = argv.option('file-name', 'MaucaoLife_zh_en.csv')
|
15
|
+
@cn_keys = []
|
16
|
+
@key_map = {}
|
17
|
+
@used_keys = []
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
fetch_keys
|
23
|
+
read_csv
|
24
|
+
gen_csv
|
25
|
+
end
|
26
|
+
|
27
|
+
def csv_file_name
|
28
|
+
file_name = @file_name
|
29
|
+
file_name = "#{@file_name}.csv" unless /.csv$/ =~ @file_name
|
30
|
+
file_name
|
31
|
+
end
|
32
|
+
|
33
|
+
def read_csv
|
34
|
+
path = File.join(@current_path, csv_file_name)
|
35
|
+
Dir.glob(path).each do |p|
|
36
|
+
CSV.foreach(p) do |row|
|
37
|
+
key = row[0]
|
38
|
+
if @used_keys.any? { |k| k.eql?(key) }
|
39
|
+
@cn_keys << { key: key, cn: row[1], en: row[2], fname: row[3], dirname: row[4] }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def gen_csv
|
46
|
+
file = File.join(@current_path, csv_file_name)
|
47
|
+
FileUtils.rm_rf(file) if File.exist?(file)
|
48
|
+
CSV.open(file, 'wb:utf-8') do |csv|
|
49
|
+
csv << %w[国际化key 中文 英文 所在文件 文件路径]
|
50
|
+
@cn_keys.each do |k|
|
51
|
+
csv << [k[:key], k[:cn], k[:en], k[:fname], k[:dirname]]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
UI.puts "生成csv文件完成.\n文件路径:#{File.absolute_path(file)}".green
|
55
|
+
end
|
56
|
+
|
57
|
+
def fetch_keys
|
58
|
+
Dir.glob("#{@current_path}/**/*.{#{@file_type}}").each do |f|
|
59
|
+
handle_file f
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def zh_ch_reg
|
64
|
+
/MLLocalizedString\([^)]+\)/
|
65
|
+
end
|
66
|
+
|
67
|
+
def handle_file(file)
|
68
|
+
File.open(file, 'r') do |f|
|
69
|
+
f.each_line do |line|
|
70
|
+
handle_line(file, line) if zh_ch_reg =~ line
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def handle_line(file, line)
|
76
|
+
line.scan(zh_ch_reg) do |str|
|
77
|
+
str[20, str.length - 22]
|
78
|
+
@used_keys << str[20, str.length - 22]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'csv'
|
4
4
|
require 'cocoapods-lhj-bin/helpers/trans_helper'
|
5
5
|
require 'cocoapods-lhj-bin/helpers/oss_helper'
|
6
|
+
require 'cocoapods-lhj-bin/config/local_config'
|
6
7
|
|
7
8
|
module Pod
|
8
9
|
class Command
|
@@ -26,26 +27,26 @@ module Pod
|
|
26
27
|
|
27
28
|
def initialize(argv)
|
28
29
|
@current_path = argv.shift_argument || Dir.pwd
|
29
|
-
@key_col = argv.option('key-col',
|
30
|
-
@cn_col = argv.option('cn-col',
|
31
|
-
@en_col = argv.option('en-col',
|
30
|
+
@key_col = argv.option('key-col', CBin::LocalConfig.instance.config['csv_key_col']).to_i
|
31
|
+
@cn_col = argv.option('cn-col', CBin::LocalConfig.instance.config['csv_cn_col']).to_i
|
32
|
+
@en_col = argv.option('en-col', CBin::LocalConfig.instance.config['csv_en_col']).to_i
|
32
33
|
@download_csv_files = argv.option('download-csv')
|
33
|
-
@read_csv_file = argv.option('read-csv-file', '
|
34
|
-
@gen_file_name = argv.option('gen-file',
|
34
|
+
@read_csv_file = argv.option('read-csv-file', CBin::LocalConfig.instance.config['read_csv_file'])
|
35
|
+
@gen_file_name = argv.option('gen-file', CBin::LocalConfig.instance.config['gen_file_name'])
|
35
36
|
@modify_source_flag = argv.flag?('modify-source', false)
|
36
37
|
@modify_file_type = argv.option('modify-file-type', 'm,h')
|
37
|
-
@modify_format_string = argv.option('modify-format-string', '
|
38
|
+
@modify_format_string = argv.option('modify-format-string', CBin::LocalConfig.instance.config['source_format_string'])
|
38
39
|
@key_map = {}
|
39
40
|
super
|
40
41
|
end
|
41
42
|
|
42
43
|
def run
|
43
|
-
down_load_csv_file if
|
44
|
+
down_load_csv_file if need_download
|
44
45
|
read_csv_file
|
45
46
|
if @key_map.keys.length.positive?
|
46
47
|
write_en_strings
|
47
|
-
write_zh_cn_strings
|
48
48
|
write_zh_hk_strings
|
49
|
+
write_zh_cn_strings
|
49
50
|
handle_modify_source if @modify_source_flag
|
50
51
|
else
|
51
52
|
UI.puts "获取中英文映射文件失败, 检查参数--read-csv-file=xx是否正常\n".red
|
@@ -53,21 +54,29 @@ module Pod
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def en_dir_name
|
56
|
-
|
57
|
+
CBin::LocalConfig.instance.config['gen_en_dir']
|
57
58
|
end
|
58
59
|
|
59
60
|
def zh_hk_dir_name
|
60
|
-
|
61
|
+
CBin::LocalConfig.instance.config['gen_zh_hk_dir']
|
61
62
|
end
|
62
63
|
|
63
64
|
def zh_cn_dir_name
|
64
|
-
|
65
|
+
CBin::LocalConfig.instance.config['gen_zh_cn_dir']
|
65
66
|
end
|
66
67
|
|
67
68
|
def generate_file_name
|
68
69
|
@gen_file_name
|
69
70
|
end
|
70
71
|
|
72
|
+
def need_download
|
73
|
+
@download_csv_files || CBin::LocalConfig.instance.config['download']
|
74
|
+
end
|
75
|
+
|
76
|
+
def download_cvs_str
|
77
|
+
@download_csv_files || CBin::LocalConfig.instance.config['download_csv']
|
78
|
+
end
|
79
|
+
|
71
80
|
def read_csv_file_name
|
72
81
|
file_name = @read_csv_file
|
73
82
|
file_name = "#{@read_csv_file}.csv" unless /.csv$/ =~ @read_csv_file
|
@@ -101,7 +110,7 @@ module Pod
|
|
101
110
|
|
102
111
|
def get_download_keys
|
103
112
|
download_keys = []
|
104
|
-
csv_files =
|
113
|
+
csv_files = download_cvs_str.split(/,/).map(&:strip)
|
105
114
|
all_keys = CBin::OSS::Helper.instance.list.map(&:key)
|
106
115
|
csv_files.each do |f|
|
107
116
|
arr = all_keys.select { |k| %r{^csv/} =~ k && /#{f}/ =~ k }
|
@@ -126,16 +135,23 @@ module Pod
|
|
126
135
|
def handle_modify_source
|
127
136
|
UI.puts '修改源码开始'
|
128
137
|
Dir.glob("#{@current_path}/**/*.{#{@modify_file_type}}").each do |f|
|
129
|
-
handle_modify_file f if File.stat(f).writable?
|
138
|
+
# handle_modify_file f if File.stat(f).writable?
|
139
|
+
if f =~ /Pods/
|
140
|
+
handle_modify_file(f) if f =~ %r{Pods/ML}
|
141
|
+
else
|
142
|
+
handle_modify_file(f)
|
143
|
+
end
|
130
144
|
end
|
131
145
|
UI.puts '修改源码结束'
|
132
146
|
end
|
133
147
|
|
134
148
|
def handle_modify_file(file)
|
149
|
+
File.chmod(0o644, file)
|
135
150
|
str = modify_file_string(file)
|
136
151
|
File.open(file, 'w+') do |f|
|
137
152
|
f.write(str)
|
138
153
|
end
|
154
|
+
File.chmod(0o444, file) if file =~ /Pods/
|
139
155
|
end
|
140
156
|
|
141
157
|
def modify_file_string(file)
|
@@ -148,20 +164,24 @@ module Pod
|
|
148
164
|
str
|
149
165
|
end
|
150
166
|
|
167
|
+
def zh_ch_reg
|
168
|
+
/@"[^"]*[\u4e00-\u9fa5]+[^"]*"/
|
169
|
+
end
|
170
|
+
|
151
171
|
def modify_format_string(file, line)
|
152
172
|
result = line
|
153
|
-
result = handle_modify_line(file, line) if line =~
|
173
|
+
result = handle_modify_line(file, line) if zh_ch_reg =~ line && !((/DDLog/ =~ line) || (/NSLog/ =~ line))
|
154
174
|
result
|
155
175
|
end
|
156
176
|
|
157
177
|
def handle_modify_line(file, line)
|
158
178
|
result = line
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
179
|
+
line.scan(zh_ch_reg) do |m|
|
180
|
+
key = find_key_by_cn_val(file, m)
|
181
|
+
if key
|
182
|
+
val = format(@modify_format_string, "@\"#{key}\"")
|
183
|
+
result = result.gsub(m, val)
|
184
|
+
end
|
165
185
|
end
|
166
186
|
result
|
167
187
|
end
|
@@ -169,12 +189,12 @@ module Pod
|
|
169
189
|
def find_key_by_cn_val(file, val)
|
170
190
|
file_name = File.basename(file, '.*')
|
171
191
|
cn_key = val[2, val.length - 3]
|
172
|
-
index = @key_map.values.find_index { |obj|
|
173
|
-
index ||= @key_map.values.find_index { |obj|
|
192
|
+
index = @key_map.values.find_index { |obj| cn_key.eql?(obj[:zh]) && /#{file_name}/ =~ obj[:key] }
|
193
|
+
index ||= @key_map.values.find_index { |obj| cn_key.eql?(obj[:zh]) }
|
174
194
|
@key_map.values[index][:key] if index
|
175
195
|
end
|
176
196
|
|
177
|
-
def format_str(type, area = :
|
197
|
+
def format_str(type, area = :origin)
|
178
198
|
str = ''
|
179
199
|
@key_map.each do |k, v|
|
180
200
|
val = v[type]
|
@@ -209,14 +229,34 @@ module Pod
|
|
209
229
|
end
|
210
230
|
|
211
231
|
def write_zh_cn_strings
|
232
|
+
if CBin::LocalConfig.instance.config['gen_zh_cn']
|
233
|
+
gen_zh_cn_strings_file
|
234
|
+
else
|
235
|
+
copy_hk_to_cn_file
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def gen_zh_cn_strings_file
|
212
240
|
file = File.join(@current_path, zh_cn_dir_name, generate_file_name)
|
213
|
-
|
241
|
+
area = :origin
|
242
|
+
area = :cn if CBin::LocalConfig.instance.config['trans_zh_cn']
|
243
|
+
content = format_str(:zh, area)
|
244
|
+
write_to_file(file, content)
|
214
245
|
UI.puts "生成简体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
|
215
246
|
end
|
216
247
|
|
248
|
+
def copy_hk_to_cn_file
|
249
|
+
source_file = File.join(@current_path, zh_hk_dir_name, generate_file_name)
|
250
|
+
dest_file = File.join(@current_path, zh_cn_dir_name, generate_file_name)
|
251
|
+
FileUtils.cp source_file, dest_file
|
252
|
+
UI.puts "繁体中文配置覆盖简体中文配置\n".green
|
253
|
+
end
|
254
|
+
|
217
255
|
def write_zh_hk_strings
|
218
256
|
file = File.join(@current_path, zh_hk_dir_name, generate_file_name)
|
219
|
-
|
257
|
+
area = :origin
|
258
|
+
area = :hk if CBin::LocalConfig.instance.config['trans_zh_hk']
|
259
|
+
content = format_str(:zh, area)
|
220
260
|
write_to_file(file, content)
|
221
261
|
UI.puts "生成繁体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
|
222
262
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Bin < Command
|
8
|
+
class Service < Bin
|
9
|
+
self.summary = '微服务名变更'
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
@current_path = argv.shift_argument || Dir.pwd
|
13
|
+
@file_type = argv.option('file-type', 'm,h')
|
14
|
+
@file_name = argv.option('file-name', 'service_map.csv')
|
15
|
+
@service_map = {}
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
read_csv
|
21
|
+
update_source
|
22
|
+
end
|
23
|
+
|
24
|
+
def read_csv
|
25
|
+
path = File.join(@current_path, csv_file_name)
|
26
|
+
Dir.glob(path).each do |p|
|
27
|
+
CSV.foreach(p) do |row|
|
28
|
+
@service_map[row[0]] = row[1] if row[0]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def csv_file_name
|
34
|
+
file_name = @file_name
|
35
|
+
file_name = "#{@file_name}.csv" unless /.csv$/ =~ @file_name
|
36
|
+
file_name
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_source
|
40
|
+
Dir.glob("#{@current_path}/**/*.{m,h}").each do |f|
|
41
|
+
if f =~ /Pods/
|
42
|
+
update_file(f) if f =~ %r{Pods/ML}
|
43
|
+
else
|
44
|
+
update_file(f)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_file(file)
|
50
|
+
File.chmod(0o644, file)
|
51
|
+
str = file_string(file)
|
52
|
+
File.open(file, 'w+') do |f|
|
53
|
+
f.write(str)
|
54
|
+
end
|
55
|
+
File.chmod(0o444, file) if file =~ /Pods/
|
56
|
+
end
|
57
|
+
|
58
|
+
def file_string(file)
|
59
|
+
str = ''
|
60
|
+
File.open(file, 'r+') do |f|
|
61
|
+
f.each_line do |line|
|
62
|
+
str += format_string(f, line)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
str
|
66
|
+
end
|
67
|
+
|
68
|
+
def format_string(file, line)
|
69
|
+
result = line
|
70
|
+
line.scan(url_reg) do |key|
|
71
|
+
result = result.gsub(key, @service_map[key])
|
72
|
+
end
|
73
|
+
result
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_head_key(line)
|
77
|
+
line.match(url_reg)
|
78
|
+
end
|
79
|
+
|
80
|
+
def url_reg
|
81
|
+
@url_key_reg ||= begin
|
82
|
+
keys = @service_map.keys.join('|')
|
83
|
+
/@".*#{keys}.*"/
|
84
|
+
end
|
85
|
+
@url_key_reg
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-lhj-bin/helpers/oss_helper'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class LocalConfig
|
6
|
+
def config_file
|
7
|
+
File.join(Pod::Config.instance.home_dir, config_file_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def config_file_name
|
11
|
+
'localizable_config.yml'
|
12
|
+
end
|
13
|
+
|
14
|
+
def syn_config_file
|
15
|
+
CBin::OSS::Helper.instance.down_load(config_file_name, config_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_config
|
19
|
+
{ 'gen_en_dir' => 'local_gen/en.lproj',
|
20
|
+
'gen_zh_hk_dir' => 'local_gen/zh-Hant.lproj',
|
21
|
+
'gen_zh_cn_dir' => 'local_gen/zh-Hans.lproj',
|
22
|
+
'gen_file_name' => 'Localizable.strings',
|
23
|
+
'source_format_string' => 'NSLocalizedString(%s, @"")',
|
24
|
+
'csv_key_col' => 0,
|
25
|
+
'csv_cn_col' => 1,
|
26
|
+
'csv_en_col' => 2,
|
27
|
+
'read_csv_file' => '*.csv',
|
28
|
+
'gen_zh_cn' => true,
|
29
|
+
'trans_zh_hk' => false,
|
30
|
+
'trans_zh_cn' => false,
|
31
|
+
'download' => false,
|
32
|
+
'download_csv' => 'zh_en.csv' }
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_config
|
36
|
+
if File.exist?(config_file)
|
37
|
+
YAML.load_file(config_file)
|
38
|
+
else
|
39
|
+
default_config
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def config
|
44
|
+
@config ||= load_config
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.instance
|
48
|
+
@instance ||= new
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
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.11
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -118,7 +118,9 @@ files:
|
|
118
118
|
- lib/cocoapods-lhj-bin/command/bin/lhj.rb
|
119
119
|
- lib/cocoapods-lhj-bin/command/bin/lib/lint.rb
|
120
120
|
- lib/cocoapods-lhj-bin/command/bin/local/fetch.rb
|
121
|
+
- lib/cocoapods-lhj-bin/command/bin/local/filter.rb
|
121
122
|
- lib/cocoapods-lhj-bin/command/bin/local/local.rb
|
123
|
+
- lib/cocoapods-lhj-bin/command/bin/local/micro_service.rb
|
122
124
|
- lib/cocoapods-lhj-bin/command/bin/local/upload.rb
|
123
125
|
- lib/cocoapods-lhj-bin/command/bin/oss/del.rb
|
124
126
|
- lib/cocoapods-lhj-bin/command/bin/oss/list.rb
|
@@ -132,6 +134,7 @@ files:
|
|
132
134
|
- lib/cocoapods-lhj-bin/config/config_builder.rb
|
133
135
|
- lib/cocoapods-lhj-bin/config/config_hot_key.rb
|
134
136
|
- lib/cocoapods-lhj-bin/config/config_hot_key_asker.rb
|
137
|
+
- lib/cocoapods-lhj-bin/config/local_config.rb
|
135
138
|
- lib/cocoapods-lhj-bin/gem_version.rb
|
136
139
|
- lib/cocoapods-lhj-bin/helpers.rb
|
137
140
|
- lib/cocoapods-lhj-bin/helpers/Info.plist
|