lhj-tools 0.1.69 → 0.1.71
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 +4 -4
- data/lib/lhj/command/yapi.rb +12 -14
- 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: e9994ca666916dfa43e3f9794e85cc6c2c6f0fad59cb7d17cd9ec39338e00ed4
|
|
4
|
+
data.tar.gz: a77906cc7b4d42cc35a5e44164f37f0b2276894190d516788994bc8ce9511322
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1bab6ae3305c789e82664f918d8a22e1290ff4cd7fd16eb0b314816ceaf401b932f86164127b3f83cda4c11b97cb6c084fb8eac42da2918679d2ab82c81d737
|
|
7
|
+
data.tar.gz: 74a00f584c2223ed1a726af3f284047a940dd8d5f02022bf98e2738350759ab0e16d807435281473a8be2c952fe0521390709ca01cf5094bfa50ccb28d7852a6
|
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,8 +98,6 @@ 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, '.'))
|
|
@@ -111,7 +109,7 @@ module Lhj
|
|
|
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
|
|
113
111
|
puts "\n\n生成文件成功!所在路径:\n#{File.expand_path(h_file)} \n#{File.expand_path(m_file)}".green
|
|
114
|
-
{ h_file: h_file, m_file: m_file, s_file: service_file }
|
|
112
|
+
{ h_file: h_file, m_file: m_file, s_file: service_file, api_id: api_id }
|
|
115
113
|
end
|
|
116
114
|
|
|
117
115
|
def push_to_git
|
|
@@ -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