cocoapods-aomi-bin 0.1.20 → 0.1.25
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72a18bc0c3ba9a0e31de6af984a1d07c7def7f70249941dd6a925dfe71d1fe6d
|
4
|
+
data.tar.gz: f1fea909529eab507e62af72b609d2d583f553d4d10983868a98e9e1c1b98b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd64cd26ca405e69ab574db311279bf03f1790459ee585345cc562caddce8c2f0d0b8cd237891bc79475cb4d8c9377f5c13672c25eab71539c7661cd9d91672
|
7
|
+
data.tar.gz: 83cd6c1b564ceb748ec102d23c981bf941dada6bc47c3e3ef955a7eb2c84e271ec4a36f484ea153b1dae213b3c11a55028b56f68a45c6d5f73af3d36cf0427fd
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/https'
|
2
2
|
require 'uri'
|
3
3
|
require 'json'
|
4
|
+
require 'plist'
|
4
5
|
|
5
6
|
module Pod
|
6
7
|
class Command
|
@@ -15,6 +16,20 @@ module Pod
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def run
|
19
|
+
gen_model
|
20
|
+
# handle_plist
|
21
|
+
end
|
22
|
+
|
23
|
+
def handle_plist
|
24
|
+
entitlements_file = File.expand_path('~/config.plist')
|
25
|
+
result = Plist.parse_xml(entitlements_file)
|
26
|
+
result.delete('com.apple.security.application-groups')
|
27
|
+
result['type'] = '0'
|
28
|
+
result.delete('version')
|
29
|
+
result.save_plist(entitlements_file)
|
30
|
+
end
|
31
|
+
|
32
|
+
def gen_model
|
18
33
|
model = fetch_model
|
19
34
|
fetch_models(nil, model) if model
|
20
35
|
print_models
|
@@ -7,6 +7,7 @@ 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
|
@@ -50,6 +51,8 @@ module Pod
|
|
50
51
|
puts " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
|
51
52
|
elsif @type.eql?('UIButton')
|
52
53
|
puts " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
|
54
|
+
elsif @type.eql?('UITableView')
|
55
|
+
puts " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
|
53
56
|
else
|
54
57
|
puts " _#{name} = [[#{@type} alloc] init];"
|
55
58
|
end
|
@@ -73,6 +76,13 @@ module Pod
|
|
73
76
|
puts " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
74
77
|
elsif @type.eql?('UIView')
|
75
78
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
79
|
+
elsif @type.eql?('UITableView')
|
80
|
+
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
81
|
+
puts " _#{name}.delegate = self;"
|
82
|
+
puts " _#{name}.delegate = self;"
|
83
|
+
puts " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
84
|
+
puts " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
85
|
+
puts " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
|
76
86
|
elsif @type.eql?('UIButton')
|
77
87
|
puts " _#{name}.backgroundColor = kBackgroundColor;"
|
78
88
|
puts " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
|
@@ -8,9 +8,18 @@ module Pod
|
|
8
8
|
class Yapi < Bin
|
9
9
|
self.summary = '通过yapi接口生成请求'
|
10
10
|
|
11
|
+
def self.options
|
12
|
+
[
|
13
|
+
%w[--id api的id],
|
14
|
+
%w[--model-pre 模型的前缀],
|
15
|
+
%w[--save 保存生成文件]
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
11
19
|
def initialize(argv)
|
12
20
|
@id = argv.option('id')
|
13
21
|
@model_pre_name = argv.option('model-pre')
|
22
|
+
@save = argv.flag?('save', false)
|
14
23
|
@http_url = ''
|
15
24
|
@http_headers = []
|
16
25
|
@data_json = {}
|
@@ -20,14 +29,43 @@ module Pod
|
|
20
29
|
@type_trans = {}
|
21
30
|
@config_model_names = []
|
22
31
|
@model_names = []
|
32
|
+
super
|
23
33
|
end
|
24
34
|
|
25
35
|
def run
|
26
36
|
load_config
|
27
37
|
fetch_model
|
28
|
-
print_models
|
29
|
-
print_models_implementation
|
30
38
|
print_methods
|
39
|
+
save_to_file if @save
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_ding
|
43
|
+
require 'net/http'
|
44
|
+
require 'uri'
|
45
|
+
body = { "msgtype" => "text", "text" => { "content" => "error:上传蒲公英超时失败!" } }.to_json
|
46
|
+
Net::HTTP.post(URI('https://oapi.dingtalk.com/robot/send?access_token=6a3519057170cdb1b7274edfe43934c84a0062ffe2c9bcced434699296a7e26e'), body, "Content-Type" => "application/json")
|
47
|
+
end
|
48
|
+
|
49
|
+
def puts_h(str)
|
50
|
+
puts str
|
51
|
+
@h_file_array ||= []
|
52
|
+
@h_file_array << str
|
53
|
+
end
|
54
|
+
|
55
|
+
def puts_m(str)
|
56
|
+
puts str
|
57
|
+
@m_file_array ||= []
|
58
|
+
@m_file_array << str
|
59
|
+
end
|
60
|
+
|
61
|
+
def save_to_file
|
62
|
+
@model_names = []
|
63
|
+
file_name = gen_model_name('')
|
64
|
+
h_file = File.join('.', "#{file_name}.h")
|
65
|
+
m_file = File.join('.', "#{file_name}.m")
|
66
|
+
File.write(h_file, @h_file_array.join("\n")) if @h_file_array.count > 0
|
67
|
+
File.write(m_file, @m_file_array.join("\n")) if @m_file_array.count > 0
|
68
|
+
puts "\n\n生成文件成功!所在路径:\n#{File.expand_path(h_file)} \n#{File.expand_path(m_file)}"
|
31
69
|
end
|
32
70
|
|
33
71
|
def url_str
|
@@ -68,6 +106,25 @@ module Pod
|
|
68
106
|
|
69
107
|
def fetch_model
|
70
108
|
res_json = req_model
|
109
|
+
begin
|
110
|
+
puts "\n<===============打印返回数据模型-Begin=====================>\n"
|
111
|
+
fetch_res_boy(res_json)
|
112
|
+
print_models
|
113
|
+
print_models_implementation
|
114
|
+
puts "\n<===============打印返回数据模型-End=====================>\n"
|
115
|
+
end
|
116
|
+
begin
|
117
|
+
puts "\n<===============打印请求模型-Begin=====================>\n"
|
118
|
+
@models = []
|
119
|
+
@model_names = []
|
120
|
+
fetch_req_body(res_json)
|
121
|
+
print_models
|
122
|
+
print_models_implementation
|
123
|
+
puts "\n<===============打印请求模型-End=====================>\n"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def fetch_res_boy(res_json)
|
71
128
|
if res_json && res_json['data']
|
72
129
|
@data_json = res_json['data']
|
73
130
|
if @data_json['res_body']
|
@@ -83,6 +140,21 @@ module Pod
|
|
83
140
|
end
|
84
141
|
end
|
85
142
|
|
143
|
+
def fetch_req_body(res_json)
|
144
|
+
if res_json && res_json['data']
|
145
|
+
@data_json = res_json['data']
|
146
|
+
if @data_json['req_body_other']
|
147
|
+
begin
|
148
|
+
res_body = JSON.parse(@data_json['req_body_other'])
|
149
|
+
res_body['name'] = gen_model_name('')
|
150
|
+
handle_model(res_body)
|
151
|
+
rescue => ex
|
152
|
+
puts ex
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
86
158
|
def gen_model_name(name)
|
87
159
|
n = name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) { $&.upcase }
|
88
160
|
if n.length <= 0
|
@@ -126,28 +198,28 @@ module Pod
|
|
126
198
|
end
|
127
199
|
|
128
200
|
def print_models
|
129
|
-
puts "\n<===============打印模型=====================>\n"
|
130
201
|
@models.each do |model|
|
131
202
|
model_name = model[:name] || ''
|
132
203
|
model_properties = model[:properties]
|
133
|
-
|
204
|
+
puts_h "@interface #{model_name} : NSObject"
|
134
205
|
model_properties.each do |m|
|
135
206
|
print_model(m)
|
136
207
|
end
|
137
|
-
|
208
|
+
puts_h "@end\n\n\n"
|
138
209
|
end
|
139
210
|
end
|
140
211
|
|
141
212
|
def print_models_implementation
|
142
213
|
@models.each do |model|
|
143
|
-
|
214
|
+
puts_m "@implementation #{model[:name]}"
|
144
215
|
str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map{ |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
|
145
216
|
if str && str.length > 0
|
146
|
-
|
147
|
-
|
148
|
-
|
217
|
+
puts_m "+(NSDictionary *)modelContainerPropertyGenericClass {"
|
218
|
+
puts_m " return @{#{str}};"
|
219
|
+
puts_m "}"
|
149
220
|
end
|
150
|
-
|
221
|
+
puts_m "@end\n"
|
222
|
+
puts "\n\n"
|
151
223
|
end
|
152
224
|
end
|
153
225
|
|
@@ -156,63 +228,68 @@ module Pod
|
|
156
228
|
type_name = m[:type_name]
|
157
229
|
type = m[:type]
|
158
230
|
des = m[:description] || ''
|
159
|
-
des.gsub!(/\n/, '')
|
231
|
+
des.gsub!(/\n/, ' ')
|
160
232
|
default = m[:default]
|
161
|
-
|
233
|
+
puts_h "///#{des} #{default}"
|
162
234
|
if type.eql?('integer')
|
163
|
-
|
235
|
+
puts_h "@property (nonatomic, assign) NSInteger #{key};"
|
236
|
+
if des.include?('分')
|
237
|
+
puts_h "/////////==========删掉其中一个属性"
|
238
|
+
puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
|
239
|
+
end
|
164
240
|
elsif type.eql?('cent')
|
165
|
-
|
241
|
+
puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
|
166
242
|
elsif type.eql?('string')
|
167
|
-
|
243
|
+
puts_h "@property (nonatomic, copy) NSString *#{key};"
|
168
244
|
elsif type.eql?('number')
|
169
|
-
|
245
|
+
puts_h "@property (nonatomic, strong) NSNumber *#{key};"
|
170
246
|
elsif type.eql?('float')
|
171
|
-
|
247
|
+
puts_h "@property (nonatomic, assign) CGFloat #{key};"
|
172
248
|
elsif type.eql?('double')
|
173
|
-
|
249
|
+
puts_h "@property (nonatomic, assign) double #{key};"
|
174
250
|
elsif type.eql?('boolean')
|
175
|
-
|
251
|
+
puts_h "@property (nonatomic, assign) BOOL #{key};"
|
176
252
|
elsif type.eql?('object')
|
177
|
-
|
253
|
+
puts_h "@property (nonatomic, strong) #{type_name} *#{key};"
|
178
254
|
elsif type.eql?('array')
|
179
|
-
|
255
|
+
puts_h "@property (nonatomic, strong) NSArray<#{type_name} *> *#{key};"
|
180
256
|
else
|
181
|
-
|
257
|
+
puts_h "@property (nonatomic, copy) NSString *#{key};"
|
182
258
|
end
|
183
259
|
end
|
184
260
|
|
185
261
|
def print_methods
|
186
262
|
puts "\n<===============方法调用=====================>\n"
|
187
|
-
|
188
|
-
|
189
|
-
|
263
|
+
puts_m "/**"
|
264
|
+
puts_m " * #{@data_json['title']} -- #{@data_json['username']}"
|
265
|
+
puts_m " */"
|
190
266
|
key_str = @data_json['path'].split('/').map{ |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/){ $&.upcase } }.join('')
|
191
267
|
key = "k#{key_str}URL"
|
192
|
-
|
193
|
-
|
194
|
-
|
268
|
+
puts_m "static NSString * const #{key} = @\"#{@data_json['path']}\";"
|
269
|
+
puts_m "\n\n"
|
270
|
+
puts_h "@interface MLParamModel : NSObject"
|
195
271
|
@data_json['req_query'].each do |h|
|
196
|
-
|
197
|
-
|
272
|
+
des = h['desc'].gsub(/\n/, ' ')
|
273
|
+
puts_h "///#{des} #{h['example']}"
|
274
|
+
puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
|
198
275
|
end
|
199
|
-
|
276
|
+
puts_h "@end"
|
200
277
|
puts "\n\n"
|
201
278
|
model = @models.last
|
202
279
|
if @data_json['method'].eql?('GET')
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
280
|
+
puts_m " [MLNetworkingManager getWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
|
281
|
+
puts_m " if (response.resultCode == 0 && !response.error){"
|
282
|
+
puts_m " NSDictionary *detailMsg = response.detailMsg"
|
283
|
+
puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
|
284
|
+
puts_m " }"
|
285
|
+
puts_m " }];"
|
209
286
|
else
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
287
|
+
puts_m " [MLNetworkingManager postWithUrl:#{key} params:nil response:^(MLResponseMessage *responseMessage) {"
|
288
|
+
puts_m " if (response.resultCode == 0 && !response.error){"
|
289
|
+
puts_m " NSDictionary *detailMsg = response.detailMsg"
|
290
|
+
puts_m " #{model[:name]} *model = [#{model[:name]} yy_modelWithDictionary:detailMsg];" if model
|
291
|
+
puts_m " }"
|
292
|
+
puts_m " }];"
|
216
293
|
end
|
217
294
|
end
|
218
295
|
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.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.8.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: plist
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.1.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|