cocoapods-aomi-bin 0.1.23 → 0.1.27

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: cb55502492ac052c7d2663e4b045a0b1f6662194621c1f3062a48967d8d0f4e5
4
- data.tar.gz: 9825c8ee973005e7a441f2a7e43868de023c9342ef1c250bdca64c67fb8c3d76
3
+ metadata.gz: ecdcf77ffe789de831f4e640d3088a54e19e6879a1f4fa0654c3a634cda30cd5
4
+ data.tar.gz: e401cb597d909572b6414605f4655fc9498392ac1f991c922e288dfa93dbfbac
5
5
  SHA512:
6
- metadata.gz: 73475f03e293309adf3cb1e639a0dfba8f626d8eda56b5f95b29b39d5df8a7c372b2b3d638b4e9cc106d94f52c542addbf481ce2955ff2d3a291b3dc02621ed6
7
- data.tar.gz: 7dc7519922409b00dca459d9c479050324d5bf2265677b56c29f59914fd9935eec1797587dfcc14385498254a543eaa21b4ac403986fd325bf059af3e83c993f
6
+ metadata.gz: 4b70ea18250659f69e835e25a3de288fa94e043ce5d217e08e6448e411277ad32be606471b06b09f5d714c635e282290946ad45c9db6c15b58cba4514a10d487
7
+ data.tar.gz: 1db2b61c886c530cdfa04f236a04dacc010a1c95e7481babbd4623ee63203a91dc1534ecc20950cc91c6e686c9579016091e5d7bd1787eb9dfe7819c67c37b29
@@ -7,12 +7,35 @@ module Pod
7
7
  def initialize(argv)
8
8
  @name = argv.option('name', 'titleLabel')
9
9
  @type = argv.option('type', 'UILabel')
10
+ super
10
11
  end
11
12
 
12
13
  def names
13
14
  @name.split(",").map(&:strip)
14
15
  end
15
16
 
17
+ def type
18
+ @ele_type ||= begin
19
+ if @type =~ /image/i
20
+ 'UIImageView'
21
+ elsif @type =~ /stack/i
22
+ 'UIStackView'
23
+ elsif @type =~ /label/i
24
+ 'UILabel'
25
+ elsif @type =~ /table/i
26
+ 'UITableView'
27
+ elsif @type =~ /text/i
28
+ 'UITextField'
29
+ elsif @type =~ /button/i
30
+ 'UIButton'
31
+ elsif @type =~ /view/i
32
+ 'UIView'
33
+ else
34
+ @type
35
+ end
36
+ end
37
+ end
38
+
16
39
  def run
17
40
  print_declare
18
41
  puts "\n\n"
@@ -26,13 +49,13 @@ module Pod
26
49
  def print_declare
27
50
  names.each do |name|
28
51
  puts "///"
29
- puts "@property (nonatomic, strong) #{@type} *#{name};"
52
+ puts "@property (nonatomic, strong) #{type} *#{name};"
30
53
  end
31
54
  end
32
55
 
33
56
  def print_instance
34
57
  names.each do |name|
35
- puts "-(#{@type} *)#{name}"
58
+ puts "-(#{type} *)#{name}"
36
59
  puts "{"
37
60
  puts " if(!_#{name}){"
38
61
  print_alloc(name)
@@ -46,46 +69,50 @@ module Pod
46
69
  end
47
70
 
48
71
  def print_alloc(name)
49
- if @type.eql?('UIImageView')
72
+ if type.eql?('UIImageView')
50
73
  puts " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
51
- elsif @type.eql?('UIButton')
74
+ elsif type.eql?('UIButton')
52
75
  puts " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
53
- elsif @type.eql?('UITableView')
76
+ elsif type.eql?('UITableView')
54
77
  puts " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
55
78
  else
56
- puts " _#{name} = [[#{@type} alloc] init];"
79
+ puts " _#{name} = [[#{type} alloc] init];"
57
80
  end
58
81
  end
59
82
 
60
83
  def print_property(name)
61
- if @type.eql?('UILabel')
84
+ if type.eql?('UILabel')
62
85
  puts " _#{name}.textColor = kSetCOLOR(0x333333);"
63
86
  puts " _#{name}.text = @\"xxxxxxxx\";"
64
87
  puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
65
88
  puts " _#{name}.textAlignment = NSTextAlignmentCenter;"
