lhj-tools 0.1.72 → 0.1.73

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: 1414ebd1811cbc9f773ed21506171acd5aa5399a5b9a9d3a74634ff8ef93e882
4
- data.tar.gz: e0b5c1dab6b128c8e8a8518f8b38c4d0e3c3b4de8cd4c61746591fc602878c5d
3
+ metadata.gz: ec999ed3fcb4f5fff34b2dc483b5932c77bfd34c59cee78dfcebd7ea1a10fc54
4
+ data.tar.gz: c0a438db4402ef344ddf83f3acd4f3bca228c9335aa8e8d240bab02ba4745269
5
5
  SHA512:
6
- metadata.gz: d0c41abe42ed5812635dc7c9a235efb9c2bce06054aba7c977ab82f7693d04e38151e91f68b8e78f22efb1d7d69ba502cca7c5024a74ca1f3364e089d4e1cf0d
7
- data.tar.gz: 989dd03e74941a8b10623179c785367db74d8b615bac7e84d564718c0cacffb5b545ceb8d565a63687c440153e5a5493c0f8e6e1821b19e959f97da0b1f8f65e
6
+ metadata.gz: 9201f7d556c51665acb83d63cbe4978eb6507d99d00b1da5ab92fa064557298242845fec4484d2cf327fc41a6bf1663c3648573627ecb3098338d5c591aa1d04
7
+ data.tar.gz: 217cc7ee797ee78ab6a074715bf346fc3e044779e2553a20a1b813a63239a3e72611d17e439477912415ba600325ed4f1d597446e213833c6146651419a22a67
@@ -66,7 +66,6 @@ module Lhj
66
66
  service_code = print_http_method(res_body['data'], result_model_name, param_model_name)
67
67
  # 5.save to file
68
68
  file_map = save_to_file(service_code) if @save
69
- puts file_map
70
69
  # 6.push to git
71
70
  push_to_git if @sync
72
71
  # 7.notify robot
@@ -101,7 +100,7 @@ module Lhj
101
100
 
102
101
  def save_to_file(service_code)
103
102
  name = model_name
104
- file_name = gen_model_name('')
103
+ file_name = gen_model_name
105
104
  unless File.exist?(File.expand_path(sub_folder_name, '.'))
106
105
  FileUtils.mkdir_p(File.expand_path(sub_folder_name, '.'))
107
106
  end
@@ -162,6 +161,10 @@ module Lhj
162
161
  @model_result_name || @config_model_name
163
162
  end
164
163
 
164
+ def req_model_name
165
+ 'Param'
166
+ end
167
+
165
168
  def model_suffix
166
169
  @config_model_suffix || @model_default_suffix
167
170
  end
@@ -228,7 +231,7 @@ module Lhj
228
231
  result = res_body['properties']['detailMsg']
229
232
  return unless result['type'] == 'object' || result['type'] == 'array'
230
233
 
231
- result['name'] = gen_model_name('')
234
+ result['name'] = gen_model_name
232
235
  result
233
236
  end
234
237
 
@@ -236,14 +239,18 @@ module Lhj
236
239
  return if !res_json || !res_json['data'] || !res_json['data']['req_body_other']
237
240
 
238
241
  result = JSON.parse(res_json['data']['req_body_other'])
239
- result['name'] = gen_model_name('')
242
+ result['name'] = gen_model_name(nil, :req)
240
243
  result
241
244
  end
242
245
 
243
- def gen_model_name(name)
244
- n = name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) { Regexp.last_match(0).upcase }
245
- n = model_name if n.length <= 0
246
- "#{model_pre}#{n}#{model_suffix}"
246
+ def gen_model_name(property_name = nil, type = :res)
247
+ name = model_name
248
+ name = req_model_name if type == :req
249
+ unless property_name.nil?
250
+ name = property_name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) { Regexp.last_match(0).upcase }
251
+ name = property_name.gsub(/^\w/) { Regexp.last_match(0).upcase } if name.length <= 0
252
+ end
253
+ "#{model_pre}#{name}#{model_suffix}"
247
254
  end
248
255
 
249
256
  def handle_model(model, &block)
@@ -398,7 +405,9 @@ module Lhj
398
405
  return unless data
399
406
 
400
407
  path = data['path']
401
- path_name = path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { Regexp.last_match(0).upcase } }.join('') if path
408
+ if path
409
+ path_name = path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { Regexp.last_match(0).upcase } }.join('')
410
+ end
402
411
  path_key = "k#{path_name}URL"
403
412
  mth = data['method']
404
413
  mth = 'JSON' if data['req_body_is_json_schema']
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.72"
5
+ VERSION = "0.1.73"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.72
4
+ version: 0.1.73
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian