tla-sbuilder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +328 -0
  3. data/VERSION +1 -0
  4. data/bin/sbuilder.rb +5 -0
  5. data/lib/cli/cli-customer.rb +420 -0
  6. data/lib/cli/cli-example.rb +92 -0
  7. data/lib/cli/cli-pet.rb +767 -0
  8. data/lib/cli/cli-text.rb +226 -0
  9. data/lib/cli/cli.rb +298 -0
  10. data/lib/sbuilder.rb +52 -0
  11. data/lib/sbuilder/constants.rb +72 -0
  12. data/lib/sbuilder/controller.rb +798 -0
  13. data/lib/sbuilder/default-sbuilder.yaml +372 -0
  14. data/lib/sbuilder/domain.rb +124 -0
  15. data/lib/sbuilder/domain_cardinality.rb +37 -0
  16. data/lib/sbuilder/domain_value.rb +81 -0
  17. data/lib/sbuilder/exception.rb +27 -0
  18. data/lib/sbuilder/extension_loader.rb +721 -0
  19. data/lib/sbuilder/factory.rb +234 -0
  20. data/lib/sbuilder/model.rb +356 -0
  21. data/lib/sbuilder/mustache/template.rb +125 -0
  22. data/lib/sbuilder/mustache/template_reader.rb +206 -0
  23. data/lib/sbuilder/mustache/template_reader_context.rb +371 -0
  24. data/lib/sbuilder/param_set.rb +132 -0
  25. data/lib/sbuilder/param_set_db.rb +20 -0
  26. data/lib/sbuilder/param_set_def.rb +57 -0
  27. data/lib/sbuilder/param_set_if.rb +68 -0
  28. data/lib/sbuilder/param_set_loader.rb +77 -0
  29. data/lib/sbuilder/param_set_loader_swagger.rb +424 -0
  30. data/lib/sbuilder/param_set_step.rb +62 -0
  31. data/lib/sbuilder/param_sets.rb +54 -0
  32. data/lib/sbuilder/parameter.rb +97 -0
  33. data/lib/sbuilder/parameter_container.rb +72 -0
  34. data/lib/sbuilder/parameter_dom.rb +70 -0
  35. data/lib/sbuilder/parameter_ref.rb +71 -0
  36. data/lib/sbuilder/resolver.rb +78 -0
  37. data/lib/sbuilder/resolver_loader.rb +79 -0
  38. data/lib/sbuilder/resolver_loader_yaml.rb +103 -0
  39. data/lib/sbuilder/resolver_rule.rb +36 -0
  40. data/lib/sbuilder/resolver_rule_match.rb +55 -0
  41. data/lib/sbuilder/resolver_rule_ref.rb +37 -0
  42. data/lib/utils/hash_inject.rb +12 -0
  43. data/lib/utils/logger.rb +80 -0
  44. data/lib/utils/netio.rb +58 -0
  45. data/lib/utils/string_inject.rb +10 -0
  46. data/lib/utils/version.rb +13 -0
  47. data/mustache/cfg/const_def.mustache +8 -0
  48. data/mustache/cfg/const_run.mustache +3 -0
  49. data/mustache/cfg/invariant-infrastructure-service.mustache +4 -0
  50. data/mustache/cfg/macro_run.mustache +6 -0
  51. data/mustache/cfg/module_footer.mustache +0 -0
  52. data/mustache/cfg/module_header.mustache +7 -0
  53. data/mustache/data-model-dump.mustache +19 -0
  54. data/mustache/data-model-footer.mustache +5 -0
  55. data/mustache/data-model-header.mustache +16 -0
  56. data/mustache/definition_types.mustache +40 -0
  57. data/mustache/domains.mustache +20 -0
  58. data/mustache/domains_assign.mustache +22 -0
  59. data/mustache/domains_run.mustache +21 -0
  60. data/mustache/extend/extend_assumptions.mustache +7 -0
  61. data/mustache/extend/extend_const.mustache +5 -0
  62. data/mustache/extend/extend_implementation.mustache +9 -0
  63. data/mustache/extend/extend_invariant.mustache +7 -0
  64. data/mustache/extend/extend_invariant_cfg.mustache +7 -0
  65. data/mustache/extend/extend_macros.mustache +19 -0
  66. data/mustache/extend/extend_operations.mustache +9 -0
  67. data/mustache/extend/extend_state.mustache +9 -0
  68. data/mustache/infrastructure-service-init.mustache +36 -0
  69. data/mustache/infrastructure-service-variables.mustache +10 -0
  70. data/mustache/interface_processes.mustache +38 -0
  71. data/mustache/interface_stubs_dummy.mustache +13 -0
  72. data/mustache/interface_types.mustache +52 -0
  73. data/mustache/markdown-header.mustache +24 -0
  74. data/mustache/markdown-toc.mustache +13 -0
  75. data/mustache/name_definition_type.mustache +5 -0
  76. data/mustache/name_domain.mustache +5 -0
  77. data/mustache/name_domain_value.mustache +5 -0
  78. data/mustache/name_domain_value_prefix.mustache +5 -0
  79. data/mustache/name_interface_response_type.mustache +6 -0
  80. data/mustache/name_interface_type.mustache +6 -0
  81. data/mustache/name_parameter_definition.mustache +5 -0
  82. data/mustache/name_parameter_type.mustache +6 -0
  83. data/mustache/name_process.mustache +6 -0
  84. data/mustache/name_type_invariant.mustache +5 -0
  85. data/mustache/name_variable.mustache +6 -0
  86. data/mustache/operator-infrastructure-service.mustache +13 -0
  87. data/mustache/possibility/module_extends.mustache +1 -0
  88. data/mustache/possibility/module_footer.mustache +1 -0
  89. data/mustache/possibility/module_header.mustache +8 -0
  90. data/mustache/possibility/possibility_definition.mustache +12 -0
  91. data/mustache/possibility/possibility_directive.mustache +1 -0
  92. data/mustache/possibility/possility_setup.mustache +28 -0
  93. data/mustache/setup/module_footer.mustache +1 -0
  94. data/mustache/setup/module_header.mustache +9 -0
  95. data/mustache/setup/operator_run.mustache +7 -0
  96. data/mustache/setup/operator_tick.mustache +2 -0
  97. data/mustache/setup/steps_run.mustache +22 -0
  98. data/mustache/setup/steps_run_bind_rule.mustache +51 -0
  99. data/mustache/setup/steps_run_bind_set.mustache +37 -0
  100. data/mustache/setup/steps_run_parameterBind.mustache +80 -0
  101. data/mustache/setup/steps_run_parameterExact.mustache +79 -0
  102. data/mustache/state_type_invariant-infrastructure-service.mustache +49 -0
  103. data/mustache/state_type_invariant.mustache +17 -0
  104. data/mustache/state_type_invariant_cfg.mustache +18 -0
  105. data/mustache/state_variables.mustache +20 -0
  106. data/mustache/tla/const_def.mustache +5 -0
  107. data/mustache/tla/const_run.mustache +3 -0
  108. data/mustache/tla/macro-infrastructure-service.mustache +14 -0
  109. data/mustache/tla/macro_run.mustache +40 -0
  110. data/mustache/tla/module_footer.mustache +2 -0
  111. data/mustache/tla/module_header.mustache +9 -0
  112. data/mustache/tla/operator_run.mustache +8 -0
  113. data/mustache/tla/operators-infrastructure-service.mustache +12 -0
  114. data/mustache/tla/plc_define_footer.mustache +1 -0
  115. data/mustache/tla/plc_define_header.mustache +1 -0
  116. data/mustache/tla/plc_define_run.mustache +59 -0
  117. data/mustache/tla/plc_footer.mustache +2 -0
  118. data/mustache/tla/plc_header.mustache +2 -0
  119. data/mustache/tla/plc_run_state.mustache +12 -0
  120. data/mustache/tla/plc_tail.mustache +8 -0
  121. data/mustache/tla/plc_translation.mustache +2 -0
  122. data/resources/schema/json_schema/draft-04.json +150 -0
  123. data/resources/schema/swagger/2.0/schema.json +1591 -0
  124. data/src-extend/README +2 -0
  125. data/src-extend/extend/extend_assumptions.mustache +7 -0
  126. data/src-extend/extend/extend_const.mustache +5 -0
  127. data/src-extend/extend/extend_implementation.mustache +9 -0
  128. data/src-extend/extend/extend_invariant.mustache +11 -0
  129. data/src-extend/extend/extend_invariant_cfg.mustache +7 -0
  130. data/src-extend/extend/extend_macros.mustache +19 -0
  131. data/src-extend/extend/extend_operations.mustache +9 -0
  132. data/src-extend/extend/extend_state.mustache +9 -0
  133. data/src-extend/extend_app/assumption +20 -0
  134. data/src-extend/extend_app/correctness +19 -0
  135. data/src-extend/extend_app/correctness.cfg +9 -0
  136. data/src-extend/extend_app/infrastructure +25 -0
  137. data/src-extend/extend_app/interface +11 -0
  138. data/src-extend/extend_app/operator +18 -0
  139. data/src-extend/extend_app/possibility +16 -0
  140. data/src-extend/extend_app/service +33 -0
  141. data/src-extend/extend_app/state +16 -0
  142. data/src-extend/extend_app/transaction +22 -0
  143. data/src/pet/assumption +29 -0
  144. data/src/pet/assumption_address_domains.tla +12 -0
  145. data/src/pet/assumption_domains.tla +16 -0
  146. data/src/pet/assumption_generic.tla +8 -0
  147. data/src/pet/assumption_id_domains.tla +2 -0
  148. data/src/pet/assumption_owner_domains.tla +14 -0
  149. data/src/pet/assumption_pet_domains.tla +16 -0
  150. data/src/pet/assumption_tag_domains.tla +13 -0
  151. data/src/pet/correctness +24 -0
  152. data/src/pet/correctness.cfg +9 -0
  153. data/src/pet/correctness_coherent_owner_address.tla +6 -0
  154. data/src/pet/correctness_pet_name.tla +4 -0
  155. data/src/pet/correctness_ref_tag.tla +13 -0
  156. data/src/pet/correctness_type_invariants.tla +12 -0
  157. data/src/pet/correctness_unique_pet.tla +3 -0
  158. data/src/pet/correctness_unique_tag.tla +3 -0
  159. data/src/pet/docs/Petstore.md +117 -0
  160. data/src/pet/extend/extend_assumptions.mustache +7 -0
  161. data/src/pet/extend/extend_implementation.mustache +9 -0
  162. data/src/pet/extend/extend_invariant.mustache +11 -0
  163. data/src/pet/extend/extend_invariant_cfg.mustache +7 -0
  164. data/src/pet/extend/extend_macros.mustache +19 -0
  165. data/src/pet/extend/extend_operations.mustache +9 -0
  166. data/src/pet/extend/extend_state.mustache +9 -0
  167. data/src/pet/infrastructure +25 -0
  168. data/src/pet/infrastructure_id_get.tla +24 -0
  169. data/src/pet/interface +12 -0
  170. data/src/pet/interface_delete_pet.tla +5 -0
  171. data/src/pet/interface_get_pet.tla +4 -0
  172. data/src/pet/interface_post_pet.tla +5 -0
  173. data/src/pet/interface_post_tag.tla +5 -0
  174. data/src/pet/interface_put_tag.tla +3 -0
  175. data/src/pet/operator +30 -0
  176. data/src/pet/operator_find_tag_by_owner_name.tla +1 -0
  177. data/src/pet/operator_get_pet.tla +4 -0
  178. data/src/pet/operator_get_pet_by_tag.tla +4 -0
  179. data/src/pet/operator_get_tag.tla +10 -0
  180. data/src/pet/operator_new_owner.tla +3 -0
  181. data/src/pet/operator_new_pet.tla +13 -0
  182. data/src/pet/operator_new_tag.tla +3 -0
  183. data/src/pet/operator_next_pet_id.tla +3 -0
  184. data/src/pet/operator_responses.tla +8 -0
  185. data/src/pet/operator_tag_exists.tla +2 -0
  186. data/src/pet/operator_tag_owner_validated.tla +2 -0
  187. data/src/pet/operator_tag_referenced.tla +4 -0
  188. data/src/pet/operator_valid_owner.tla +17 -0
  189. data/src/pet/operator_valid_pet.tla +6 -0
  190. data/src/pet/operator_valid_tag.tla +5 -0
  191. data/src/pet/possibility +18 -0
  192. data/src/pet/possibility_at_least_two_tags.tla +12 -0
  193. data/src/pet/possibility_invalid_tag_address.tla +8 -0
  194. data/src/pet/service +35 -0
  195. data/src/pet/service_pet_delete.tla +11 -0
  196. data/src/pet/service_pet_get.tla +27 -0
  197. data/src/pet/service_pet_post.tla +78 -0
  198. data/src/pet/service_tag_post.tla +53 -0
  199. data/src/pet/service_tag_put.tla +82 -0
  200. data/src/pet/state +16 -0
  201. data/src/pet/state_infra.tla +6 -0
  202. data/src/pet/state_pet.tla +5 -0
  203. data/src/pet/state_tag_id.tla +2 -0
  204. data/src/pet/transaction +23 -0
  205. data/src/pet/transaction_delete_pet.tla +13 -0
  206. data/src/pet/transaction_enter_pet.tla +13 -0
  207. data/src/pet/transaction_enter_tag.tla +56 -0
  208. data/src/pet/transaction_error.tla +23 -0
  209. data/tla-sbuilder.gemspec +43 -0
  210. metadata +353 -0
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+ require_relative 'cli-pet'
3
+ require_relative 'cli-customer'
4
+ module Sbuilder
5
+
6
+ class Example < Thor
7
+
8
+ def initialize(*args)
9
+ super
10
+ end
11
+
12
+ # ------------------------------------------------------------------
13
+ # task pet
14
+
15
+ desc :pet, "Create 'Pet Store' TLA+ model <cnf_dir> -directory"
16
+ option :test, :type => :string, :desc => "test"
17
+ # access parent options
18
+ Cli.shared_options( :cnf_dir) { |name, opts| option name, opts }
19
+ def pet
20
+ dir = options[:cnf_dir]
21
+ CliPet.write_files( dir, self )
22
+ # sbuilder - example sources
23
+ write_example_dir
24
+
25
+ end
26
+
27
+ desc :customer, "Create 'Customer' TLA+ model <cnf_dir> -directory"
28
+ option :test, :type => :string, :desc => "test"
29
+ # access parent options
30
+ Cli.shared_options( :cnf_dir) { |name, opts| option name, opts }
31
+ def customer
32
+ dir = options[:cnf_dir]
33
+ sbuilder_yaml = Sbuilder::Constants::CNF_FILE
34
+ write_example( dir, sbuilder_yaml, Sbuilder::CliCustomer::SBUILDER_YAML_CUSTOMER )
35
+ write_example( dir, Sbuilder::CliCustomer::FILE_RESOLVER_CUSTOMER, Sbuilder::CliCustomer::RESOLVER_CUSTOMER )
36
+ write_example( dir, Sbuilder::CliCustomer::FILE_INTERFACE_CUSTOMER, Sbuilder::CliCustomer::INTERFACE_CUSTOMER_SWAGGER )
37
+ write_example( dir, Sbuilder::CliCustomer::FILE_EXTENSIONS_CUSTOMER_COMMON, Sbuilder::CliCustomer::EXTENSIONS_CUSTOMER_COMMON )
38
+ write_example( dir, Sbuilder::CliCustomer::FILE_EXTENSIONS_CUSTOMER_RUN1, Sbuilder::CliCustomer::EXTENSIONS_CUSTOMER_RUN1 )
39
+ write_example( dir, Sbuilder::CliCustomer::FILE_EXTENSIONS_CUSTOMER_RUN2, Sbuilder::CliCustomer::EXTENSIONS_CUSTOMER_RUN2 )
40
+
41
+ # sbuilder - example sources
42
+ write_example_dir
43
+
44
+ end
45
+
46
+
47
+
48
+ # ------------------------------------------------------------------
49
+ # common routines
50
+ no_commands do
51
+
52
+ def output( level, msg )
53
+ puts msg if level <= options[:verbosity]
54
+ end
55
+
56
+ def write_example_dir
57
+
58
+ src_dir = File.expand_path( File.join File.dirname(__FILE__), "../../src" )
59
+ target_src_dir = File.expand_path( options[:src_dir] )
60
+
61
+ if src_dir != target_src_dir then
62
+
63
+ output( 1, "Directory: --> #{target_src_dir}" )
64
+
65
+ FileUtils.copy_entry( src_dir, target_src_dir )
66
+
67
+ else
68
+ # developmenet environement Gem src == options[:src_dir]
69
+ output( 0, "#{target_src_dir} - already in context" )
70
+ end
71
+
72
+ end
73
+
74
+ # File open && write
75
+ def write_example( dir, file, lines )
76
+ msg = <<-EOS.unindent
77
+ No such directory #{dir}
78
+
79
+ Run '#{File.basename $0} init' to initialize configuration directories
80
+
81
+ EOS
82
+ raise msg unless File.exist?( dir )
83
+ filePath = "#{dir}/#{file}"
84
+ output( 1, "File: --> #{filePath}" )
85
+ File.open( filePath ,'w' ) { |f| f.write( lines ) }
86
+ end
87
+
88
+ end # no_commands
89
+
90
+
91
+ end # class Example
92
+ end
@@ -0,0 +1,767 @@
1
+ module Sbuilder
2
+
3
+ require_relative 'cli-text'
4
+
5
+ class CliPet
6
+
7
+ # ------------------------------------------------------------------
8
+ # Constans
9
+
10
+ FILE_RESOLVER_PETSTORE="resolver_petstore.yaml"
11
+ FILE_RESOLVER_PETSTORE_DEFAULT="resolver_petstore_default.yaml"
12
+ FILE_INFRASTRUCTURE_PETSTORE="petstore-infra.yaml"
13
+ FILE_INTERFACE_TAGS="petstore-tags.yaml"
14
+ FILE_EXTENSIONS_PETSTORE_COMMON="extend_petstore_doms.yaml"
15
+ FILE_EXTENSIONS_PETSTORE_RUN1="extend_petstore_run1.yaml"
16
+ FILE_EXTENSIONS_PETSTORE_RUN2="extend_petstore_run2.yaml"
17
+ FILE_EXTENSIONS_PETSTORE_RUN3="extend_petstore_run3.yaml"
18
+ FILE_EXTENSIONS_PETSTORE_RUN_SVG="extend_petstore_run_svg.yaml"
19
+
20
+ PETSTORE_URL="https://cdn.rawgit.com/swagger-api/swagger-spec/master/examples/v2.0/yaml/petstore-expanded.yaml"
21
+
22
+
23
+ # ------------------------------------------------------------------
24
+ # sbuilder
25
+
26
+ SBUILDER_YAML_PET= <<-EOS
27
+ #{Sbuilder::CliText::SBUILBER_INTERFACES}
28
+
29
+ interfaces:
30
+
31
+ - type: swagger
32
+ url: #{PETSTORE_URL}
33
+ cache: petstore.yaml
34
+
35
+ - type: swagger
36
+ file: #{FILE_INTERFACE_TAGS}
37
+
38
+ - type: swagger
39
+ infrastructureServices: true
40
+ file: #{FILE_INFRASTRUCTURE_PETSTORE}
41
+
42
+
43
+ # ------------------------------------------------------------------
44
+ #{Sbuilder::CliText::SBUILDER_RESOLVERS}
45
+ resolvers:
46
+ - type: resolver_yaml
47
+ url: cnf/#{FILE_RESOLVER_PETSTORE}
48
+ # un-comment to use default resolver.
49
+ # normally not used
50
+ # - type: resolver_yaml
51
+ # url: cnf/#{FILE_RESOLVER_PETSTORE_DEFAULT}
52
+
53
+ # ------------------------------------------------------------------
54
+ #{Sbuilder::CliText::SBUILER_SETUPS}
55
+ setups:
56
+ - setupDirectory: default
57
+
58
+ - setupDirectory: pet1
59
+ extensions:
60
+ - type: default-yaml
61
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
62
+ - type: default-yaml
63
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN1}
64
+ possibilities:
65
+ - tag_with_invalid_address
66
+ - at_least_two_tags
67
+
68
+ - setupDirectory: pet2
69
+ extensions:
70
+ - type: default-yaml
71
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
72
+ - type: default-yaml
73
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN2}
74
+
75
+ - setupDirectory: pet3
76
+ extensions:
77
+ - type: default-yaml
78
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
79
+ - type: default-yaml
80
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN3}
81
+ possibilities:
82
+ - tag_with_invalid_address
83
+ - at_least_two_tags
84
+
85
+ - setupDirectory: pet-svg
86
+ extensions:
87
+ - type: default-yaml
88
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
89
+ - type: default-yaml
90
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN_SVG}
91
+
92
+ - setupDirectory: error-invalidate-name
93
+ desc: Owner name is invalidate on a tag referenced
94
+ preferences:
95
+ error-invalidate-name: true
96
+ extensions:
97
+ - type: default-yaml
98
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
99
+ - type: default-yaml
100
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN3}
101
+
102
+
103
+ - setupDirectory: error-duplicate-tag
104
+ desc: Duplicate tag violation found
105
+ preferences:
106
+ error-duplicate-tag: true
107
+ extensions:
108
+ - type: default-yaml
109
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_COMMON}
110
+ - type: default-yaml
111
+ url: cnf/#{FILE_EXTENSIONS_PETSTORE_RUN3}
112
+
113
+
114
+ # ------------------------------------------------------------------
115
+ #{Sbuilder::CliText::SBUILDER_PREFERENCES}
116
+ preferences:
117
+ debug-output: true
118
+
119
+
120
+ # ------------------------------------------------------------------
121
+ #{Sbuilder::CliText::SBUILDER_GENERATE}
122
+ generate:
123
+
124
+
125
+ - output: doc/tag-put.md
126
+ inputs:
127
+
128
+ - desc: Implementation of tag put
129
+ modelData: none
130
+ template: markdown-toc.mustache
131
+
132
+ - desc: Service "put_tag"
133
+ modelData: none
134
+ template: markdown-header.mustache
135
+ templateParameters:
136
+ include: service_tag_put.tla
137
+
138
+
139
+ - desc: Operator "GetTagtByIdentity"
140
+ modelData: none
141
+ template: markdown-header.mustache
142
+ templateParameters:
143
+ include: operator_get_tag.tla
144
+
145
+ - desc: Operator "ValidateTagData"
146
+ modelData: none
147
+ template: markdown-header.mustache
148
+ templateParameters:
149
+ include: operator_valid_tag.tla
150
+
151
+ - desc: Operator "TagReferenced"
152
+ modelData: none
153
+ template: markdown-header.mustache
154
+ templateParameters:
155
+ include: operator_tag_referenced.tla
156
+
157
+ - desc: Operator "TagOwnerValidated"
158
+ modelData: none
159
+ template: markdown-header.mustache
160
+ templateParameters:
161
+ include: operator_tag_owner_validated.tla
162
+
163
+ - desc: Transaction "enter_tag"
164
+ modelData: none
165
+ template: markdown-header.mustache
166
+ templateParameters:
167
+ include: transaction_enter_tag.tla
168
+
169
+ - desc: Tag owner address coherence
170
+ modelData: none
171
+ template: markdown-header.mustache
172
+ templateParameters:
173
+ include: correctness_coherent_owner_address.tla
174
+
175
+ - desc: Pet tag reference integrity
176
+ modelData: none
177
+ template: markdown-header.mustache
178
+ templateParameters:
179
+ include: correctness_ref_tag.tla
180
+
181
+ - desc: Tag uniqueness
182
+ modelData: none
183
+ template: markdown-header.mustache
184
+ templateParameters:
185
+ include: correctness_unique_tag.tla
186
+
187
+
188
+ - output: doc/tag-post.md
189
+ inputs:
190
+
191
+ - desc: Implementation of tag post
192
+ modelData: none
193
+ template: markdown-toc.mustache
194
+
195
+ - desc: Service tag-post
196
+ modelData: none
197
+ template: markdown-header.mustache
198
+ templateParameters:
199
+ include: service_tag_put.tla
200
+
201
+ - desc: Operator "ValidateTagData"
202
+ modelData: none
203
+ template: markdown-header.mustache
204
+ templateParameters:
205
+ include: operator_valid_tag.tla
206
+
207
+ - desc: Operator "TagOwnerValidated"
208
+ modelData: none
209
+ template: markdown-header.mustache
210
+ templateParameters:
211
+ include: operator_tag_owner_validated.tla
212
+
213
+ - desc: Operator "ValidOwner"
214
+ modelData: none
215
+ template: markdown-header.mustache
216
+ templateParameters:
217
+ include: operator_valid_owner.tla
218
+
219
+
220
+ - desc: Transaction
221
+ modelData: none
222
+ template: markdown-header.mustache
223
+ templateParameters:
224
+ include: transaction_enter_tag.tla
225
+
226
+
227
+
228
+ - output: doc/pet-post.md
229
+ inputs:
230
+
231
+ - desc: Implementation of pet post
232
+ modelData: none
233
+ template: markdown-toc.mustache
234
+
235
+ - desc: Pet post service
236
+ modelData: none
237
+ template: markdown-header.mustache
238
+ templateParameters:
239
+ include: service_pet_post.tla
240
+
241
+ - desc: Operator "ValidatePetData"
242
+ modelData: none
243
+ template: markdown-header.mustache
244
+ templateParameters:
245
+ include: operator_valid_pet.tla
246
+
247
+ - desc: Operator "ValidTagExists"
248
+ modelData: none
249
+ template: markdown-header.mustache
250
+ templateParameters:
251
+ include: operator_tag_exists.tla
252
+
253
+ - desc: Enter pet into database
254
+ modelData: none
255
+ template: markdown-header.mustache
256
+ templateParameters:
257
+ include: transaction_enter_pet.tla
258
+
259
+ - desc: Type invariant for Petstore
260
+ modelData: none
261
+ template: markdown-header.mustache
262
+ templateParameters:
263
+ include: correctness_pet_name.tla
264
+
265
+ - desc: Tag owner address coherence
266
+ modelData: none
267
+ template: markdown-header.mustache
268
+ templateParameters:
269
+ include: correctness_coherent_owner_address.tla
270
+
271
+ - desc: Pet tag reference integrity
272
+ modelData: none
273
+ template: markdown-header.mustache
274
+ templateParameters:
275
+ include: correctness_ref_tag.tla
276
+
277
+ - desc: Tag uniqueness
278
+ modelData: none
279
+ template: markdown-header.mustache
280
+ templateParameters:
281
+ include: correctness_unique_tag.tla
282
+
283
+
284
+ # - desc: Data for petstore
285
+ # modelData: none
286
+ # template: markdown-header.mustache
287
+ # templateParameters:
288
+ # include: state_pet.tla
289
+
290
+ # - desc: Type definitions in Petstore
291
+ # modelData: definitions
292
+ # template: markdown-header.mustache
293
+ # templateParameters:
294
+ # include: definition_types.mustache
295
+
296
+
297
+ EOS
298
+
299
+ EXTENSIONS_PETSTORE_COMMON = <<-EOS
300
+ #{Sbuilder::CliText::EXTENSION_HEADER_DOM}
301
+
302
+ #
303
+ # Extend domain resolved in #{FILE_RESOLVER_PETSTORE}
304
+ #
305
+
306
+ -
307
+ domain-extension:
308
+ - domain: id
309
+ cardinality: 3
310
+ - domain: pet_name
311
+ cardinality: 3
312
+ - domain: error_codes
313
+ values:
314
+ - validation-error
315
+ - unspecified
316
+
317
+
318
+ #{Sbuilder::CliText::EXTENSION_HEADER_SETUP}
319
+
320
+ - interface-extension:
321
+ - matcher: /pets(post)
322
+ implementation: post_pet
323
+
324
+ - matcher: /pets/{id}(delete)
325
+ implementation: delete_pet
326
+
327
+ - matcher: /pets/{id}(get)
328
+ implementation: get_pet
329
+
330
+ - matcher: /tags(post)
331
+ implementation: post_tag
332
+
333
+ - matcher: /tags(put)
334
+ implementation: put_tag
335
+
336
+ EOS
337
+
338
+ EXTENSIONS_PETSTORE_RUN1 = <<-EOS
339
+ #{Sbuilder::CliText::EXTENSION_HEADER_SETUP}
340
+ #
341
+
342
+ - step-extension:
343
+
344
+ - interface: /pets(post)
345
+ input:
346
+ pet:
347
+ name: 1
348
+
349
+ - interface: /pets(post)
350
+ input:
351
+ pet:
352
+ name: 0
353
+
354
+ - interface: /pets/{id}(get)
355
+ input:
356
+ id: 1
357
+
358
+ - interface: /pets/{id}(delete)
359
+ input:
360
+ id: 1
361
+
362
+ - interface: /pets/{id}(get)
363
+ input:
364
+ id: 1
365
+
366
+ EOS
367
+
368
+
369
+ EXTENSIONS_PETSTORE_RUN2 = <<-EOS
370
+ #
371
+ #
372
+
373
+ - step-extension:
374
+
375
+ - interface: /pets(post)
376
+
377
+ - interface: /pets/{id}(get)
378
+
379
+ - interface: /pets/{id}(delete)
380
+
381
+ - interface: /pets/{id}(get)
382
+
383
+ EOS
384
+
385
+ EXTENSIONS_PETSTORE_RUN_SVG = <<-EOS
386
+ #
387
+ # Just enough behaviour to create a decent graph
388
+ #
389
+
390
+ - step-extension:
391
+
392
+ - interface: /tags(post)
393
+ # bindExact: true
394
+ # inputs:
395
+ # - input:
396
+ # tag:
397
+ # _default: 1
398
+ # name: 1
399
+ # - input:
400
+ # tag:
401
+ # _default: 2
402
+ # name: 1
403
+ # address:
404
+ # _default: 1
405
+
406
+ - interface: /pets(post)
407
+ bindExact: true
408
+ inputs:
409
+ - input:
410
+ pet:
411
+ _default: 1
412
+ tag: 1
413
+ - input:
414
+ pet:
415
+ _default: 1
416
+ tag: 0
417
+ - input:
418
+ pet:
419
+ _default: 1
420
+ tag: 2
421
+ - input:
422
+ pet:
423
+ _default: 1
424
+ tag: 3
425
+ - input:
426
+ pet:
427
+ _default: 1
428
+ tag: 2
429
+ # - input:
430
+ # pet:
431
+ # _default: 2
432
+
433
+ # - interface: /pets(post)
434
+ # bindExact: true
435
+ # inputs:
436
+ # - input:
437
+ # pet:
438
+ # _default: 1
439
+ # # - input:
440
+ # # pet:
441
+ # # _default: 2
442
+
443
+ EOS
444
+
445
+
446
+ EXTENSIONS_PETSTORE_RUN3 = <<-EOS
447
+ #
448
+ #
449
+
450
+ - step-extension:
451
+
452
+ - interface: /tags(post)
453
+
454
+ - interface: /pets(post)
455
+
456
+ - interface: /pets(post)
457
+ bindExact: true
458
+ inputs:
459
+ - input:
460
+ pet:
461
+ _default: 1
462
+ - input:
463
+ pet:
464
+ _default: 2
465
+
466
+
467
+ - interface: /tags(post)
468
+ input:
469
+ tag:
470
+ name: 1
471
+ address:
472
+ street: 1
473
+
474
+ - interface: /pets(post)
475
+ bindExact: true
476
+ inputs:
477
+ - input:
478
+ pet:
479
+ _default: 1
480
+ - input:
481
+ pet:
482
+ _default: 2
483
+
484
+ - interface: /tags(put)
485
+ EOS
486
+
487
+
488
+
489
+ RESOLVER_PETSTORE_DEFAULT = <<-EOS
490
+ #{Sbuilder::CliText::RESOLVER_HEADER}
491
+
492
+ # Default 'catch-all' resolver used for testing
493
+ #
494
+ # NOTICE: un-comment in sbuilder.yaml
495
+
496
+ - Name: default-relsolver
497
+ Matcher: !ruby/regexp /.*/
498
+ Rules:
499
+ - Matcher: !ruby/regexp /.*/
500
+ Domain: default_domain
501
+
502
+ EOS
503
+
504
+ RESOLVER_PETSTORE = <<-EOS
505
+ #{Sbuilder::CliText::RESOLVER_HEADER}
506
+ #
507
+ # Example mapper to Petstore example
508
+ # see #{PETSTORE_URL}
509
+
510
+ # Catch all rule
511
+
512
+ - Name: pets_default
513
+ Rules:
514
+ - Matcher: !ruby/regexp /.*/
515
+ Domain: default
516
+
517
+
518
+ # Definitions
519
+
520
+ - Name: Error
521
+ Matcher: Error
522
+ Rules:
523
+ - Matcher: code
524
+ Domain: error_codes
525
+ - Ref: pets_default
526
+
527
+ # - Name: Status
528
+ # Matcher: Status
529
+ # Rules:
530
+ # - Matcher: code
531
+ # Domain: error_codes
532
+ # - Ref: pets_default
533
+
534
+ - Name: Address
535
+ Matcher: Address
536
+ Rules:
537
+ - Matcher: street
538
+ Domain: street
539
+ - Matcher: city
540
+ Domain: city
541
+ # - Ref: pets_default
542
+
543
+ - Name: Tag
544
+ Matcher: Tag
545
+ Rules:
546
+ - Matcher: tag
547
+ Domain: id
548
+
549
+ - Name: Owner
550
+ Matcher: Owner
551
+ Rules:
552
+ - Matcher: name
553
+ Domain: owner_name
554
+
555
+
556
+ - Name: Pet
557
+ Matcher: Pet
558
+ Rules:
559
+ - Matcher: id
560
+ Domain: id
561
+ - Matcher: name
562
+ Domain: pet_name
563
+ - Matcher: tag
564
+ Domain: id
565
+
566
+
567
+ - Name: NewPet
568
+ Matcher: NewPet
569
+ Rules:
570
+ - Ref: Pet
571
+
572
+ - Name: Id-definition
573
+ Matcher: Id
574
+ Rules:
575
+ - Matcher: id
576
+ Domain: id
577
+
578
+ # operations
579
+
580
+ - Name: pets_get
581
+ Matcher: /pets(get)
582
+ Rules:
583
+ - Matcher: tags
584
+ Domain: pet_tags
585
+ - Ref: pets_default
586
+
587
+ - Name: pets_post
588
+ Matcher: /pets(post)
589
+ Rules:
590
+ - Ref: Pet
591
+ - Ref: Tag
592
+
593
+ - Name: pets_get_id
594
+ Matcher: /pets/{id}(get)
595
+ Rules:
596
+ - Ref: Pet
597
+
598
+ - Name: pets_delete_id
599
+ Matcher: /pets/{id}(delete)
600
+ Rules:
601
+ - Ref: Pet
602
+
603
+ - Name: id_type_get
604
+ Matcher: /id/{type}(get)
605
+ Rules:
606
+ - Ref: pets_default
607
+
608
+ - Name: tags_post
609
+ Matcher: /tags(post)
610
+ Rules:
611
+ - Ref: Owner
612
+
613
+ - Name: tags_put
614
+ Matcher: /tags(put)
615
+
616
+
617
+ EOS
618
+
619
+ INTERFACE_TAGS = <<-EOS
620
+ # Additional services for Petstore
621
+ #
622
+ swagger: "2.0"
623
+ info:
624
+ version: 1.0.0
625
+ title: Petstore extensions
626
+ description: A simple API for composite services
627
+ termsOfService: http://swagger.io/terms/
628
+ contact:
629
+ name: TLA Sbuilder team
630
+ email: foo@example.com
631
+ url: http://localhost
632
+ license:
633
+ name: MIT
634
+ url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
635
+ host: locahost
636
+ basePath: /api
637
+ schemes:
638
+ - http
639
+ consumes:
640
+ - application/json
641
+ produces:
642
+ - application/json
643
+ paths:
644
+ /tags:
645
+ post:
646
+ description: Creates a tag entry
647
+ parameters:
648
+ - name: tag
649
+ in: body
650
+ description: Tag to add
651
+ required: true
652
+ schema:
653
+ $ref: '#/definitions/Owner'
654
+ responses:
655
+ 200:
656
+ description: OK
657
+ schema:
658
+ $ref: '#/definitions/Tag'
659
+ default:
660
+ description: default
661
+ put:
662
+ description: Updates
663
+ parameters:
664
+ - name: tag
665
+ in: body
666
+ description: Tag to add
667
+ required: true
668
+ schema:
669
+ $ref: '#/definitions/Tag'
670
+ responses:
671
+ 200:
672
+ description: OK
673
+ schema:
674
+ $ref: '#/definitions/Tag'
675
+ default:
676
+ description: Some error
677
+ schema:
678
+ $ref: '#/definitions/Error'
679
+ definitions:
680
+ Tag:
681
+ required:
682
+ - tag
683
+ properties:
684
+ tag:
685
+ type: string
686
+ owner:
687
+ $ref: '#/definitions/Owner'
688
+ Owner:
689
+ properties:
690
+ name:
691
+ type: string
692
+ address:
693
+ $ref: '#/definitions/Address'
694
+ Address:
695
+ properties:
696
+ street:
697
+ type: string
698
+ city:
699
+ type: string
700
+ EOS
701
+
702
+ INFRASTRUCTURE_PETSTORE = <<-EOS
703
+ # Infrastrcuture services for Petstore
704
+ #
705
+ swagger: "2.0"
706
+ info:
707
+ version: 1.0.0
708
+ title: Petstore extensions
709
+ description: A simple API for composite services
710
+ termsOfService: http://swagger.io/terms/
711
+ contact:
712
+ name: TLA Sbuilder team
713
+ email: foo@example.com
714
+ url: http://localhost
715
+ license:
716
+ name: MIT
717
+ url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
718
+ host: locahost
719
+ basePath: /api
720
+ schemes:
721
+ - http
722
+ consumes:
723
+ - application/json
724
+ produces:
725
+ - application/json
726
+ paths:
727
+ /id/{type}:
728
+ get:
729
+ operationId: Generate id from sequence {type}
730
+ responses:
731
+ 200:
732
+ description: OK
733
+ schema:
734
+ $ref: '#/definitions/Id'
735
+ 404:
736
+ description: Could not generate id
737
+ schema:
738
+ $ref: '#/definitions/Error'
739
+ definitions:
740
+ Id:
741
+ required:
742
+ - id
743
+ properties:
744
+ id:
745
+ type: string
746
+ EOS
747
+
748
+ class << self
749
+
750
+ def write_files( dir, cli )
751
+ sbuilder_yaml = Sbuilder::Constants::CNF_FILE
752
+ cli.write_example( dir, sbuilder_yaml, Sbuilder::CliPet::SBUILDER_YAML_PET )
753
+ cli.write_example( dir, Sbuilder::CliPet::FILE_RESOLVER_PETSTORE, Sbuilder::CliPet::RESOLVER_PETSTORE )
754
+ cli.write_example( dir, Sbuilder::CliPet::FILE_RESOLVER_PETSTORE_DEFAULT, Sbuilder::CliPet::RESOLVER_PETSTORE_DEFAULT )
755
+ cli.write_example( dir, Sbuilder::CliPet::FILE_INFRASTRUCTURE_PETSTORE, Sbuilder::CliPet::INFRASTRUCTURE_PETSTORE )
756
+ cli.write_example( dir, Sbuilder::CliPet::FILE_INTERFACE_TAGS, Sbuilder::CliPet::INTERFACE_TAGS )
757
+ cli.write_example( dir, Sbuilder::CliPet::FILE_EXTENSIONS_PETSTORE_COMMON, Sbuilder::CliPet::EXTENSIONS_PETSTORE_COMMON )
758
+ cli.write_example( dir, Sbuilder::CliPet::FILE_EXTENSIONS_PETSTORE_RUN1, Sbuilder::CliPet::EXTENSIONS_PETSTORE_RUN1 )
759
+ cli.write_example( dir, Sbuilder::CliPet::FILE_EXTENSIONS_PETSTORE_RUN2, Sbuilder::CliPet::EXTENSIONS_PETSTORE_RUN2 )
760
+ cli.write_example( dir, Sbuilder::CliPet::FILE_EXTENSIONS_PETSTORE_RUN3, Sbuilder::CliPet::EXTENSIONS_PETSTORE_RUN3 )
761
+ cli.write_example( dir, Sbuilder::CliPet::FILE_EXTENSIONS_PETSTORE_RUN_SVG, Sbuilder::CliPet::EXTENSIONS_PETSTORE_RUN_SVG )
762
+ end
763
+ end
764
+
765
+ end
766
+ end
767
+