cocoapods-aomi-bin 0.1.1 → 0.1.6
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-lhj-bin/command/bin.rb +3 -2
- data/lib/cocoapods-lhj-bin/command/bin/{fetch.rb → local/fetch.rb} +7 -1
- data/lib/cocoapods-lhj-bin/command/bin/{local.rb → local/local.rb} +77 -29
- data/lib/cocoapods-lhj-bin/command/bin/local/upload.rb +46 -0
- data/lib/cocoapods-lhj-bin/command/bin/oss/del.rb +1 -1
- data/lib/cocoapods-lhj-bin/command/bin/oss/list.rb +0 -4
- data/lib/cocoapods-lhj-bin/config/config.rb +0 -3
- data/lib/cocoapods-lhj-bin/gem_version.rb +1 -1
- data/lib/cocoapods-lhj-bin/helpers/oss_helper.rb +8 -0
- data/lib/cocoapods-lhj-bin/helpers/trans_helper.rb +0 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de50f4edfa779b9e90f5ae4e184d6f6fa16dfa30ccb8391315eed1f5fcf2400
|
4
|
+
data.tar.gz: f2148de18be3ad11c18f1456407f912378c4ff3110185baaaa525438c99b8256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cad276b5fa7153d116e8bf4cbd9461b563329b7492ddf12a21536de3ed57d409d46f6cc211d6bf612b3f0f37994f3e487bf6f354fad2fca7d145479e2a993d5a
|
7
|
+
data.tar.gz: cd8cbe520df055dbaaa779221e9dc2856e49bfd7b20bf1bcf23604306e36399f17e7020e0d8c5b94445100a96e7758a5189b9a5a4fd7f8e1d5928c31f69ecad8
|
@@ -6,9 +6,10 @@ require 'cocoapods-lhj-bin/command/bin/code'
|
|
6
6
|
require 'cocoapods-lhj-bin/command/bin/update'
|
7
7
|
require 'cocoapods-lhj-bin/command/bin/install'
|
8
8
|
require 'cocoapods-lhj-bin/command/bin/import'
|
9
|
-
require 'cocoapods-lhj-bin/command/bin/local'
|
9
|
+
require 'cocoapods-lhj-bin/command/bin/local/local'
|
10
|
+
require 'cocoapods-lhj-bin/command/bin/local/fetch'
|
11
|
+
require 'cocoapods-lhj-bin/command/bin/local/upload'
|
10
12
|
require 'cocoapods-lhj-bin/command/bin/trans'
|
11
|
-
require 'cocoapods-lhj-bin/command/bin/fetch'
|
12
13
|
require 'cocoapods-lhj-bin/command/bin/lhj'
|
13
14
|
require 'cocoapods-lhj-bin/command/bin/config/push'
|
14
15
|
require 'cocoapods-lhj-bin/command/bin/oss/list'
|
@@ -28,8 +28,14 @@ module Pod
|
|
28
28
|
gen_csv
|
29
29
|
end
|
30
30
|
|
31
|
+
def csv_file_name
|
32
|
+
file_name = @file_name
|
33
|
+
file_name = "#{@file_name}.csv" unless /.csv$/ =~ @file_name
|
34
|
+
file_name
|
35
|
+
end
|
36
|
+
|
31
37
|
def gen_csv
|
32
|
-
file = File.join(@current_path,
|
38
|
+
file = File.join(@current_path, csv_file_name)
|
33
39
|
FileUtils.rm_rf(file) if File.exist?(file)
|
34
40
|
CSV.open(file, 'wb:utf-8') do |csv|
|
35
41
|
csv << %w[国际化key 中文 英文 原字符 所在文件 文件路径]
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'csv'
|
4
4
|
require 'cocoapods-lhj-bin/helpers/trans_helper'
|
5
|
+
require 'cocoapods-lhj-bin/helpers/oss_helper'
|
5
6
|
|
6
7
|
module Pod
|
7
8
|
class Command
|
@@ -14,11 +15,12 @@ module Pod
|
|
14
15
|
%w[--key-col 国际化key在csv中第几列,默认为0],
|
15
16
|
%w[--cn-col 中文在csv中第几列,默认为1],
|
16
17
|
%w[--en-col 英文在csv中第几列,默认为2],
|
17
|
-
%w[--csv
|
18
|
-
%w[--
|
18
|
+
%w[--download-csv 云端下载cvs的文件名],
|
19
|
+
%w[--read-csv-file 读取csv的文件名,默认为当前目录下所有csv文件],
|
20
|
+
%w[--gen-file 生成配置文件名,默认名为:Localizable.strings],
|
19
21
|
%w[--modify-source 修改源码,使用国际化key代替中文字符串],
|
20
22
|
%w[--modify-file-type 需要修改源码的文件类型,默认为m,h],
|
21
|
-
%w[--modify-format-string 修改为国际化后的字符格式,默认为NSLocalizedString(%s
|
23
|
+
%w[--modify-format-string 修改为国际化后的字符格式,默认为NSLocalizedString(%s,@"")]
|
22
24
|
]
|
23
25
|
end
|
24
26
|
|
@@ -27,17 +29,18 @@ module Pod
|
|
27
29
|
@key_col = argv.option('key-col', 0).to_i
|
28
30
|
@cn_col = argv.option('cn-col', 1).to_i
|
29
31
|
@en_col = argv.option('en-col', 2).to_i
|
30
|
-
@
|
32
|
+
@download_csv_files = argv.option('download-csv')
|
33
|
+
@read_csv_file = argv.option('read-csv-file', '*')
|
31
34
|
@gen_file_name = argv.option('gen-file', 'Localizable.strings')
|
32
35
|
@modify_source_flag = argv.flag?('modify-source', false)
|
33
36
|
@modify_file_type = argv.option('modify-file-type', 'm,h')
|
34
37
|
@modify_format_string = argv.option('modify-format-string', 'NSLocalizedString(%s, @"")')
|
35
38
|
@key_map = {}
|
36
|
-
@cn_key_map = {}
|
37
39
|
super
|
38
40
|
end
|
39
41
|
|
40
42
|
def run
|
43
|
+
down_load_csv_file if @download_csv_files
|
41
44
|
read_csv_file
|
42
45
|
if @key_map.keys.length.positive?
|
43
46
|
write_en_strings
|
@@ -45,32 +48,87 @@ module Pod
|
|
45
48
|
write_zh_hk_strings
|
46
49
|
handle_modify_source if @modify_source_flag
|
47
50
|
else
|
48
|
-
UI.puts "获取中英文映射文件失败, 检查参数--csv-file=xx是否正常\n".red
|
51
|
+
UI.puts "获取中英文映射文件失败, 检查参数--read-csv-file=xx是否正常\n".red
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
55
|
def en_dir_name
|
53
|
-
'en.lproj'
|
56
|
+
'local_gen/en.lproj'
|
54
57
|
end
|
55
58
|
|
56
59
|
def zh_hk_dir_name
|
57
|
-
'zh-hk.lproj'
|
60
|
+
'local_gen/zh-hk.lproj'
|
58
61
|
end
|
59
62
|
|
60
63
|
def zh_cn_dir_name
|
61
|
-
'zh-cn.lproj'
|
64
|
+
'local_gen/zh-cn.lproj'
|
62
65
|
end
|
63
66
|
|
64
67
|
def generate_file_name
|
65
68
|
@gen_file_name
|
66
69
|
end
|
67
70
|
|
71
|
+
def read_csv_file_name
|
72
|
+
file_name = @read_csv_file
|
73
|
+
file_name = "#{@read_csv_file}.csv" unless /.csv$/ =~ @read_csv_file
|
74
|
+
file_name
|
75
|
+
end
|
76
|
+
|
77
|
+
def down_load_csv_file
|
78
|
+
ary = get_download_keys
|
79
|
+
ary.each do |key|
|
80
|
+
file_name = File.basename(key)
|
81
|
+
file = File.join(@current_path, file_name)
|
82
|
+
backup_csv_file file if File.exist?(file)
|
83
|
+
UI.puts "下载csv文件:#{CBin::OSS::Helper.instance.object_url(key)} 到目录#{file}\n".green
|
84
|
+
CBin::OSS::Helper.instance.down_load(key, file)
|
85
|
+
end
|
86
|
+
UI.puts "下载云端csv文件完成 \n".green
|
87
|
+
end
|
88
|
+
|
89
|
+
def backup_csv_file(file)
|
90
|
+
dest_file = bak_file(file)
|
91
|
+
FileUtils.mkdir_p(File.dirname(dest_file)) unless File.exist?(File.dirname(dest_file))
|
92
|
+
UI.puts "备份csv文件:#{file} 到目录#{dest_file}".green
|
93
|
+
FileUtils.cp file, dest_file
|
94
|
+
FileUtils.rm_rf file
|
95
|
+
end
|
96
|
+
|
97
|
+
def bak_file(file)
|
98
|
+
dest_file = File.join(File.dirname(file), 'csv_bak', File.basename(file))
|
99
|
+
File.exist?(dest_file) ? bak_file(dest_file) : dest_file
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_download_keys
|
103
|
+
download_keys = []
|
104
|
+
csv_files = @download_csv_files.split(/,/).map(&:strip)
|
105
|
+
all_keys = CBin::OSS::Helper.instance.list.map(&:key)
|
106
|
+
csv_files.each do |f|
|
107
|
+
arr = all_keys.select { |k| %r{^csv/} =~ k && /#{f}/ =~ k }
|
108
|
+
if arr.count.positive?
|
109
|
+
arr.sort! { |a, b| b.split(%r{/})[1].to_i <=> a.split(%r{/})[1].to_i }
|
110
|
+
download_keys << arr[0]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
download_keys
|
114
|
+
end
|
115
|
+
|
116
|
+
def read_csv_file
|
117
|
+
path = File.join(@current_path, read_csv_file_name)
|
118
|
+
Dir.glob(path).each do |p|
|
119
|
+
CSV.foreach(p) do |row|
|
120
|
+
key = row[@key_col]
|
121
|
+
@key_map[key] = { key: key, zh: row[@cn_col], en: row[@en_col] } unless key =~ /[\u4e00-\u9fa5]/
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
68
126
|
def handle_modify_source
|
69
|
-
UI.puts '
|
127
|
+
UI.puts '修改源码开始'
|
70
128
|
Dir.glob("#{@current_path}/**/*.{#{@modify_file_type}}").each do |f|
|
71
129
|
handle_modify_file f if File.stat(f).writable?
|
72
130
|
end
|
73
|
-
UI.puts '
|
131
|
+
UI.puts '修改源码结束'
|
74
132
|
end
|
75
133
|
|
76
134
|
def handle_modify_file(file)
|
@@ -92,15 +150,15 @@ module Pod
|
|
92
150
|
|
93
151
|
def modify_format_string(file, line)
|
94
152
|
result = line
|
95
|
-
result = handle_modify_line line if line =~ /@"[^"]*[\u4e00-\u9fa5]+[^"]*"/
|
153
|
+
result = handle_modify_line(file, line) if line =~ /@"[^"]*[\u4e00-\u9fa5]+[^"]*"/
|
96
154
|
result
|
97
155
|
end
|
98
156
|
|
99
|
-
def handle_modify_line(line)
|
157
|
+
def handle_modify_line(file, line)
|
100
158
|
result = line
|
101
159
|
reg = /@"[^"]*[\u4e00-\u9fa5]+[^"]*"/
|
102
160
|
ma = reg.match(line)
|
103
|
-
key = find_key_by_cn_val(ma[0])
|
161
|
+
key = find_key_by_cn_val(file, ma[0])
|
104
162
|
if key
|
105
163
|
val = format(@modify_format_string, "@\"#{key}\"")
|
106
164
|
result = line.gsub(ma[0], val)
|
@@ -108,22 +166,12 @@ module Pod
|
|
108
166
|
result
|
109
167
|
end
|
110
168
|
|
111
|
-
def find_key_by_cn_val(val)
|
169
|
+
def find_key_by_cn_val(file, val)
|
170
|
+
file_name = File.basename(file, '.*')
|
112
171
|
cn_key = val[2, val.length - 3]
|
113
|
-
@
|
114
|
-
|
115
|
-
|
116
|
-
def read_csv_file
|
117
|
-
path = "#{@current_path}/#{@csv_file}.csv"
|
118
|
-
Dir.glob(path).each do |p|
|
119
|
-
CSV.foreach(p) do |row|
|
120
|
-
key = row[@key_col]
|
121
|
-
unless key =~ /[\u4e00-\u9fa5]/
|
122
|
-
@key_map[key] = { zh: row[@cn_col], en: row[@en_col] }
|
123
|
-
@cn_key_map[row[@cn_col]] = key
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
172
|
+
index = @key_map.values.find_index { |obj| /^#{cn_key}$/ =~ obj[:zh] && /^#{file_name}/ =~ obj[:key] }
|
173
|
+
index ||= @key_map.values.find_index { |obj| /^#{cn_key}$/ =~ obj[:zh] }
|
174
|
+
@key_map.values[index][:key] if index
|
127
175
|
end
|
128
176
|
|
129
177
|
def format_str(type, area = :cn)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'cocoapods-lhj-bin/helpers/oss_helper'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Bin < Command
|
6
|
+
class Local < Bin
|
7
|
+
class Upload < Local
|
8
|
+
self.summary = '上传中英文对照csv文件'
|
9
|
+
|
10
|
+
def self.options
|
11
|
+
[
|
12
|
+
%w[--upload-file 上传中英文对照csv文件名]
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(argv)
|
17
|
+
@pwd_path = argv.shift_argument || Dir.pwd
|
18
|
+
@upload_csv_file = argv.option('upload-file', '*.csv')
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def csv_file_name
|
23
|
+
file_name = @upload_csv_file
|
24
|
+
file_name = "#{@upload_csv_file}.csv" unless /.csv$/ =~ @upload_csv_file
|
25
|
+
file_name
|
26
|
+
end
|
27
|
+
|
28
|
+
def csv_oss_key(file_name)
|
29
|
+
"csv/#{Time.now.to_i}/#{file_name}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
csv_files = File.join(@pwd_path, '**', csv_file_name)
|
34
|
+
Dir.glob(csv_files).each do |f|
|
35
|
+
file_name = File.basename(f)
|
36
|
+
oss_key = csv_oss_key file_name
|
37
|
+
CBin::OSS::Helper.instance.upload(oss_key, f)
|
38
|
+
url = CBin::OSS::Helper.instance.object_url(oss_key)
|
39
|
+
UI.puts "云端上传成功.下载Url:#{url}\n".green
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -36,12 +36,9 @@ module CBin
|
|
36
36
|
case configuration_env
|
37
37
|
when 'release_iphoneos'
|
38
38
|
file = config_release_iphoneos_file
|
39
|
-
puts "\n====== #{configuration_env} 环境 ========"
|
40
39
|
when 'debug_iphoneos'
|
41
40
|
file = config_debug_iphoneos_file
|
42
|
-
puts "\n====== #{configuration_env} 环境 ========"
|
43
41
|
when 'dev'
|
44
|
-
puts "\n====== #{configuration_env} 环境 ========"
|
45
42
|
else
|
46
43
|
raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]===="
|
47
44
|
end
|
@@ -19,6 +19,14 @@ module CBin
|
|
19
19
|
@bucket.put_object(key, :file => file)
|
20
20
|
end
|
21
21
|
|
22
|
+
def down_load(key, file)
|
23
|
+
@bucket.get_object(key, :file => file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def object_url(key)
|
27
|
+
@bucket.object_url(key, false)
|
28
|
+
end
|
29
|
+
|
22
30
|
def list
|
23
31
|
@bucket.list_objects
|
24
32
|
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.6
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -111,14 +111,15 @@ files:
|
|
111
111
|
- lib/cocoapods-lhj-bin/command/bin/code.rb
|
112
112
|
- lib/cocoapods-lhj-bin/command/bin/config/push.rb
|
113
113
|
- lib/cocoapods-lhj-bin/command/bin/dup.rb
|
114
|
-
- lib/cocoapods-lhj-bin/command/bin/fetch.rb
|
115
114
|
- lib/cocoapods-lhj-bin/command/bin/import.rb
|
116
115
|
- lib/cocoapods-lhj-bin/command/bin/init.rb
|
117
116
|
- lib/cocoapods-lhj-bin/command/bin/initHotKey.rb
|
118
117
|
- lib/cocoapods-lhj-bin/command/bin/install.rb
|
119
118
|
- lib/cocoapods-lhj-bin/command/bin/lhj.rb
|
120
119
|
- lib/cocoapods-lhj-bin/command/bin/lib/lint.rb
|
121
|
-
- lib/cocoapods-lhj-bin/command/bin/local.rb
|
120
|
+
- lib/cocoapods-lhj-bin/command/bin/local/fetch.rb
|
121
|
+
- lib/cocoapods-lhj-bin/command/bin/local/local.rb
|
122
|
+
- lib/cocoapods-lhj-bin/command/bin/local/upload.rb
|
122
123
|
- lib/cocoapods-lhj-bin/command/bin/oss/del.rb
|
123
124
|
- lib/cocoapods-lhj-bin/command/bin/oss/list.rb
|
124
125
|
- lib/cocoapods-lhj-bin/command/bin/repo/update.rb
|