cocoapods-aomi-bin 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e89d1160267cbaca0726951d62739924145ad03acf6b2c8841b728fe2fa15ecb
4
- data.tar.gz: de326cca1219934abcc1b23e6bde7a82747fb605c54c67f38542d437df194797
3
+ metadata.gz: b7481159dec769eae8103bda57cb36e305af85b987f1ef0599efe8d195d0d710
4
+ data.tar.gz: 51db4957eafd463de1746a986f66cf4e3e0c59dde020c16adfcff1facdf22b8e
5
5
  SHA512:
6
- metadata.gz: 2d95cd0bb9a8c9cd9ede100eb9dab67e7ccdc9f4393852c9c0a98fa6d31c2082303a61840a2b23503db3a872a169b1fd0a04debba5a476ce71a3e2033d2778b4
7
- data.tar.gz: cb71472ec07895dfdd8499d0a1a571c54ca35210c2c335160b1a5f2375a5626b0263da28f0bd2be575108bc2d0d5995fc65cb0bb48eeaabd467daccaa6aa6fc4
6
+ metadata.gz: 2ffb92c51c36a24ea08db92b8d6e17b30536bb273f726e0f6a93b1e94326f51c07dcf975199c38e0ae397825fe5fdf25ca18a848355ecea4cda9845adc8b52e5
7
+ data.tar.gz: 2efcd36bbb1c8103b9cc7da90f6b2aa69939bcd5fa4d63c418c0e3da1867abcaf3a9ea7df601223790a4bfdbb267368f8cfc4cd04356d1a02eefc3485e002909
@@ -8,6 +8,9 @@ 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'
10
10
  require 'cocoapods-lhj-bin/command/bin/lhj'
11
+ require 'cocoapods-lhj-bin/command/bin/config/push'
12
+ require 'cocoapods-lhj-bin/command/bin/oss/list'
13
+ require 'cocoapods-lhj-bin/command/bin/oss/del'
11
14
  require 'cocoapods-lhj-bin/helpers'
12
15
  require 'cocoapods-lhj-bin/native'
13
16
 
@@ -0,0 +1,43 @@
1
+ #coding:utf-8
2
+ require 'cocoapods-lhj-bin/helpers/oss_helper'
3
+ require 'yaml'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Init < Bin
9
+ class Push < Init
10
+ self.summary = '推送配置文档到OSS.'
11
+
12
+ def initialize(argv)
13
+ super
14
+ end
15
+
16
+ def run
17
+ push
18
+ end
19
+
20
+ def push
21
+ file = File.expand_path("#{Pod::Config.instance.home_dir}/bin_dev.yml")
22
+ CBin::OSS::Helper.instance.upload('bin_dev.yml', file)
23
+ end
24
+
25
+ def trans
26
+ key_map = {}
27
+ path = '/Users/lihaijian/workspace/cocoa/cocoapods-lhj-bin-build-temp/zh2Hant.properties'
28
+ File.open(path, 'r+') do |f|
29
+ f.each_line do |line|
30
+ arr = line.split('=')
31
+ key = [arr[0][2, 4].hex].pack("U")
32
+ val = arr[1].strip!
33
+ key_map[key] = [val[2, 4].hex].pack("U")
34
+ end
35
+ end
36
+ File.open('/Users/lihaijian/workspace/cocoa/cocoapods-lhj-bin-build-temp/zh2hant.yml', 'w') { |f| f.write key_map.to_yaml }
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,54 +1,143 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'csv'
2
4
 
3
5
  module Pod
4
6
  class Command
5
7
  class Bin < Command
6
8
  class Local < Bin
7
- self.summary = '国际化文件变更'
9
+ self.summary = '生成国际化文件'
10
+
11
+ def self.options
12
+ [
13
+ %w[--key Key在csv中第几列,默认为0],
14
+ %w[--cn 中文在csv中第几列,默认为1],
15
+ %w[--en 英文文在csv中第几列,默认为2]
16
+ ]
17
+ end
8
18
 
9
19
  def initialize(argv)
10
20
  @current_path = argv.shift_argument || Dir.pwd
21
+ @key_col = argv.option('key').to_i || 0
22
+ @cn_col = argv.option('cn').to_i || 1
23
+ @en_col = argv.option('en').to_i || 2
11
24
  @key_map = {}
25
+ @trans_map = {}
26
+ @trans_map_invert = {}
12
27
  super
13
28
  end
14
29
 
15
30
  def run
31
+ load_trans_map
16
32
  read_csv_file
17
33
  write_en_strings
