cocoapods-aomi-bin 0.1.12 → 0.1.17

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: 9cfcbfeeae134c9aacd50c954533008ba3236e50fcafe6e15bfef70e4bbc3973
4
- data.tar.gz: 864e6bc1e2a0f42ccff3794f19947cedbd4f8bde8115162f776e0017d4576ef1
3
+ metadata.gz: 49133e2b9dbd7b9dc71db8acab55373cdff0edc852c389d77807af522c1626dd
4
+ data.tar.gz: 42f7f78c46513a26710835aa834d1e05b67e7ada7b524c87bda676e0912dd348
5
5
  SHA512:
6
- metadata.gz: 755402a04f78ef6a944739939c8ae4a193a255bbef817f2556e61a19659fb3b7e70d59ed5f50f79ccf4aa60f7c5f851b59bf0ed8494fc0b98b695958f211f28f
7
- data.tar.gz: 174b6b7804b20c4a76d5805357e28a98360c4ff0d626cab0089b28f3252ecb62990aa3a736b23226983c775562ecb90ed58b7ac1c064f5aa2d130d27cfe8263b
6
+ metadata.gz: e71bf10b411685698e9f2f42ae0d4d252112cba5c63c245395aa30a66cafa44e81a8984ab67b9a31ad68aabf9a52c11f7056590bd9f6e7898c2281fef6c6a658
7
+ data.tar.gz: 158c7b60ee4561488d8ad22c5e4a01bc6bdecc79cf4a37e87a3ca8362e6c541506edc29b3cbd07e98eb707990017036eccd71169e206be5680e7e27054a32c4c
@@ -6,6 +6,7 @@ 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/reverse_import'
9
10
  require 'cocoapods-lhj-bin/command/bin/local/local'
10
11
  require 'cocoapods-lhj-bin/command/bin/local/fetch'
11
12
  require 'cocoapods-lhj-bin/command/bin/local/filter'
@@ -13,6 +14,8 @@ require 'cocoapods-lhj-bin/command/bin/local/micro_service'
13
14
  require 'cocoapods-lhj-bin/command/bin/local/upload'
14
15
  require 'cocoapods-lhj-bin/command/bin/trans'
15
16
  require 'cocoapods-lhj-bin/command/bin/lhj'
17
+ require 'cocoapods-lhj-bin/command/bin/model'
18
+ require 'cocoapods-lhj-bin/command/bin/view'
16
19
  require 'cocoapods-lhj-bin/command/bin/config/push'
17
20
  require 'cocoapods-lhj-bin/command/bin/oss/list'
18
21
  require 'cocoapods-lhj-bin/command/bin/oss/del'
@@ -55,7 +58,7 @@ module Pod
55
58
  end
56
59
 
57
60
  def validate!
58
- super
61
+ # super
59
62
  # 这里由于 --help 是在 validate! 方法中提取的,会导致 --help 失效
60
63
  # pod lib create 也有这个问题
61
64
  banner! if @help
@@ -18,8 +18,8 @@ module Pod
18
18
  end
19
19
 
20
20
  def push_cn_hk
21
- file = File.expand_path("#{Pod::Config.instance.home_dir}/zh2hant.yml")
22
- CBin::OSS::Helper.instance.upload('zh2hant.yml', file)
21
+ file = File.expand_path("#{Pod::Config.instance.home_dir}/localizable_config.yml")
22
+ CBin::OSS::Helper.instance.upload('localizable_config.yml', file)
23
23
  end
24
24
 
25
25
  def push
@@ -115,6 +115,16 @@ module Pod
115
115
  result
116
116
  end
117
117
 
118
+ =begin
119
+ def format_string(file, line)
120
+ result = line
121
+ if /(\W)(TicketList)(\W)/ =~ line
122
+ result = result.gsub(/(\W)(TicketList)(\W)/, '\1TKTicketModel\3')
123
+ end
124
+ result
125
+ end
126
+ =end
127
+
118
128
  def exist_in_file(file, header)
119
129
  folder_name = @header_folder_map[header.to_sym]
120
130
  Regexp.new("/Pods/#{folder_name}") =~ File.path(file) if folder_name
@@ -77,6 +77,7 @@ module Pod
77
77
  fname = File.basename(file)