66
- elsif @type.eql?('UIImageView')
89
+ elsif type.eql?('UIImageView')
67
90
  puts " _#{name}.backgroundColor = kBackgroundColor;"
68
91
  puts " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
69
92
  puts " _#{name}.clipsToBounds = YES;"
70
93
  puts " _#{name}.layer.cornerRadius = 6.0f;"
71
94
  puts " _#{name}.layer.borderColor = kLineColor.CGColor;"
72
95
  puts " _#{name}.layer.borderWidth = 0.5;"
73
- elsif @type.eql?('UITextField')
96
+ elsif type.eql?('UITextField')
74
97
  puts " _#{name}.textColor = kSetCOLOR(0x333333);"
75
98
  puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
76
- elsif @type.eql?('UIView')
99
+ elsif type.eql?('UIView')
77
100
  puts " _#{name}.backgroundColor = kBackgroundColor;"
78
- elsif @type.eql?('UITableView')
101
+ elsif type.eql?('UIStackView')
102
+ puts " _#{name}.axis = UILayoutConstraintAxisHorizontal;"
103
+ puts " _#{name}.distribution = UIStackViewDistributionFillEqually;"
104
+ elsif type.eql?('UITableView')
79
105
  puts " _#{name}.backgroundColor = kBackgroundColor;"
80
106
  puts " _#{name}.delegate = self;"
81
107
  puts " _#{name}.delegate = self;"
82
108
  puts " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
83
109
  puts " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
84
110
  puts " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
85
- elsif @type.eql?('UIButton')
111
+ elsif type.eql?('UIButton')
86
112
  puts " _#{name}.backgroundColor = kBackgroundColor;"
87
113
  puts " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
88
114
  puts " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
115
+ puts " _#{name}.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];"
89
116
  puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateNormal];"
90
117
  puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateSelected];"
91
118
  puts " [_#{name} addTarget:self action:@selector(actionHandler:) forControlEvents:UIControlEventTouchUpInside];"
@@ -99,13 +126,15 @@ module Pod
99
126
  puts "[self.#{name}.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:0].active = YES;"
100
127
  puts "[self.#{name}.topAnchor constraintEqualToAnchor:contentView.topAnchor].active = YES;"
101
128
  puts "[self.#{name}.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor].active = YES;"
129
+ puts "[self.#{name}.widthAnchor constraintEqualToConstant:80].active = YES;"
130
+ puts "[self.#{name}.heightAnchor constraintEqualToConstant:80].active = YES;"
102
131
  puts "\n\n"
103
132
  end
104
133
  end
105
134
 
106
135
  def print_value
107
136
  names.each do |name|
108
- if @type.eql?('UILabel')
137
+ if type.eql?('UILabel')
109
138
  puts "self.#{name}.text = @\"xxxxx\";"
110
139
  end
111
140
  end
@@ -11,19 +11,22 @@ module Pod
11
11
  def self.options
12
12
  [
13
13
  %w[--id api的id],
14
- %w[--model-pre 模型的前缀]
14
+ %w[--model-pre 模型的前缀],
15
+ %w[--save 保存生成文件]
15
16
  ]
16
17
  end
17
18
 
18
19
  def initialize(argv)
19
20
  @id = argv.option('id')
20
21
  @model_pre_name = argv.option('model-pre')
22
+ @save = argv.flag?('save', false)
21
23
  @http_url = ''
22
24
  @http_headers = []
23
25
  @data_json = {}
24
26
  @models = []
25
27
  @config_id = ''
26
28
  @config_model_pre = 'ML'
29
+ @model_default_suffix = 'Model'
27
30
  @type_trans = {}
28
31
  @config_model_names = []
29
32
  @model_names = []
@@ -34,6 +37,7 @@ module Pod
34
37
  load_config
35
38
  fetch_model
36
39
  print_methods
40
+ save_to_file if @save
37
41
  end
38
42
 
39
43
  def test_ding
@@ -43,6 +47,28 @@ module Pod
43
47
  Net::HTTP.post(URI('https://oapi.dingtalk.com/robot/send?access_token=6a3519057170cdb1b7274edfe43934c84a0062ffe2c9bcced434699296a7e26e'), body, "Content-Type" => "application/json")
44
48
  end
45
49
 
