cocoapods-aomi-bin 0.1.24 → 0.1.28
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: 8b23d08fce41cc6477f55bbb2267d4cb01bb47666db21271ab088eb05d927561
|
4
|
+
data.tar.gz: c1de98fd28db066db52b352dc0aa67f2a54d097d43ff4c1387196a6e6acd173a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ea5d910bc3810d784ce7e44ace8f44a16fc44942b53bb9db36b27b5d42ea397ba494909f2d8b0468f716f1626fad20a7d60a23bf2e297116984b99a322d492
|
7
|
+
data.tar.gz: 16708b835b342bef5651e14f359a060eb154ce6b913cca310aa615c5096785f01d05771956cc14cdd7a297fc0a3bd595d245711e2ba7ad58b9055ca0452a6f76
|
@@ -14,6 +14,28 @@ module Pod
|
|
14
14
|
@name.split(",").map(&:strip)
|
15
15
|
end
|
16
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
|
+
|
17
39
|
def run
|
18
40
|
print_declare
|
19
41
|
puts "\n\n"
|
@@ -27,13 +49,13 @@ module Pod
|
|
27
49
|
def print_declare
|
28
50
|
names.each do |name|
|
29
51
|
puts "///"
|
30
|
-
puts "@property (nonatomic, strong) #{
|
52
|
+
puts "@property (nonatomic, strong) #{type} *#{name};"
|
31
53
|
end
|
32
54
|
end
|
33
55
|
|
34
56
|
def print_instance
|
35
57
|
names.each do |name|
|
36
|
-
puts "-(#{
|
58
|
+
puts "-(#{type} *)#{name}"
|
37
59
|
puts "{"
|
38
60
|
puts " if(!_#{name}){"
|
39
61
|
print_alloc(name)
|
@@ -47,46 +69,50 @@ module Pod
|
|
47
69
|
end
|
48
70
|
|
49
71
|
def print_alloc(name)
|
50
|
-
if
|
72
|
+
if type.eql?('UIImageView')
|
51
73
|
puts " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
|
52
|
-
elsif
|
74
|
+
elsif type.eql?('UIButton')
|
53
75
|
puts " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
|
54
|
-
elsif
|
76
|
+
elsif type.eql?('UITableView')
|
55
77
|
puts " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
|
56
78
|
else
|
57
|
-
puts " _#{name} = [[#{
|
79
|
+
puts " _#{name} = [[#{type} alloc] init];"
|
58
80
|
end
|
59
81
|
end
|
60
82
|
|
61
83
|
def print_property(name)
|
62
|
-
if
|
84
|
+
if type.eql?('UILabel')
|
63
85
|
puts " _#{name}.textColor = kSetCOLOR(0x333333);"
|
64
86
|
puts " _#{name}.text = @\"xxxxxxxx\";"
|
65
87
|
puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
66
88
|
puts " _#{name}.textAlignment = NSTextAlignmentCenter;"
|
67
|
-
elsif
|
89
|
+
elsif type.eql?('UIImageView')
|
68
90
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
69
91
|
puts " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
|
70
92
|
puts " _#{name}.clipsToBounds = YES;"
|
71
93
|
puts " _#{name}.layer.cornerRadius = 6.0f;"
|
72
94
|
puts " _#{name}.layer.borderColor = kLineColor.CGColor;"
|
73
95
|
puts " _#{name}.layer.borderWidth = 0.5;"
|
74
|
-
elsif
|
96
|
+
elsif type.eql?('UITextField')
|
75
97
|
puts " _#{name}.textColor = kSetCOLOR(0x333333);"
|
76
98
|
puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
77
|
-
elsif
|
99
|
+
elsif type.eql?('UIView')
|
78
100
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
79
|
-
elsif
|
101
|
+
elsif type.eql?('UIStackView')
|
102
|
+
puts " _#{name}.axis = UILayoutConstraintAxisHorizontal;"
|
103
|
+
puts " _#{name}.distribution = UIStackViewDistributionFillEqually;"
|
104
|
+
elsif type.eql?('UITableView')
|
80
105
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
81
106
|
puts " _#{name}.delegate = self;"
|
82
107
|
puts " _#{name}.delegate = self;"
|
83
108
|
puts " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
84
109
|
puts " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
85
110
|
puts " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
|
86
|
-
elsif
|
111
|
+
elsif type.eql?('UIButton')
|
87
112
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
88
113
|
puts " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
|
89
114
|
puts " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
|
115
|
+
puts " _#{name}.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];"
|
90
116
|
puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateNormal];"
|
91
117
|
puts " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateSelected];"
|
92
118
|
puts " [_#{name} addTarget:self action:@selector(actionHandler:) forControlEvents:UIControlEventTouchUpInside];"
|
@@ -100,13 +126,19 @@ module Pod
|
|
100
126
|
puts "[self.#{name}.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:0].active = YES;"
|
101
127
|
puts "[self.#{name}.topAnchor constraintEqualToAnchor:contentView.topAnchor].active = YES;"
|
102
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;"
|
131
|
+
if type.eql?('UILabel')
|
132
|
+
puts "[self.#{name} setContentHuggingPriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
133
|
+
puts "[self.#{name} setContentCompressionResistancePriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
134
|
+
end
|
103
135
|
puts "\n\n"
|
104
136
|
end
|
105
137
|
end
|
106
138
|
|
107
139
|
def print_value
|
108
140
|
names.each do |name|
|
109
|
-
if
|
141
|
+
if type.eql?('UILabel')
|
110
142
|
puts "self.#{name}.text = @\"xxxxx\";"
|
111
143
|
end
|
112
144
|
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}
|
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
|
-
|
210
|
+
puts_h "@interface #{model_name} : NSObject"
|
180
211
|
model_properties.each do |m|
|
181
212
|
print_model(m)
|
182
213
|
end
|
183
|
-
|
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
|
-
|
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
|
-
|
193
|
-
|
194
|
-
|
223
|
+
puts_m "+(NSDictionary *)modelContainerPropertyGenericClass {"
|
224
|
+
puts_m " return @{#{str}};"
|
225
|
+
puts_m "}"
|
195
226
|
end
|
196
|
-
|
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
|
-
|
239
|
+
puts_h "///#{des} #{default}"
|
208
240
|
if type.eql?('integer')
|
209
|
-
|
241
|
+
puts_h "@property (nonatomic, assign) NSInteger #{key};"
|
210
242
|
if des.include?('分')
|
211
|
-
|
212
|
-
|
243
|
+
puts_h "/////////==========删掉其中一个属性"
|
244
|
+
puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
|
213
245
|
end
|
214
246
|
elsif type.eql?('cent')
|
215
|
-
|
247
|
+
puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
|
216
248
|
elsif type.eql?('string')
|
217
|
-
|
249
|
+
puts_h "@property (nonatomic, copy) NSString *#{key};"
|
218
250
|
elsif type.eql?('number')
|
219
|
-
|
251
|
+
puts_h "@property (nonatomic, strong) NSNumber *#{key};"
|
220
252
|
elsif type.eql?('float')
|
221
|
-
|
253
|
+
puts_h "@property (nonatomic, assign) CGFloat #{key};"
|
222
254
|
elsif type.eql?('double')
|
223
|
-
|
255
|
+
puts_h "@property (nonatomic, assign) double #{key};"
|
224
256
|
elsif type.eql?('boolean')
|
225
|
-
|
257
|
+
puts_h "@property (nonatomic, assign) BOOL #{key};"
|
226
258
|
elsif type.eql?('object')
|
227
|
-
|
259
|
+
puts_h "@property (nonatomic, strong) #{type_name} *#{key};"
|
228
260
|
elsif type.eql?('array')
|
229
|
-
|
261
|
+
puts_h "@property (nonatomic, strong) NSArray<#{type_name} *> *#{key};"
|
230
262
|
else
|
231
|
-
|
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
|
-
|
238
|
-
|
239
|
-
|
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
|
-
|
243
|
-
|
244
|
-
|
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
|
-
|
248
|
-
|
279
|
+
puts_h "///#{des} #{h['example']}"
|
280
|
+
puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
|
249
281
|
end
|
250
|
-
|
282
|
+
puts_h "@end"
|
251
283
|
puts "\n\n"
|
252
284
|
model = @models.last
|
253
285
|
if @data_json['method'].eql?('GET')
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
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
|
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.28
|
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-
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|