78
78
  dir_name = File.dirname(file)
79
79
  mod_name = framework_name(dir_name)
80
+ # ('a'..'z').to_a.shuffle[0..12].join
80
81
  key = "#{mod_name}.#{File.basename(file, '.*')}.#{rand(36**8).to_s(36)}"
81
82
  cn_str = str[2, str.length - 3]
82
83
  en_str = cn_str.gsub(/[\u4e00-\u9fa5]/, 'x')
@@ -42,7 +42,7 @@ module Pod
42
42
 
43
43
  def run
44
44
  down_load_csv_file if need_download
45
- read_csv_file
45
+ read_csv
46
46
  if @key_map.keys.length.positive?
47
47
  write_en_strings
48
48
  write_zh_hk_strings
@@ -122,12 +122,27 @@ module Pod
122
122
  download_keys
123
123
  end
124
124
 
125
- def read_csv_file
125
+ def read_csv
126
126
  path = File.join(@current_path, read_csv_file_name)
127
- Dir.glob(path).each do |p|
128
- CSV.foreach(p) do |row|
129
- key = row[@key_col]
130
- @key_map[key] = { key: key, zh: row[@cn_col], en: row[@en_col] } unless key =~ /[\u4e00-\u9fa5]/
127
+ Dir.glob(path).each do |f|
128
+ read_csv_file f
129
+ end
130
+ end
131
+
132
+ def read_csv_file(file)
133
+ key_c = CBin::LocalConfig.instance.get_col_by_name(file, 'csv_key_col')
134
+ cn_c = CBin::LocalConfig.instance.get_col_by_name(file, 'csv_cn_col')
135
+ en_c = CBin::LocalConfig.instance.get_col_by_name(file, 'csv_en_col')
136
+ trans_hk = CBin::LocalConfig.instance.get_col_by_name(file, 'trans_zh_hk')
137
+ trans_cn = CBin::LocalConfig.instance.get_col_by_name(file, 'trans_zh_cn')
138
+ CSV.foreach(file) do |row|
139
+ if row.length > 2
140
+ key = row[key_c]
141
+ cn_str = row[cn_c]
142
+ hk_str = row[cn_c]
143
+ cn_str = CBin::Trans::Helper.instance.trans_zh_cn_str(cn_str) if trans_cn
144
+ hk_str = CBin::Trans::Helper.instance.trans_zh_hk_str(hk_str) if trans_hk
145
+ @key_map[key] = { key: key, cn: cn_str, hk: hk_str, en: row[en_c] } unless key =~ /[\u4e00-\u9fa5]/
131
146
  end
132
147
  end
133
148
  end
@@ -194,17 +209,10 @@ module Pod
194
209
  @key_map.values[index][:key] if index
195
210
  end
196
211
 
197
- def format_str(type, area = :origin)
212
+ def format_str(type)
198
213
  str = ''
199
214
  @key_map.each do |k, v|
200
- val = v[type]
201
- case area
202
- when :hk
203
- val = CBin::Trans::Helper.instance.trans_zh_hk_str val
204
- when :cn
205
- val = CBin::Trans::Helper.instance.trans_zh_cn_str val
206
- end
207
- str += "\"#{k}\" = \"#{val}\";\n"
215
+ str += "\"#{k}\" = \"#{v[type]}\";\n"
208
216
  end
209
217
  str
210
218
  end
@@ -229,18 +237,12 @@ module Pod
229
237
  end
230
238
 
231
239
  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
240
+ gen_zh_cn_strings_file
237
241
  end
238
242
 
239
243
  def gen_zh_cn_strings_file
240
244
  file = File.join(@current_path, zh_cn_dir_name, generate_file_name)
241
- area = :origin
242
- area = :cn if CBin::LocalConfig.instance.config['trans_zh_cn']
243
- content = format_str(:zh, area)
245
+ content = format_str(:cn)
244
246
  write_to_file(file, content)
245
247
  UI.puts "生成简体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
246
248
  end
@@ -254,9 +256,7 @@ module Pod
254
256
 
255
257
  def write_zh_hk_strings
256
258
  file = File.join(@current_path, zh_hk_dir_name, generate_file_name)
257
- area = :origin
258
- area = :hk if CBin::LocalConfig.instance.config['trans_zh_hk']
259
- content = format_str(:zh, area)
259
+ content = format_str(:hk)
260
260
  write_to_file(file, content)
261
261
  UI.puts "生成繁体中文配置完成.文件路径:#{File.absolute_path(file)}\n".green
262
262
  end
@@ -0,0 +1,103 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module Pod
6
+ class Command
7
+ class Bin < Command
8
+ class Model < Bin
9
+ self.summary = '生成模型文件'
10
+
11
+ def initialize(argv)
12
+ @url = argv.shift_argument
13
+ @model_pre_name = argv.option('model-pre', 'ML')
14
+ @models = []
15
+ end
16
+
17
+ def run
18
+ uri = URI.parse(@url)
19
+ res = Net::HTTP.get_response(uri)
20
+ res_body = JSON.parse(res.body)
21
+ detail_msg = res_body['detailMsg']
22
+ fetch_models(nil, detail_msg) if detail_msg
23
+ print_models
24
+ print_models_implementation
25
+ end
26
+
27
+ def validate!
28
+ help! "请输入url" unless @url
29
+ end
30
+
31
+ def fetch_models(name, obj)
32
+ model = obj
33
+ model = obj.first if obj.respond_to? :<<
34
+ @models.unshift({name: name, value: model}) if model.instance_of? Hash
35
+ if model.instance_of? Hash
36
+ model.each do |key, value|
37
+ if (value.instance_of? Hash) || (value.instance_of? Array)
38
+ fetch_models(key, value)
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def print_models
45
+ @models.each do |model|
46
+ model_name = ''
47
+ model_name = model[:name].gsub('List', '').gsub('Vo', '').gsub(/^\w/) { $&.upcase } if model[:name]
48
+ puts "@interface #{@model_pre_name}#{model_name}Model : NSObject"
49
+ model[:value].each do |key, value|
50
+ print_property(key, value)
51
+ end
52
+ puts "@end\n\n\n"
53
+ end
54
+ end
55
+
56
+ def print_models_implementation
57
+ @models.each do |model|
58
+ model_name = model[:name].gsub('List', '').gsub('Vo', '').gsub(/^\w/) { $&.upcase } if model[:name]
59
+ puts "@implementation #{@model_pre_name}#{model_name}Model"
60
+ puts "+(NSDictionary *)modelContainerPropertyGenericClass {"
61
+ puts " return @{@\"#{model[:name]}\" : #{@model_pre_name}#{model_name}Model.class};"
62
+ puts "}"
63
+ puts "@end\n\n\n"
64
+ end
65
+ end
66
+
67
+ def print_property(key, value)
68
+ if value.instance_of? String
69
+ puts "///#{value}"
70
+ puts "@property (nonatomic, copy) NSString *#{key};"
71
+ elsif value.instance_of? Integer
72
+ puts "///#{value}"
73
+ puts "@property (nonatomic, assign) NSInteger #{key};"
74
+ puts "///#{value}" if value > 1000
75
+ puts "@property (nonatomic, strong) MLCentNumber *#{key};" if value > 1000
76
+ elsif value.instance_of? Float
77
+ puts "///#{value}"
78
+ puts "@property (nonatomic, assign) CGFloat #{key};"
79
+ elsif (value.instance_of? TrueClass) || (value.instance_of? FalseClass)
80
+ puts "///#{value}"
81
+ puts "@property (nonatomic, assign) BOOL #{key};"
82
+ elsif value.instance_of? Array
83
+ if value.first.instance_of? String
84
+ puts "///#{key}"
85
+ puts "@property (nonatomic, strong) NSArray<NSString *> *#{key};"
86
+ else
87
+ puts "///#{key}"
88
+ name = key.gsub('List', '').gsub('Vo', '').gsub(/^\w/) { $&.upcase }
89
+ puts "@property (nonatomic, strong) NSArray<#{@model_pre_name}#{name}Model *> *#{key};"
90
+ end
91
+ elsif value.instance_of? Hash
92
+ puts "///#{key}"
93
+ name = key.gsub('List', '').gsub('Vo', '').gsub(/^\w/) { $&.upcase }
94
+ puts "@property (nonatomic, strong) #{@model_pre_name}#{name}Model *#{key};"
95
+ else
96
+ puts "///#{value}"
97
+ puts "@property (nonatomic, copy) NSString *#{key};"
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'find'
4
+ require 'fileutils'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class ReverseImport < Bin
10
+ self.summary = '更改头文件引入'
11
+
12
+ def initialize(argv)
13
+ @current_path = argv.shift_argument || Dir.pwd
14
+ @framework_names = []
15
+ super
16
+ end
17
+
18
+ def run
19
+ get_all_frameworks
20
+ get_import_headers
21
+ end
22
+
23
+ def get_import_headers
24
+ Dir.glob("#{@current_path}/**/*.{m,h,pch}").each do |f|
25
+ header_handler_file(f) unless f =~ /Pods/
26
+ end
27
+ end
28
+
29
+ def get_all_frameworks
30
+ folders = child_dir
31
+ folders.each { |name| @framework_names << name }
32
+ end
33
+
34
+ def framework_name_reg
35
+ @url_key_reg ||= begin
36
+ keys = @framework_names.join('|')
37
+ /#{keys}/
38
+ end
39
+ @url_key_reg
40
+ end
41
+
42
+ def pod_folder_name
43
+ File.join(@current_path, 'MacauLife', 'CustomPods')
44
+ end
45
+
46
+ def child_dir
47
+ dirs = Dir.entries(pod_folder_name)
48
+ dirs.reject!{ |d| File.directory?(d) }
49
+ dirs
50
+ end
51
+
52
+ def import_reg
53
+ /#import\s*<(.*)\/(.*)>$/
54
+ end
55
+
56
+ def header_handler_file(f)
57
+ str = ''
58
+ File.readlines(f).each do |l|
59
+ if import_reg =~ l
60
+ ma = l.match(import_reg)
61
+ if framework_name_reg =~ ma[1]
62
+ str += "#import \"#{ma[2]}\"\n"
63
+ else
64
+ str += l.dup
65
+ end
66
+ else
67
+ str += l.dup
68
+ end
69
+ end
70
+ File.write(f, str)
71
+ end
72
+
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,108 @@
1
+ module Pod
2
+ class Command
3
+ class Bin < Command
4
+ class View < Bin
5
+ self.summary = '生成源码'
6
+
7
+ def initialize(argv)
8
+ @name = argv.option('name', 'titleLabel')
9
+ @type = argv.option('type', 'UILabel')
10
+ end
11
+
12
+ def names
13
+ @name.split(",").map(&:strip)
14
+ end
15
+
16
+ def run
17
+ print_declare
18
+ puts "\n\n"
19
+ print_instance
20
+ puts "\n\n"
21
+ print_layout
22
+ puts "\n\n"
23
+ print_value
24
+ end
25
+
26
+ def print_declare
27
+ names.each do |name|
28
+ puts "///"
29
+ puts "@property (nonatomic, strong) #{@type} *#{name};"
30
+ end
31
+ end
32
+
33
+ def print_instance
34
+ names.each do |name|
35
+ puts "-(#{@type} *)#{name}"
36
+ puts "{"
37
+ puts " if(!_#{name}){"
38
+ print_alloc(name)
39
+ puts " _#{name}.translatesAutoresizingMaskIntoConstraints = NO;"
40
+ print_property(name)
41
+ puts " }"
42
+ puts " return _#{name};"
43
+ puts "}"
44
+ puts "\n"
45
+ end
46
+ end
47
+
48
+ def print_alloc(name)
49
+ if @type.eql?('UIImageView')
50
+ puts " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
51
+ elsif @type.eql?('UIButton')
52
+ puts " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
53
+ else
54
+ puts " _#{name} = [[#{@type} alloc] init];"
55
+ end
56
+ end
57
+
58
+ def print_property(name)
59
+ if @type.eql?('UILabel')
60
+ puts " _#{name}.textColor = kSetCOLOR(0x333333);"
61
+ puts " _#{name}.text = @\"xxxxxxxx\";"
62
+ puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
63
+ puts " _#{name}.textAlignment = NSTextAlignmentCenter;"
64
+ elsif @type.eql?('UIImageView')
65
+ puts " _#{name}.backgroundColor = kBackgroundColor;"
66
+ puts " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
67
+ puts " _#{name}.clipsToBounds = YES;"
68
+ puts " _#{name}.layer.cornerRadius = 6.0f;"
69
+ puts " _#{name}.layer.borderColor = kLineColor.CGColor;"
70
+ puts " _#{name}.layer.borderWidth = 0.5;"
71
+ elsif @type.eql?('UITextField')
72
+ puts " _#{name}.textColor = kSetCOLOR(0x333333);"
73
+ puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
74
+ elsif @type.eql?('UIView')
75
+ puts " _#{name}.backgroundColor = kBackgroundColor;"
76
+ elsif @type.eql?('UIButton')
77
+ puts " _#{name}.backgroundColor = kBackgroundColor;"
78
+ puts " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
79
+ puts " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
80
+ puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateNormal];"
81
+ puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateSelected];"
82
+ puts " [_#{name} addTarget:self action:@selector(actionHandler:) forControlEvents:UIControlEventTouchUpInside];"
83
+ end
84
+ end
85
+
86
+ def print_layout
87
+ names.each do |name|
88
+ puts "[contentView addSubview:self.#{name}];"
89
+ puts "[self.#{name}.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor constant:0].active = YES;"
90
+ puts "[self.#{name}.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:0].active = YES;"
91
+ puts "[self.#{name}.topAnchor constraintEqualToAnchor:contentView.topAnchor].active = YES;"
92
+ puts "[self.#{name}.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor].active = YES;"
93
+ puts "\n\n"
94
+ end
95
+ end
96
+
97
+ def print_value
98
+ names.each do |name|
99
+ if @type.eql?('UILabel')
100
+ puts "self.#{name}.text = @\"xxxxx\";"
101
+ end
102
+ end
103
+ end
104
+
105
+ end
106
+ end
107
+ end
108
+ end
@@ -33,11 +33,16 @@ module CBin
33
33
  end