50
+ def puts_h(str)
51
+ puts str
52
+ @h_file_array ||= []
53
+ @h_file_array << str
54
+ end
55
+
56
+ def puts_m(str)
57
+ puts str
58
+ @m_file_array ||= []
59
+ @m_file_array << str
60
+ end
61
+
62
+ def save_to_file
63
+ @model_names = []
64
+ file_name = gen_model_name('')
65
+ h_file = File.join('.', "#{file_name}.h")
66
+ m_file = File.join('.', "#{file_name}.m")
67
+ File.write(h_file, @h_file_array.join("\n")) if @h_file_array.count > 0
68
+ File.write(m_file, @m_file_array.join("\n")) if @m_file_array.count > 0
69
+ puts "\n\n生成文件成功!所在路径:\n#{File.expand_path(h_file)} \n#{File.expand_path(m_file)}"
70
+ end
71
+
46
72
  def url_str
47
73
  "#{@http_url}#{api_id}"
48
74
  end
@@ -56,6 +82,7 @@ module Pod
56
82
  @http_url = config['url']
57
83
  @config_id = config['id']
58
84
  @config_model_pre = config['model_pre']
85
+ @config_model_suffix = config['model_suffix']
59
86
  @config_model_names = config['model_names']
60
87
  @type_trans = config['type_trans']
61
88
  end
@@ -68,6 +95,10 @@ module Pod
68
95
  @model_pre_name || @config_model_pre
69
96
  end
70
97
 
98
+ def model_suffix
99
+ @config_model_suffix || @model_default_suffix
100
+ end
101
+
71
102
  def req_model
72
103
  uri = URI.parse(url_str)
73
104
  req = Net::HTTP::Get.new(uri)
@@ -135,7 +166,7 @@ module Pod
135
166
  if n.length <= 0
