goa_model_gen 0.9.6 → 0.9.7

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: fe779fe770c8cd29d871c25eba2b99849f8ac1ded301e2882626b8f77ce05423
4
- data.tar.gz: c5ceb285bcd63b666fbc2274718f2bb6a02da528b6828cb32bf8d7057dd9257c
3
+ metadata.gz: 0bf4c80340040eaf2b29729d5798bd0c6b6220b25b2fa75b7c8ac507c546d690
4
+ data.tar.gz: a260252e1472941a1f02ee88712dca0079f6d3898178af619ecb1fce64957132
5
5
  SHA512:
6
- metadata.gz: 6c79be2c421b0190493a611a545c9c4d1c674d48ad256dd3a6715bab0132234521bd471ff6cf366f78c9fc93c5c2da80fe77a41121f7549948461cc1da2c72a1
7
- data.tar.gz: 617355d9b10271f9e16ec9f37fd4550ae070ecf3d92d90dc334ce1d536e2ebcd8a5bbd168d5382f88645c5fe1195fc3c6086ac3c6c8508b4b28cf728e22566ba
6
+ metadata.gz: 723725e4b61fa693909d4f3d0ffb0337bdd2acf73a074cd79b1fb52571825f63008ce78d9326c4b0b7d1e904574fe6b79c82fc461828b27e47875acc91aaff1c
7
+ data.tar.gz: b8daf5ce16247ef444146749f9a8189a5b647a241c1a1d583e9ecb06936f1ceaf537720a7bfda94a2675b5fff36ff24ec25c47a1bc596e268b551b858fb44ba4
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency "thor", "~> 0.20.0"
27
27
  spec.add_runtime_dependency "activesupport"
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "bundler"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
  spec.add_development_dependency "pry"
@@ -13,6 +13,7 @@ module GoaModelGen
13
13
  attr_accessor :validation
14
14
  attr_accessor :swagger_name
15
15
  attr_reader :type_obj
16
+ attr_reader :json_tag
16
17
  attr_reader :datastore_tag
17
18
  attr_reader :prepare_method
18
19
 
@@ -26,6 +27,7 @@ module GoaModelGen
26
27
  @validation = attrs['validation']
27
28
  @goa_name = attrs['goa_name']
28
29
  @swagger_name = attrs['swagger_name']
30
+ @json_tag = attrs['json_tag']
29
31
  @datastore_tag = attrs['datastore_tag']
30
32
  @prepare_method = attrs['prepare_method']
31
33
  end
@@ -79,18 +81,22 @@ module GoaModelGen
79
81
  end
80
82
 
81
83
  def tag
82
- json_tag = name.underscore.dup
83
- json_tag << ',omitempty' if nullable?
84
84
  validate_tags = nullable? ? [] : ['required']
85
85
  validate_tags << validation.presence
86
86
  validate_tags.compact!
87
87
  [
88
- ['json', json_tag],
88
+ ['json', json_tag.presence || build_json_tag],
89
89
  ['validate', validate_tags.join(',').presence],
90
90
  ['datastore', datastore_tag],
91
91
  ].map{|k,v| v ? "#{k}:\"#{v}\"" : nil}.compact.join(' ')
92
92
  end
93
93
 
94
+ def build_json_tag
95
+ r = name.underscore.dup
96
+ r << ',omitempty' if nullable?
97
+ return r
98
+ end
99
+
94
100
  def definition
95
101
  "#{ name } #{ type } `#{ tag }`"
96
102
  end
@@ -99,6 +99,7 @@ func (m *<%= model.name %>) PrepareToCreate() error {
99
99
  }
100
100
 
101
101
  func (m *<%= model.name %>) PrepareToUpdate() error {
102
+ m.PrepareFields()
102
103
  <%- if model.fields.any?{|f| f.name == "UpdatedAt"} -%>
103
104
  m.UpdatedAt = time.Now()
104
105
  <%- end -%>
@@ -1,3 +1,3 @@
1
1
  module GoaModelGen
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goa_model_gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -186,8 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
189
- rubyforge_project:
190
- rubygems_version: 2.7.6
189
+ rubygems_version: 3.0.3
191
190
  signing_key:
192
191
  specification_version: 4
193
192
  summary: Generate model files for goa in golang