34
34
 
35
35
  def load_config
36
- if File.exist?(config_file)
37
- YAML.load_file(config_file)
38
- else
39
- default_config
40
- end
36
+ syn_config_file unless File.exist?(config_file)
37
+ YAML.load_file(config_file)
38
+ end
39
+
40
+ def get_col_by_name(file_name, col_name = 'csv_key_col')
41
+ m = config
42
+ col = m[col_name]
43
+ fo = m['read_targets'].find{ |o| /#{o['csv_file']}/ =~ file_name }
44
+ col = fo[col_name] if fo
45
+ col
41
46
  end
42
47
 
43
48
  def config
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.17'
3
3
  end
4
4
 
5
5
  module Pod
@@ -19,8 +19,8 @@ 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)
22
+ def down_load(key, file, &block)
23
+ @bucket.get_object(key, :file => file, &block)
24
24
  end
25
25
 
26
26
  def object_url(key)
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.12
4
+ version: 0.1.17
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-24 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -122,13 +122,16 @@ files:
122
122
  - lib/cocoapods-lhj-bin/command/bin/local/local.rb
123
123
  - lib/cocoapods-lhj-bin/command/bin/local/micro_service.rb
124
124
  - lib/cocoapods-lhj-bin/command/bin/local/upload.rb
125
+ - lib/cocoapods-lhj-bin/command/bin/model.rb
125
126
  - lib/cocoapods-lhj-bin/command/bin/oss/del.rb
126
127
  - lib/cocoapods-lhj-bin/command/bin/oss/list.rb
127
128
  - lib/cocoapods-lhj-bin/command/bin/repo/update.rb
129
+ - lib/cocoapods-lhj-bin/command/bin/reverse_import.rb
128
130
  - lib/cocoapods-lhj-bin/command/bin/spec/create.rb
129
131
  - lib/cocoapods-lhj-bin/command/bin/spec/push.rb
130
132
  - lib/cocoapods-lhj-bin/command/bin/trans.rb
131
133
  - lib/cocoapods-lhj-bin/command/bin/update.rb
134
+ - lib/cocoapods-lhj-bin/command/bin/view.rb
132
135
  - lib/cocoapods-lhj-bin/config/config.rb
133
136
  - lib/cocoapods-lhj-bin/config/config_asker.rb
134
137
  - lib/cocoapods-lhj-bin/config/config_builder.rb