136
167
  n = @config_model_names.detect{ |c| !@model_names.any?{ |n| n.gsub(/#{model_pre}(.*)Model/, '\1').eql?(c) } }
137
168
  end
138
- model_name = "#{model_pre}#{n}Model"
169
+ model_name = "#{model_pre}#{n}#{model_suffix}"
139
170
  @model_names << model_name
140
171
  model_name
141
172
  end
@@ -176,24 +207,25 @@ module Pod
176
207
  @models.each do |model|
177
208
  model_name = model[:name] || ''
178
209
  model_properties = model[:properties]
179
- puts "@interface #{model_name} : NSObject"
210
+ puts_h "@interface #{model_name} : NSObject"
180
211
  model_properties.each do |m|
181
212
  print_model(m)
182
213
  end
183
- puts "@end\n\n\n"
214
+ puts_h "@end\n\n\n"
184
215
  end
185
216
  end
186
217
 
187
218
  def print_models_implementation
188
219
  @models.each do |model|
189
- puts "@implementation #{model[:name]}"
220
+ puts_m "@implementation #{model[:name]}"
190
221
  str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map{ |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
191
222
  if str && str.length > 0
192
- puts "+(NSDictionary *)modelContainerPropertyGenericClass {"
193
- puts " return @{#{str}};"
194
- puts "}"
223
+ puts_m "+(NSDictionary *)modelContainerPropertyGenericClass {"
224
+ puts_m " return @{#{str}};"
225
+ puts_m "}"
195
226
  end
196
- puts "@end\n\n\n"
227
+ puts_m "@end\n"
228
+ puts "\n\n"
197
229
  end
198
230
  end
199
231
 
@@ -204,66 +236,66 @@ module Pod
204
236
  des = m[:description] || ''
205
237
  des.gsub!(/\n/, ' ')
206
238
  default = m[:default]
207
- puts "///#{des} #{default}"
239
+ puts_h "///#{des} #{default}"
208
240
  if type.eql?('integer')
209
- puts "@property (nonatomic, assign) NSInteger #{key};"
241
+ puts_h "@property (nonatomic, assign) NSInteger #{key};"
210
242
  if des.include?('分')
211
- puts "/////////==========删掉其中一个属性"
212
- puts "@property (nonatomic, strong) MLCentNumber *#{key};"
243
+ puts_h "/////////==========删掉其中一个属性"
244
+ puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
213
245
  end
214
246
  elsif type.eql?('cent')
215
- puts "@property (nonatomic, strong) MLCentNumber *#{key};"
247
+ puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
216
248
  elsif type.eql?('string')
217
- puts "@property (nonatomic, copy) NSString *#{key};"
249
+ puts_h "@property (nonatomic, copy) NSString *#{key};"
218
250
  elsif type.eql?('number')
219
- puts "@property (nonatomic, strong) NSNumber *#{key};"
251
+ puts_h "@property (nonatomic, strong) NSNumber *#{key};"
220
252
  elsif type.eql?('float')
221
- puts "@property (nonatomic, assign) CGFloat #{key};"
253
+ puts_h "@property (nonatomic, assign) CGFloat #{key};"
222
254
  elsif type.eql?('double')
223
- puts "@property (nonatomic, assign) double #{key};"
255
+ puts_h "@property (nonatomic, assign) double #{key};"
224
256
  elsif type.eql?('boolean')
225
- puts "@property (nonatomic, assign) BOOL #{key};"
257
+ puts_h "@property (nonatomic, assign) BOOL #{key};"
226
258
  elsif type.eql?('object')
227
- puts "@property (nonatomic, strong) #{type_name} *#{key};"
259
+ puts_h "@property (nonatomic, strong) #{type_name} *#{key};"
228
260
  elsif type.eql?('array')
229
- puts "@property (nonatomic, strong) NSArray<#{type_name} *> *#{key};"
261
+ puts_h "@property (nonatomic, strong) NSArray<#{type_name} *> *#{key};"
230
262
  else
231
- puts "@property (nonatomic, copy) NSString *#{key};"
263
+ puts_h "@property (nonatomic, copy) NSString *#{key};"
232
264
  end
233
265
  end
234
266
 
235
267
  def print_methods
236
268
  puts "\n<===============方法调用=====================>\n"
237
- puts "/**"
238
- puts " * #{@data_json['title']} -- #{@data_json['username']}"
239
- puts " */"
269
+ puts_m "/**"
270
+ puts_m " * #{@data_json['title']} -- #{@data_json['username']}"
271
+ puts_m " */"
240
272
  key_str = @data_json['path'].split('/').map{ |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/){ $&.upcase } }.join('')
241
273
  key = "k#{key_str}URL"
242
- puts "static NSString * const #{key} = @\"#{@data_json['path']}\";"
243
- puts "\n\n"
244
- puts "@interface MLParamModel : NSObject"
274
+ puts_m "static NSString * const #{key} = @\"#{@data_json['path']}\";"
275
+ puts_m "\n\n"
276
+ puts_h "@interface MLParamModel : NSObject"
245
277
  @data_json['req_query'].each do |h|
246
278
  des = h['desc'].gsub(/\n/, ' ')
247
- puts "///#{des} #{h['example']}"
248
- puts "@property (nonatomic, copy) NSString *#{h['name']};"
279
+ puts_h "///#{des} #{h['example']}"
280
+ puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
249
281
  end
250
- puts "@end"
282
+ puts_h "@end"
251
283
  puts "\n\n"
252
284
  model = @models.last
253
285
  if @data_json['method'].eql?('GET')
254
- puts " [MLNetworkingManager getWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
255
- puts " if (response.resultCode == 0 && !response.error){"
256
- puts " NSDictionary *detailMsg = response.detailMsg"
257
- puts " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
258
- puts " }"
259
- puts " }];"
286
+ puts_m " [MLNetworkingManager getWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
287
+ puts_m " if (response.resultCode == 0 && !response.error){"
288
+ puts_m " NSDictionary *detailMsg = response.detailMsg"
289
+ puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
290
+ puts_m " }"
291
+ puts_m " }];"
260
292
  else
261
- puts " [MLNetworkingManager postWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
262
- puts " if (response.resultCode == 0 && !response.error){"
263
- puts " NSDictionary *detailMsg = response.detailMsg"
264
- puts " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
265
- puts " }"
266
- puts " }];"
293
+ puts_m " [MLNetworkingManager postWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
294
+ puts_m " if (response.resultCode == 0 && !response.error){"
295
+ puts_m " NSDictionary *detailMsg = response.detailMsg"
296
+ puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
297
+ puts_m " }"
298
+ puts_m " }];"
267
299
  end
268
300
  end
269
301
  end
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = '0.1.23'
2
+ VERSION = '0.1.27'
3
3
  end
4
4
 
5
5
  module Pod
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.23
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods