goa_model_gen 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/goa_model_gen/templates/model.go.erb +35 -0
- data/lib/goa_model_gen/type.rb +2 -0
- data/lib/goa_model_gen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca554d53fda64080cd5a64e2408b2558f548c5d6acd6f5e14848736cf2d39fa
|
4
|
+
data.tar.gz: a426126a914b0b8d3e70f8fe6e4e995540c099dcbe5eadb97705ba489a146ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890c57ae95750b80d5b96034c4c4844e7660c027c2e3959e53de6491bfb5f2d742922753a1ad1f7be55b28330fab3c34c650341b0053e8f9a602b56fd9608c38
|
7
|
+
data.tar.gz: 4c11251847cc608ec123875924ef01393f0d8c95e66dedf3cb03491c2cb18efe85a9c06cd79288739acbcd37b30d335a878ba8b3c6d6949547d58f56afd818b7
|
@@ -29,6 +29,41 @@ const (
|
|
29
29
|
<%- end -%>
|
30
30
|
)
|
31
31
|
<%- end -%>
|
32
|
+
|
33
|
+
<%- if type.enum_map -%>
|
34
|
+
const (
|
35
|
+
<%- type.enum_map.each do |key, name| -%>
|
36
|
+
<%= type.name %><%= name.camelize %> <%= type.name %> = <%= key.inspect %>
|
37
|
+
<%- end -%>
|
38
|
+
)
|
39
|
+
|
40
|
+
var <%= type.name %>Map = map[<%= type.name %>]string{
|
41
|
+
<%- type.enum_map.each do |key, name| -%>
|
42
|
+
<%= key.inspect %>: <%= name.inspect %>,
|
43
|
+
<%- end -%>
|
44
|
+
}
|
45
|
+
|
46
|
+
func (t <%= type.name %>) String() string {
|
47
|
+
return <%= type.name %>Map[t]
|
48
|
+
}
|
49
|
+
|
50
|
+
var <%= type.name %>NameToValue = map[string]<%= type.name %>{
|
51
|
+
<%- type.enum_map.each do |key, name| -%>
|
52
|
+
<%= name.inspect %>: <%= key.inspect %>,
|
53
|
+
<%- end -%>
|
54
|
+
}
|
55
|
+
|
56
|
+
func Parse<%= type.name %>(s string) *<%= type.name %> {
|
57
|
+
val, ok := <%= type.name %>NameToValue[s]
|
58
|
+
if ok {
|
59
|
+
return &val
|
60
|
+
} else {
|
61
|
+
return nil
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
<%- end -%>
|
66
|
+
|
32
67
|
<%- end -%>
|
33
68
|
|
34
69
|
<%- end -%>
|
data/lib/goa_model_gen/type.rb
CHANGED
@@ -33,6 +33,7 @@ module GoaModelGen
|
|
33
33
|
|
34
34
|
class Model < Type
|
35
35
|
attr_reader :enum_items, :enum_path
|
36
|
+
attr_reader :enum_map
|
36
37
|
attr_reader :payload, :media_type
|
37
38
|
attr_reader :payload_name, :media_type_name
|
38
39
|
attr_reader :goon
|
@@ -43,6 +44,7 @@ module GoaModelGen
|
|
43
44
|
super(name, attrs)
|
44
45
|
@base = attrs['base']
|
45
46
|
@enum_path = attrs['enum']
|
47
|
+
@enum_map = attrs['enum_map']
|
46
48
|
@goon = attrs['goon']
|
47
49
|
@payload_name = check_blank(attrs['payload']){ store? ? "#{@name}Payload" : @name }
|
48
50
|
@media_type_name = check_blank(attrs['media_type']){ @name }
|
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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|