18
- write_zh_hans_strings
34
+ write_zh_cn_strings
35
+ write_zh_hk_strings
36
+ end
37
+
38
+ def en_dir_name
39
+ 'en.lproj'
40
+ end
41
+
42
+ def zh_hk_dir_name
43
+ 'zh-hk.lproj'
44
+ end
45
+
46
+ def zh_cn_dir_name
47
+ 'zh-cn.lproj'
48
+ end
49
+
50
+ def generate_file_name
51
+ 'Localizable.strings'
52
+ end
53
+
54
+ def yaml_file
55
+ File.join(Pod::Config.instance.home_dir, 'zh2hant.yml')
56
+ end
57
+
58
+ def load_trans_map
59
+ require 'yaml'
60
+ down_load_yaml unless File.exist?(yaml_file)
61
+ contents = YAML.safe_load(File.open(yaml_file))
62
+ @trans_map = contents.to_hash
63
+ @trans_map_invert = @trans_map.invert
64
+ end
65
+
66
+ def down_load_yaml
67
+ require 'open-uri'
68
+ UI.puts "开始下载简繁配置文件...\n"
69
+ URI.open('http://aomi-ios-repo.oss-cn-shenzhen.aliyuncs.com/zh2hant.yml') do |i|
70
+ File.open(yaml_file, 'w+') do |f|
71
+ f.write(i.read)
72
+ end
73
+ end
19
74
  end
20
75
 
21
76
  def read_csv_file
22
- path = "#{@current_path}/b_lvr_land_a_land.csv"
23
- CSV.foreach(path) { |row| @key_map[row[0]] = { zh: row[1], en: row[3] } unless row[0] =~ /[\u4e00-\u9fa5]/ }
77
+ Dir.glob("#{@current_path}/**/*.csv").each do |p|
78
+ CSV.foreach(p) { |row| @key_map[row[@key_col]] = { zh: row[@cn_col], en: row[@en_col] } unless row[0] =~ /[\u4e00-\u9fa5]/ }
79
+ end
24
80
  end
25
81
 
26
- def file_str(type)
82
+ def format_str(type, area = :cn)
27
83
  str = ''
28
84
  @key_map.each do |k, v|
29
- str += "\"#{k}\" = \"#{v[type]}\";\n"
85
+ val = v[type]
86
+ case area
87
+ when :hk
88
+ val = trans_zh_hk_str val
89
+ when :cn
90
+ val = trans_zh_cn_str val
91
+ end
92
+ str += "\"#{k}\" = \"#{val}\";\n"
30
93
  end
31
94
  str
32
95
  end
33
96
 
34
- def write_to_file(file, type)
97
+ def trans_zh_cn_str(input)
98
+ out = []
99
+ input.each_char do |c|
100
+ out << (@trans_map_invert[c] || c)
101
+ end
102
+ out.join('')
103
+ end
104
+
105
+ def trans_zh_hk_str(input)
106
+ out = []
107
+ input.each_char do |c|
108
+ out << (@trans_map[c] || c)
109
+ end
110
+ out.join('')
111
+ end
112
+
113
+ def write_to_file(file, contents)
35
114
  FileUtils.rm_rf(file) if File.exist?(file)
115
+ FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(File.dirname(file))
36
116
  File.open(file, 'w+') do |f|
37
- str = file_str(type)
38
- f.write(str)
117
+ f.write(contents)
39
118
  end
40
119
  end
41
120
 
121
+ def generate_file(file, type)
122
+ content = format_str(type)
123
+ write_to_file(file, content)
124
+ end
125
+
42
126
  def write_en_strings
43
- file = "#{@current_path}/Main_en.strings"
44
- write_to_file(file, :en)
127
+ file = File.join(@current_path, en_dir_name, generate_file_name)
128
+ generate_file(file, :en)
45
129
  end
46
130
 
47
- def write_zh_hans_strings
48
- file = "#{@current_path}/Main_zh_hans.strings"
49
- write_to_file(file, :zh)
131
+ def write_zh_cn_strings
132
+ file = File.join(@current_path, zh_cn_dir_name, generate_file_name)
133
+ generate_file(file, :zh)
50
134
  end
51
135
 
136
+ def write_zh_hk_strings
137
+ file = File.join(@current_path, zh_hk_dir_name, generate_file_name)
138
+ content = format_str(:zh, :hk)
139
+ write_to_file(file, content)
140
+ end
52
141
  end
53
142
  end
54
143
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ require 'cocoapods-lhj-bin/helpers/oss_helper'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class OSS < Bin
8
+ class Del < OSS
9
+ self.summary = '删除OSS的key'
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('--key=XX', true)
13
+ ]
14
+
15
+ def self.options
16
+ [
17
+ ['--key', 'OSS对应的key']
18
+ ]
19
+ end
20
+
21
+ def initialize(argv)
22
+ @key = argv.option('key')
23
+ super
24
+ end
25
+
26
+ def validate!
27
+ help! "请输入key" unless @key
28
+ super
29
+ end
30
+
31
+ def run
32
+ CBin::OSS::Helper.instance.delete(@key)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require 'cocoapods-lhj-bin/helpers/oss_helper'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class OSS < Bin
8
+ class List < OSS
9
+ self.summary = '查看OSS列表'
10
+
11
+ def initialize(argv)
12
+ super
13
+ end
14
+
15
+ def run
16
+ objects = CBin::OSS::Helper.instance.list
17
+ objects.each do |o|
18
+ path = "#{CBin::OSS::Helper.instance.url_path}/#{o.key}"
19
+ UI.puts path.green
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
4
4
 
5
5
  module Pod
@@ -0,0 +1,35 @@
1
+ require 'aliyun/oss'
2
+ require 'cocoapods-lhj-bin/config/config'
3
+
4
+ module CBin
5
+ class OSS
6
+ class Helper
7
+ def initialize
8
+ @client = Aliyun::OSS::Client.new(endpoint: CBin.config.oss_endpoint,
9
+ access_key_id: CBin.config.oss_access_key_id,
10
+ access_key_secret: CBin.config.oss_access_key_secret)
11
+ @bucket = @client.get_bucket(CBin.config.oss_bucket)
12
+ end
13
+
14
+ def url_path
15
+ "http://#{CBin.config.oss_bucket}.#{CBin.config.oss_endpoint}"
16
+ end
17
+
18
+ def upload(key, file)
19
+ @bucket.put_object(key, :file => file)
20
+ end
21
+
22
+ def list
23
+ @bucket.list_objects
24
+ end
25
+
26
+ def delete(key)
27
+ @bucket.delete_object(key)
28
+ end
29
+
30
+ def self.instance
31
+ @instance ||= new
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,4 +1,4 @@
1
- require 'aliyun/oss'
1
+ require 'cocoapods-lhj-bin/helpers/oss_helper'
2
2
  require 'cocoapods-lhj-bin/native/podfile'
3
3
  require 'cocoapods/command/gen'
4
4
  require 'cocoapods/generate'
@@ -17,8 +17,6 @@ module CBin
17
17
  @spec = spec
18
18
  @code_dependencies = code_dependencies
19
19
  @sources = sources
20
- @client = Aliyun::OSS::Client.new(endpoint: CBin.config.oss_endpoint, access_key_id: CBin.config.oss_access_key_id, access_key_secret: CBin.config.oss_access_key_secret )
21
- @bucket = @client.get_bucket(CBin.config.oss_bucket)
22
20
  end
23
21
 
24
22
  def upload
@@ -73,7 +71,7 @@ EOF
73
71
  res = File.exist?(zip_file)
74
72
  end
75
73
  if res
76
- @bucket.put_object("#{@spec.name}/#{@spec.version}/#{@spec.name}.zip", :file => zip_file)
74
+ CBin::OSS::Helper.instance.upload("#{@spec.name}/#{@spec.version}/#{@spec.name}.zip", zip_file)
77
75
  end
78
76
  res
79
77
  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.0.6
4
+ version: 0.0.7
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 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -109,6 +109,7 @@ files:
109
109
  - lib/cocoapods-lhj-bin/command/bin/archive.rb
110
110
  - lib/cocoapods-lhj-bin/command/bin/auto.rb
111
111
  - lib/cocoapods-lhj-bin/command/bin/code.rb
112
+ - lib/cocoapods-lhj-bin/command/bin/config/push.rb
112
113
  - lib/cocoapods-lhj-bin/command/bin/dup.rb
113
114
  - lib/cocoapods-lhj-bin/command/bin/import.rb
114
115
  - lib/cocoapods-lhj-bin/command/bin/init.rb
@@ -117,6 +118,8 @@ files:
117
118
  - lib/cocoapods-lhj-bin/command/bin/lhj.rb
118
119
  - lib/cocoapods-lhj-bin/command/bin/lib/lint.rb
119
120
  - lib/cocoapods-lhj-bin/command/bin/local.rb
121
+ - lib/cocoapods-lhj-bin/command/bin/oss/del.rb
122
+ - lib/cocoapods-lhj-bin/command/bin/oss/list.rb
120
123
  - lib/cocoapods-lhj-bin/command/bin/repo/update.rb
121
124
  - lib/cocoapods-lhj-bin/command/bin/spec/create.rb
122
125
  - lib/cocoapods-lhj-bin/command/bin/spec/push.rb
@@ -135,6 +138,7 @@ files:
135
138
  - lib/cocoapods-lhj-bin/helpers/framework_builder.rb
136
139
  - lib/cocoapods-lhj-bin/helpers/library.rb
137
140
  - lib/cocoapods-lhj-bin/helpers/library_builder.rb
141
+ - lib/cocoapods-lhj-bin/helpers/oss_helper.rb
138
142
  - lib/cocoapods-lhj-bin/helpers/sources_helper.rb
139
143
  - lib/cocoapods-lhj-bin/helpers/spec_creator.rb
140
144
  - lib/cocoapods-lhj-bin/helpers/spec_files_helper.rb