cocoapods-aomi-bin 0.1.8 → 0.1.9
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: 8fc461c5e823740442cc8c083a408a4acb93360fc6363a183a5679d070c79df0
|
4
|
+
data.tar.gz: '0397bd469fb875c69681e7c5739439a923bf31ef7846386f6d07f2f63952c122'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c963ee1a10a974416d2cd5525f539a905e79439bbf8680a9fe2cf44bf531de1782bfbe40e96fb0aeafe911ac833d2c7a88223cbaec1ff0dfca06803004e6fcdd
|
7
|
+
data.tar.gz: 171b50fc4a031baf5414c3a9641665e790d46c5a7bf0ea530ef45ab633ad50ee5035295d2b14e8f36d015b60cac0f35749aa6c2b709aa8da66a9feb80af4276b
|
@@ -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
|
@@ -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,25 +27,25 @@ 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
|
+
write_zh_cn_strings if CBin::LocalConfig.instance.config['gen_zh_cn']
|
48
49
|
write_zh_hk_strings
|
49
50
|
handle_modify_source if @modify_source_flag
|
50
51
|
else
|
@@ -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 }
|
@@ -185,7 +194,7 @@ module Pod
|
|
185
194
|
@key_map.values[index][:key] if index
|
186
195
|
end
|
187
196
|
|
188
|
-
def format_str(type, area = :
|
197
|
+
def format_str(type, area = :origin)
|
189
198
|
str = ''
|
190
199
|
@key_map.each do |k, v|
|
191
200
|
val = v[type]
|
@@ -221,13 +230,18 @@ module Pod
|
|
221
230
|
|
222
231
|
def write_zh_cn_strings
|
223
232
|
file = File.join(@current_path, zh_cn_dir_name, generate_file_name)
|
224
|
-
|
233
|
+
area = :origin
|
234
|
+
area = :cn if CBin::LocalConfig.instance.config['trans_zh_cn']
|
235
|
+
content = format_str(:zh, area)
|
236
|
+
write_to_file(file, content)
|
225
237
|
UI.puts "生成简体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
|
226
238
|
end
|
227
239
|
|
228
240
|
def write_zh_hk_strings
|
229
241
|
file = File.join(@current_path, zh_hk_dir_name, generate_file_name)
|
230
|
-
|
242
|
+
area = :origin
|
243
|
+
area = :hk if CBin::LocalConfig.instance.config['trans_zh_hk']
|
244
|
+
content = format_str(:zh, area)
|
231
245
|
write_to_file(file, content)
|
232
246
|
UI.puts "生成繁体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
|
233
247
|
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.9
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/cocoapods-lhj-bin/config/config_builder.rb
|
133
133
|
- lib/cocoapods-lhj-bin/config/config_hot_key.rb
|
134
134
|
- lib/cocoapods-lhj-bin/config/config_hot_key_asker.rb
|
135
|
+
- lib/cocoapods-lhj-bin/config/local_config.rb
|
135
136
|
- lib/cocoapods-lhj-bin/gem_version.rb
|
136
137
|
- lib/cocoapods-lhj-bin/helpers.rb
|
137
138
|
- lib/cocoapods-lhj-bin/helpers/Info.plist
|