lhj-tools 0.1.69 → 0.1.70

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: 14aa58ce44752d28082011fef120da1f393585210f16bbae26dbdd97d741b3ff
4
- data.tar.gz: fcf24ca4267e6e5b1195880f7f397ef939edaa4ffcedf6898c85d7653951cf39
3
+ metadata.gz: 016612e3ae63d122d623c3edf0d3d7c2d299c168b65fc00277c21893afb89b69
4
+ data.tar.gz: 262a3bca5cc53615347fdfd26d8805566ecc2b49fbd2021515448cd0806e4938
5
5
  SHA512:
6
- metadata.gz: c88954bbf5f6bdd1fcbfdb9ae8f01f9736775775a1fbba6590637c7d26ee93c329b16b9a2956c2386a68ff05d859884e28a310111129bd3d7ef92966a8121e70
7
- data.tar.gz: eb1b73442d3bdb83c9ab8284b88d92205f17d29aa9a545d0d8b1acbd3c3b0195e5b753116a9e5d643415f912149659691a1c42f153deb9f0f5da64988cf63f85
6
+ metadata.gz: 2008b246e8158d34b44db6bdc8fa02a84279c6d387006ebc1df6424ca79de7a664abd1c2788e9647a9a27f8f5fa4a43b45e78d45105eee7e6be435e162d597ed
7
+ data.tar.gz: 57b1908b366a81aca0e928bf9a57801f1e13673039c75807f3c8256424637c067155d8fceffe60cf6620e6daf17e8ad5735db45d837721ae9e0470abc98a7883
@@ -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
@@ -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.70"
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.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian