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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14aa58ce44752d28082011fef120da1f393585210f16bbae26dbdd97d741b3ff
4
- data.tar.gz: fcf24ca4267e6e5b1195880f7f397ef939edaa4ffcedf6898c85d7653951cf39
3
+ metadata.gz: e9994ca666916dfa43e3f9794e85cc6c2c6f0fad59cb7d17cd9ec39338e00ed4
4
+ data.tar.gz: a77906cc7b4d42cc35a5e44164f37f0b2276894190d516788994bc8ce9511322
5
5
  SHA512:
6
- metadata.gz: c88954bbf5f6bdd1fcbfdb9ae8f01f9736775775a1fbba6590637c7d26ee93c329b16b9a2956c2386a68ff05d859884e28a310111129bd3d7ef92966a8121e70
7
- data.tar.gz: eb1b73442d3bdb83c9ab8284b88d92205f17d29aa9a545d0d8b1acbd3c3b0195e5b753116a9e5d643415f912149659691a1c42f153deb9f0f5da64988cf63f85
6
+ metadata.gz: e1bab6ae3305c789e82664f918d8a22e1290ff4cd7fd16eb0b314816ceaf401b932f86164127b3f83cda4c11b97cb6c084fb8eac42da2918679d2ab82c81d737
7
+ data.tar.gz: 74a00f584c2223ed1a726af3f284047a940dd8d5f02022bf98e2738350759ab0e16d807435281473a8be2c952fe0521390709ca01cf5094bfa50ccb28d7852a6
@@ -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
- @config_model_names = config['model_names']
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/) { $&.upcase }
240
- if n.length <= 0
241
- n = @config_model_names.detect { |c| @model_names.none? { |na| na.gsub(/#{model_pre}(.*)Model/, '\1').eql?(c) } }
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/) { $&.upcase } }.join('') if path
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']
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.69"
5
+ VERSION = "0.1.71"
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.69
4
+ version: 0.1.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian