lhj-tools 0.1.67 → 0.1.70
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/yapi.rb +18 -20
- data/lib/lhj/tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 016612e3ae63d122d623c3edf0d3d7c2d299c168b65fc00277c21893afb89b69
|
4
|
+
data.tar.gz: 262a3bca5cc53615347fdfd26d8805566ecc2b49fbd2021515448cd0806e4938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2008b246e8158d34b44db6bdc8fa02a84279c6d387006ebc1df6424ca79de7a664abd1c2788e9647a9a27f8f5fa4a43b45e78d45105eee7e6be435e162d597ed
|
7
|
+
data.tar.gz: 57b1908b366a81aca0e928bf9a57801f1e13673039c75807f3c8256424637c067155d8fceffe60cf6620e6daf17e8ad5735db45d837721ae9e0470abc98a7883
|
data/lib/lhj/command/yapi.rb
CHANGED
@@ -24,6 +24,7 @@ module Lhj
|
|
24
24
|
def initialize(argv)
|
25
25
|
@id = argv.option('id')
|
26
26
|
@model_pre_name = argv.option('model-pre')
|
27
|
+
@model_result_name = argv.option('model-name')
|
27
28
|
@language = argv.option('lan', 'oc')
|
28
29
|
@save = argv.flag?('save', false)
|
29
30
|
@sync = argv.flag?('sync', false)
|
@@ -34,10 +35,9 @@ module Lhj
|
|
34
35
|
@http_headers = []
|
35
36
|
@config_id = ''
|
36
37
|
@config_model_pre = 'ML'
|
38
|
+
@config_model_name = 'Result'
|
37
39
|
@model_default_suffix = 'Model'
|
38
40
|
@type_trans = {}
|
39
|
-
@config_model_names = []
|
40
|
-
@model_names = []
|
41
41
|
@http_url = ''
|
42
42
|
super
|
43
43
|
end
|
@@ -98,15 +98,13 @@ module Lhj
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def save_to_file(service_code)
|
101
|
-
@model_names = []
|
102
|
-
model_name = @config_model_names.first
|
103
101
|
file_name = gen_model_name('')
|
104
102
|
unless File.exist?(File.expand_path(sub_folder_name, '.'))
|
105
103
|
FileUtils.mkdir_p(File.expand_path(sub_folder_name, '.'))
|
106
104
|
end
|
107
|
-
h_file = File.join('.', sub_folder_name, "#{file_name}.h")
|
108
|
-
m_file = File.join('.', sub_folder_name, "#{file_name}.m")
|
109
|
-
service_file = File.join('.', sub_folder_name, "#{model_pre}#{model_name}Service.m")
|
105
|
+
h_file = File.join('.', api_id, sub_folder_name, "#{file_name}.h")
|
106
|
+
m_file = File.join('.', api_id, sub_folder_name, "#{file_name}.m")
|
107
|
+
service_file = File.join('.', api_id, sub_folder_name, "#{model_pre}#{model_name}Service.m")
|
110
108
|
File.write(h_file, @h_file_array.join("\n")) if @h_file_array.count.positive?
|
111
109
|
File.write(m_file, @m_file_array.join("\n")) if @m_file_array.count.positive?
|
112
110
|
File.write(service_file, service_code) if service_code
|
@@ -115,10 +113,10 @@ module Lhj
|
|
115
113
|
end
|
116
114
|
|
117
115
|
def push_to_git
|
118
|
-
Actions.sh('git checkout master'
|
119
|
-
Actions.sh('git add .'
|
120
|
-
Actions.sh("git commit -m 'generate yapi code'"
|
121
|
-
Actions.sh('git push'
|
116
|
+
Actions.sh('git checkout master')
|
117
|
+
Actions.sh('git add .')
|
118
|
+
Actions.sh("git commit -m 'generate yapi code'")
|
119
|
+
Actions.sh('git push')
|
122
120
|
end
|
123
121
|
|
124
122
|
def notify_robot(template_vars)
|
@@ -145,7 +143,7 @@ module Lhj
|
|
145
143
|
@config_id = config['id']
|
146
144
|
@config_model_pre = config['model_pre']
|
147
145
|
@config_model_suffix = config['model_suffix']
|
148
|
-
@
|
146
|
+
@config_model_name = config['model_name']
|
149
147
|
@type_trans = config['type_trans']
|
150
148
|
end
|
151
149
|
|
@@ -157,6 +155,10 @@ module Lhj
|
|
157
155
|
@model_pre_name || @config_model_pre
|
158
156
|
end
|
159
157
|
|
158
|
+
def model_name
|
159
|
+
@model_result_name || @config_model_name
|
160
|
+
end
|
161
|
+
|
160
162
|
def model_suffix
|
161
163
|
@config_model_suffix || @model_default_suffix
|
162
164
|
end
|
@@ -236,13 +238,9 @@ module Lhj
|
|
236
238
|
end
|
237
239
|
|
238
240
|
def gen_model_name(name)
|
239
|
-
n = name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) {
|
240
|
-
if n.length <= 0
|
241
|
-
|
242
|
-
end
|
243
|
-
model_name = "#{model_pre}#{n}#{model_suffix}"
|
244
|
-
@model_names << model_name
|
245
|
-
model_name
|
241
|
+
n = name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) { Regexp.last_match(0).upcase }
|
242
|
+
n = model_name if n.length <= 0
|
243
|
+
"#{model_pre}#{n}#{model_suffix}"
|
246
244
|
end
|
247
245
|
|
248
246
|
def handle_model(model, &block)
|
@@ -397,7 +395,7 @@ module Lhj
|
|
397
395
|
return unless data
|
398
396
|
|
399
397
|
path = data['path']
|
400
|
-
path_name = path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) {
|
398
|
+
path_name = path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { Regexp.last_match(0).upcase } }.join('') if path
|
401
399
|
path_key = "k#{path_name}URL"
|
402
400
|
mth = data['method']
|
403
401
|
mth = 'JSON' if data['req_body_is_json_schema']
|
data/lib/lhj/tools/version.rb
CHANGED