tla-sbuilder 0.2.2 → 0.3.4
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 +4 -4
- data/README.md +150 -116
- data/VERSION +1 -1
- data/lib/cli/cli-customer.rb +23 -3
- data/lib/cli/cli-pet.rb +66 -12
- data/lib/cli/cli-text.rb +127 -8
- data/lib/cli/cli.rb +49 -6
- data/lib/sbuilder.rb +26 -3
- data/lib/sbuilder/constants.rb +165 -6
- data/lib/sbuilder/controller.rb +943 -169
- data/lib/sbuilder/controller_utils.rb +122 -0
- data/lib/sbuilder/default-sbuilder.yaml +38 -44
- data/lib/sbuilder/domain.rb +160 -36
- data/lib/sbuilder/domain_cardinality.rb +1 -1
- data/lib/sbuilder/domain_range.rb +102 -0
- data/lib/sbuilder/domain_type.rb +150 -0
- data/lib/sbuilder/domain_value.rb +21 -13
- data/lib/sbuilder/exception.rb +16 -0
- data/lib/sbuilder/extension_loader.rb +67 -686
- data/lib/sbuilder/extension_loader_deprecated_step_extensions.rb +711 -0
- data/lib/sbuilder/extension_loader_step_generator.rb +876 -0
- data/lib/sbuilder/facade/{api_loader.rb → api_loader_facade.rb} +176 -45
- data/lib/sbuilder/facade/api_loader_plugin.rb +6 -32
- data/lib/sbuilder/facade/api_loader_plugin_mixer.rb +35 -0
- data/lib/sbuilder/facade/facade_constants.rb +23 -0
- data/lib/sbuilder/facade/loader_plugin_root.rb +56 -0
- data/lib/sbuilder/facade/param_set_root.rb +55 -0
- data/lib/sbuilder/facade/snippet_loader_facade.rb +600 -0
- data/lib/sbuilder/facade/snippet_loader_plugin.rb +76 -0
- data/lib/sbuilder/facade/snippet_loader_plugin_mixer.rb +56 -0
- data/lib/sbuilder/factory.rb +224 -45
- data/lib/sbuilder/model.rb +125 -45
- data/lib/sbuilder/mustache/template.rb +107 -58
- data/lib/sbuilder/mustache/template_reader.rb +56 -46
- data/lib/sbuilder/mustache/template_reader_context.rb +64 -234
- data/lib/sbuilder/mustache/template_resolve.rb +103 -0
- data/lib/sbuilder/mustache/template_root.rb +71 -0
- data/lib/sbuilder/param_set.rb +30 -15
- data/lib/sbuilder/param_set_db.rb +1 -1
- data/lib/sbuilder/param_set_def.rb +6 -1
- data/lib/sbuilder/param_set_def_func.rb +39 -0
- data/lib/sbuilder/param_set_if.rb +45 -10
- data/lib/sbuilder/param_set_loader_swagger.rb +56 -26
- data/lib/sbuilder/param_set_step.rb +1 -1
- data/lib/sbuilder/param_sets.rb +2 -1
- data/lib/sbuilder/parameter.rb +9 -3
- data/lib/sbuilder/parameter_container.rb +1 -1
- data/lib/sbuilder/parameter_dom.rb +17 -5
- data/lib/sbuilder/parameter_ref.rb +39 -10
- data/lib/sbuilder/parser/parser_facade.rb +310 -0
- data/lib/sbuilder/resolver.rb +11 -6
- data/lib/sbuilder/resolver_loader.rb +1 -1
- data/lib/sbuilder/resolver_loader_yaml.rb +1 -1
- data/lib/sbuilder/resolver_rule.rb +1 -1
- data/lib/sbuilder/resolver_rule_match.rb +10 -4
- data/lib/sbuilder/resolver_rule_ref.rb +1 -1
- data/lib/sbuilder/setup_loader.rb +49 -0
- data/lib/sbuilder/setup_loader_env.rb +478 -0
- data/lib/sbuilder/setup_loader_pref.rb +56 -0
- data/lib/sbuilder/snippet_loader_simple.rb +125 -0
- data/lib/sbuilder/spec/api_loader.rb +34 -0
- data/lib/sbuilder/spec/api_loader_facade.rb +169 -32
- data/lib/sbuilder/spec/loader_plugin.rb +98 -0
- data/lib/sbuilder/spec/snippet_loader.rb +228 -0
- data/lib/sbuilder/symbol_table.rb +279 -0
- data/lib/utils/{cache_lines.rb → fileio.rb} +8 -1
- data/lib/utils/logger.rb +2 -1
- data/lib/utils/powerset.rb +13 -0
- data/lib/utils/validate.rb +38 -0
- data/mustache/cfg/const_def.mustache +2 -0
- data/mustache/cfg/macro_run.mustache +1 -4
- data/mustache/data-model-header.mustache +1 -0
- data/mustache/definition_types.mustache +34 -4
- data/mustache/domains.mustache +1 -1
- data/mustache/domains_assign.mustache +1 -1
- data/mustache/infrastructure-service-init.mustache +1 -1
- data/mustache/interface_processes.mustache +16 -10
- data/mustache/interface_types.mustache +37 -11
- data/mustache/operator-infrastructure-service.mustache +1 -1
- data/mustache/resources/schedule_operator_new_step.tla +8 -0
- data/mustache/resources/schedule_process_macro.tla +37 -0
- data/mustache/resources/schedule_process_procedure.tla +22 -0
- data/mustache/resources/schedule_throw.tla +16 -0
- data/mustache/setup/domains_run.mustache +8 -2
- data/mustache/setup/operator_run.mustache +0 -4
- data/mustache/setup/steps_run.mustache +4 -3
- data/mustache/setup/steps_run_parameterBind.mustache +14 -6
- data/mustache/setup/steps_run_parameterExact.mustache +7 -3
- data/mustache/state_type_invariant-infrastructure-service.mustache +9 -4
- data/mustache/tla/const_def.mustache +1 -1
- data/mustache/tla/macro_run.mustache +7 -1
- data/mustache/tla/module_header.mustache +1 -1
- data/mustache/tla/operator_run.mustache +8 -5
- data/mustache/tla/plc_define_run.mustache +45 -36
- data/mustache/tla/plc_run_state.mustache +12 -5
- data/src-extend/extend/extend_assumptions.mustache +3 -0
- data/src-extend/extend/extend_const.mustache +3 -0
- data/src-extend/extend/extend_implementation.mustache +3 -0
- data/src-extend/extend/extend_invariant.mustache +3 -0
- data/src-extend/extend/extend_macros.mustache +3 -0
- data/src-extend/extend/extend_operations.mustache +3 -0
- data/src-extend/extend/extend_state.mustache +3 -0
- data/src/pet/extend/extend_assumptions.mustache +4 -0
- data/src/pet/extend/extend_implementation.mustache +3 -0
- data/src/pet/extend/extend_invariant.mustache +3 -0
- data/src/pet/extend/extend_macros.mustache +3 -0
- data/src/pet/extend/extend_operations.mustache +4 -0
- data/src/pet/extend/extend_state.mustache +3 -0
- data/src/pet/interface +5 -5
- data/src/pet/interface_delete_pet.tla +1 -1
- data/src/pet/interface_get_pet.tla +1 -1
- data/src/pet/interface_post_pet.tla +4 -2
- data/src/pet/interface_post_tag.tla +1 -1
- data/src/pet/interface_put_tag.tla +1 -1
- data/tla-sbuilder.gemspec +3 -3
- metadata +44 -19
- data/mustache/name_definition_type.mustache +0 -5
- data/mustache/name_domain.mustache +0 -5
- data/mustache/name_domain_value.mustache +0 -5
- data/mustache/name_domain_value_prefix.mustache +0 -5
- data/mustache/name_interface_response_type.mustache +0 -6
- data/mustache/name_interface_type.mustache +0 -6
- data/mustache/name_parameter_type.mustache +0 -6
- data/mustache/name_process.mustache +0 -6
- data/mustache/state_type_invariant.mustache +0 -17
- data/mustache/state_variables.mustache +0 -20
- data/src-extend/extend/extend_invariant_cfg.mustache +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13bb5aca53c85d8ae5b3943c8c37c23f745adc00
|
|
4
|
+
data.tar.gz: 5f22e716073199acd62eef8f1477b2562727374c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2686dae3b6360eeafa1d6f71639515f718c0f45bd43067010ea740391ab3338e5086d51f24d7d4929c7ed8499b94d3f2967ecd69b855d24f90dc935e121d3fd3
|
|
7
|
+
data.tar.gz: 9412ebeb149ca0357e0340cdadc00c7b1d55df6778764464a880274b13f1759f79c47a86c18b13162eab0a0fe4bf59ce6cd661ca63ba87048e742e1b11a5acd9
|
data/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<link href="../site.css" rel="stylesheet"></link>
|
|
2
2
|
[Readme](README.md) [Releases](RELEASES.md)
|
|
3
3
|
|
|
4
|
-
# Sbuilder - A Specification Builder for TLA+ Tools - $Release:0.
|
|
4
|
+
# Sbuilder - A Specification Builder for TLA+ Tools - $Release:0.3.4$
|
|
5
5
|
|
|
6
|
-
A tool to generate runnable
|
|
6
|
+
A tool to generate runnable formal models in
|
|
7
7
|
[TLA+ language](http://research.microsoft.com/en-us/um/people/lamport/tla/book.html)
|
|
8
|
-
for [target systems](#TARGET-SYSTEM).
|
|
9
|
-
|
|
8
|
+
for [target systems](#TARGET-SYSTEM). Formal model can be verified
|
|
9
|
+
using
|
|
10
10
|
[TLA+ Tools](http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html),
|
|
11
11
|
and parts of it can be presented as
|
|
12
12
|
[implementation blueprints](#BLUEPRINT) to developers.
|
|
@@ -14,16 +14,16 @@ and parts of it can be presented as
|
|
|
14
14
|
See
|
|
15
15
|
|
|
16
16
|
* [documentation](https://jarjuk.wordpress.com/sbuilder/) for
|
|
17
|
-
|
|
17
|
+
background information, User's Guide and Developer's Guide
|
|
18
18
|
|
|
19
|
-
* [
|
|
20
|
-
(Cucumber tests) for more details on configuring Sbuilder,
|
|
21
|
-
features implemented by Sbuilder
|
|
19
|
+
* [on-line documentation](http://jarjuk.github.io/tla-sbuilder.html)
|
|
20
|
+
(including Cucumber tests) for more details on configuring Sbuilder,
|
|
21
|
+
and on features implemented by Sbuilder
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
## <a id="TARGET-SYSTEM">Target Systems</a>
|
|
25
25
|
|
|
26
|
-
Sbuilder supports modeling
|
|
26
|
+
Sbuilder supports modeling business IT systems, where system
|
|
27
27
|
architecture identifies
|
|
28
28
|
|
|
29
29
|
* **interfaces**: entry point providing access to services within the
|
|
@@ -40,60 +40,61 @@ architecture identifies
|
|
|
40
40
|
|
|
41
41
|
## <a id="ELEMENTS-OF">Runnable Specification Code</a>
|
|
42
42
|
|
|
43
|
-
Sbuilder combines three main elements to create runnable TLA+
|
|
44
|
-
|
|
43
|
+
Sbuilder combines three main elements to create runnable TLA+ formal
|
|
44
|
+
model:
|
|
45
45
|
|
|
46
|
-
1. **
|
|
46
|
+
1. **API interfaces**: Natively Sbuilder accepts
|
|
47
47
|
[RESTfull](https://en.wikipedia.org/wiki/Representational_state_transfer)
|
|
48
48
|
interface api specification expressed in
|
|
49
49
|
[Swagger](http://swagger.io/)
|
|
50
|
-
[v2.0](http://swagger.io/specification/)
|
|
51
|
-
|
|
52
|
-
e.g. from
|
|
50
|
+
[v2.0](http://swagger.io/specification/)
|
|
51
|
+
format. [API Loader Extension Point](#API_LOADER) allows importing
|
|
52
|
+
API confiugration also from external systems, e.g. from
|
|
53
|
+
[salesforce](https://github.com/jarjuk/tla-sbuilder-salesforce)
|
|
53
54
|
|
|
54
|
-
2. **
|
|
55
|
-
snippets from Sbuilder *code repository
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
In addition, a setup may define domain cardinalities, or domain
|
|
63
|
-
values. The tools allows defining multiple setups, each setup
|
|
64
|
-
resulting to a complete, runnable TLA+ code, allowing system model
|
|
65
|
-
to be run in various environment context
|
|
55
|
+
2. **TLA Snippets**: Sbuilder tangles either manually crafted TLA
|
|
56
|
+
snippets from Sbuilder *code repository*, or snippets loaded using
|
|
57
|
+
[Snippet Loader Extension Point](#SNIPPET_LOADER), with code
|
|
58
|
+
created for *API interfaces*. *TLA -snippets* are also used to
|
|
59
|
+
specify correctness criteria for the system. Examples of *TLA
|
|
60
|
+
Snippets* are:
|
|
61
|
+
|
|
62
|
+
* **state**: TLA+ variables modeling *database*
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
* **operator**: TLA+ language constructs, which enable "to define all
|
|
65
|
+
the data structures and operations that occur in the specification"
|
|
69
66
|
|
|
70
|
-
* **
|
|
67
|
+
* **transaction**: pseudo code implementation of common behavior in
|
|
68
|
+
modifying system state
|
|
71
69
|
|
|
72
|
-
* **
|
|
73
|
-
|
|
70
|
+
* **service**: pseudo code implementation of target system
|
|
71
|
+
*application services* using PlusCal procedures in TLA+ language
|
|
74
72
|
|
|
75
|
-
* **
|
|
76
|
-
|
|
73
|
+
* **infrastructure**: pseudo code implementation of target system
|
|
74
|
+
*infrastructure services* using PlusCal procedures in TLA+ language
|
|
77
75
|
|
|
78
|
-
* **
|
|
79
|
-
|
|
76
|
+
* **interface**: implementation of *application interface* extension
|
|
77
|
+
points using PlusCal macros in TLA+ language
|
|
80
78
|
|
|
81
|
-
* **
|
|
82
|
-
|
|
79
|
+
* **correctness**: operator definitions, and INVARIANT directives in
|
|
80
|
+
TLA+ language specifying properties, which must be not violated in
|
|
81
|
+
specification executions
|
|
83
82
|
|
|
84
|
-
* **
|
|
85
|
-
|
|
83
|
+
* **possibility**: optional operator definitions to increase
|
|
84
|
+
confidence in correctness invariants
|
|
86
85
|
|
|
87
|
-
* **
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
* **assumption**: operator definitions, in TLA+ language specifying
|
|
87
|
+
properties on specification model constants, which must be not
|
|
88
|
+
violated.
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
|
|
91
|
+
3. **Setups**: To complete the runnable formal model Sbuilder uses
|
|
92
|
+
setups. A setup is a sequence of interface operations, and their
|
|
93
|
+
input parameters. Setup also define domain cardinalities, or
|
|
94
|
+
domain values. The tools allows defining multiple setups, each
|
|
95
|
+
setup resulting to a complete, runnable TLA+ code, allowing
|
|
96
|
+
application model to be run in various environment context
|
|
93
97
|
|
|
94
|
-
* **assumption**: operator definitions, in TLA+ language specifying
|
|
95
|
-
properties on specification model constants, which must be not
|
|
96
|
-
violated.
|
|
97
98
|
|
|
98
99
|
Sbuilder can generate <a id="BLUEPRINT">**implementation
|
|
99
100
|
blueprints**</a> as depicted in section
|
|
@@ -102,84 +103,48 @@ blueprints* are html-pages including code snippets from Sbuilder *code
|
|
|
102
103
|
repository*, or code generated based on *interface specifications*.
|
|
103
104
|
|
|
104
105
|
|
|
105
|
-
##
|
|
106
|
-
|
|
107
|
-
The picture below gives an overview, how Sbuilder -tool can be
|
|
108
|
-
deployed in an "mainstream" software development process.
|
|
109
|
-
|
|
110
|
-
The objective for creating a specification model is to get better
|
|
111
|
-
understanding, to get the design right, and to write better code for
|
|
112
|
-
the system being built - and thereby to justify the extra effort
|
|
113
|
-
needed in modeling.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-

|
|
117
|
-
|
|
118
|
-
We assume that services are currently implemented based on informal
|
|
119
|
-
service specification documents written in English. We also assume
|
|
120
|
-
that service interface is available in a machine readable format.
|
|
106
|
+
## Two Operating Modes
|
|
121
107
|
|
|
122
|
-
|
|
123
|
-
"Pseudo code modeling". The output of the process enhancement are
|
|
124
|
-
implementation blueprints, which are made available for developers at
|
|
125
|
-
the side of current service implementation documentation. An
|
|
126
|
-
implementation blueprint for a service contains pseudo code snippets
|
|
127
|
-
extracted from specification model, relevant for implementing a
|
|
128
|
-
particular service.
|
|
108
|
+
Sbuilder supports two operating modes:
|
|
129
109
|
|
|
130
|
-
|
|
110
|
+
* Modeling Pipeline
|
|
111
|
+
* Embedded Mode
|
|
131
112
|
|
|
132
|
-
- **accept API specification input**: Machine readable interface
|
|
133
|
-
specification is translated to TLA+ language.
|
|
134
113
|
|
|
135
|
-
|
|
136
|
-
domains. In this task, we define domain resolvers in Sbuilder -tool,
|
|
137
|
-
and add TLA+ operators, and assumptions to verify that the resulting
|
|
138
|
-
domain model conforms to service specification. In practice,
|
|
139
|
-
creating a formal domain model results in "Gaining better
|
|
140
|
-
understanding" of the informal specification.
|
|
114
|
+
### <a id="MODELING-PIPELINE">Modeling Pipeline</a>
|
|
141
115
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
service specification, as TLA+ language operators and invariants.
|
|
116
|
+
Sbuilder can be embedded into "mainstream" software development
|
|
117
|
+
process to support specification and design up-front, before actually
|
|
118
|
+
starting the implementation.
|
|
146
119
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
120
|
+
In *Modeling Pipeline* mode, Sbuilder is used to create formal
|
|
121
|
+
specification model of the application with the objectives 1) to get
|
|
122
|
+
better understanding, 2) to get the design right, 3) and to write
|
|
123
|
+
better code for the system being
|
|
124
|
+
built. [more details](MODELING-PIPELINE.md)
|
|
152
125
|
|
|
153
|
-
- **create implementation blueprint**: In the final task, modeler
|
|
154
|
-
defines web pages for implementation blueprints. A blueprint
|
|
155
|
-
collects relevant TLA+ snippets in Sbuilder code repository,
|
|
156
|
-
together with any other useful documentation, to help in
|
|
157
|
-
implementing a specific service. Web pages are made available for
|
|
158
|
-
service implementation to help developers to "Write better
|
|
159
|
-
code". Competent developers may understand TLA+ language, but, like
|
|
160
|
-
in software engineering generally, good comments in pseudo code
|
|
161
|
-
snippets will make blueprints more approachable.
|
|
162
126
|
|
|
163
127
|
|
|
164
|
-
|
|
128
|
+
### <a id="EMBEDDED-MODE">Embedded Mode</a>
|
|
165
129
|
|
|
166
|
-
|
|
167
|
-
|
|
130
|
+
Adding a separate task to create a formal specification model calls
|
|
131
|
+
for commitment, which may be
|
|
132
|
+
[hard to achieve](https://jarjuk.wordpress.com/2016/06/08/sbuilder-roadmap/)
|
|
133
|
+
in contemporary software development practices. In order to hide the
|
|
134
|
+
complexities in creating a formal model, Sbuilder can be embedded into
|
|
135
|
+
a framework, and to use implementation code in creating formal model
|
|
136
|
+
of the application.
|
|
168
137
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
to verify its correctness
|
|
138
|
+
An example of embedded sbuilder is
|
|
139
|
+
[sbuilder-ethereum](https://github.com/jarjuk/sbuilder-ethereum).
|
|
172
140
|
|
|
173
|
-
* **developer**: expert role implementing IT system interface and
|
|
174
|
-
service according to the service specification, interface definition,
|
|
175
|
-
and Sbuilder blueprint.
|
|
176
141
|
|
|
177
142
|
|
|
178
143
|
## <a id="USAGE">Usage</a>
|
|
179
144
|
|
|
180
145
|
### Pre-requisites
|
|
181
146
|
|
|
182
|
-
`Sbuilder` -tool requires Ruby 2.
|
|
147
|
+
`Sbuilder` -tool requires Ruby 2.1
|
|
183
148
|
|
|
184
149
|
To run the specification model created by Sbuilder -tool, you must
|
|
185
150
|
have Java and
|
|
@@ -272,7 +237,8 @@ and observing **Error: Evaluating invariant** `possible_tag_with_invalid_address
|
|
|
272
237
|
|
|
273
238
|
### Create Own Model
|
|
274
239
|
|
|
275
|
-
See [
|
|
240
|
+
See [on-line documentation](http://jarjuk.github.io/tla-sbuilder.html)
|
|
241
|
+
for more details.
|
|
276
242
|
|
|
277
243
|
Create default directories used by `sbuilder` in current working directory
|
|
278
244
|
|
|
@@ -325,7 +291,7 @@ controlling, how environment invokes interface operations, and in
|
|
|
325
291
|
effect, by throttling number of states generated during model
|
|
326
292
|
checking.
|
|
327
293
|
|
|
328
|
-
|
|
294
|
+
In order to avoid enumerating too large sets Sbuilder allows
|
|
329
295
|
|
|
330
296
|
* fixing input parameter bindings in an interface operation. In cases,
|
|
331
297
|
where domain sizes are not a problem, SBuilder allows TLA+ tool to
|
|
@@ -349,15 +315,21 @@ from the specification code.
|
|
|
349
315
|
|
|
350
316
|
## Extending Sbuilder
|
|
351
317
|
|
|
352
|
-
|
|
318
|
+
### <a id="API_LOADER">API Loader Extension Point</a>
|
|
319
|
+
|
|
320
|
+
Sbuilder defines an *API Loader Extension Point* to load API
|
|
321
|
+
interfaces, and data type definitions into Sbuilder context. An API
|
|
353
322
|
loader is a Ruby class
|
|
354
323
|
|
|
355
|
-
*
|
|
324
|
+
* extending [Sbuilder::ApiLoaderPlugin](lib/sbuilder/facade/api_loader_plugin.rb)
|
|
325
|
+
|
|
326
|
+
* using [Sbuilder::ApiLoader](lib/sbuilder/facade/api_loader_facade.rb)
|
|
356
327
|
facade to integrate with Sbuilder
|
|
357
328
|
|
|
358
329
|
* satisfying [`api_loader_facade` contract](lib/sbuilder/spec/api_loader_facade.rb)
|
|
359
330
|
|
|
360
|
-
*
|
|
331
|
+
* interacting with Sbuilder as demonstrated in
|
|
332
|
+
[cucumber tests](features/100-plugin-extension/010-api-loader-plugin.feature)
|
|
361
333
|
|
|
362
334
|
For a plugin implementation example, see an Swagger API loader in
|
|
363
335
|
Sbuilder:
|
|
@@ -368,9 +340,9 @@ Sbuilder:
|
|
|
368
340
|
|
|
369
341
|
For example, to activate Sbuilder API loader plugin
|
|
370
342
|
`Sbuilder::Interfaces::Salesforce::SalesforceLoader` implemented in
|
|
371
|
-
`tla-sbuilder-salesforce`
|
|
372
|
-
add the following YAML snippet
|
|
373
|
-
|
|
343
|
+
`tla-sbuilder-salesforce` GEM using configuration hash shown below,
|
|
344
|
+
add the following YAML snippet into `sbuilder.yaml` configuration file
|
|
345
|
+
`extend.loaders` -section:
|
|
374
346
|
|
|
375
347
|
extend:
|
|
376
348
|
loaders:
|
|
@@ -396,6 +368,68 @@ In the example, `file` -property points to a plugin configuration
|
|
|
396
368
|
file, and `cache` property gives name prefix for files, which the
|
|
397
369
|
plugin may use to cache API content to speed up generation phase.
|
|
398
370
|
|
|
371
|
+
### <a id="SNIPPET_LOADER">Snippet Loader Extension Point</a>
|
|
372
|
+
|
|
373
|
+
Sbuilder defines an *Snippet Loader Extension Point* to load TLA
|
|
374
|
+
snippets into Sbuilder context. An Snippet loader is a Ruby class
|
|
375
|
+
|
|
376
|
+
* extending [Sbuilder::SnippetLoaderPlugin](lib/sbuilder/facade/snippet_loader_plugin.rb)
|
|
377
|
+
|
|
378
|
+
* using [Sbuilder::SnippetLoaderFacade](lib/sbuilder/facade/snippet_loader_facade.rb)
|
|
379
|
+
facade to integrate with Sbuilder
|
|
380
|
+
|
|
381
|
+
* satisfying interface specification
|
|
382
|
+
[`snippet_loader_plugin: signature`](lib/sbuilder/spec/snippet_loader.rb)
|
|
383
|
+
|
|
384
|
+
* interacting with Sbuilder as demonstrated in
|
|
385
|
+
[cucumber tests](features/100-plugin-extension/200-snippet-loader-plugin.feature)
|
|
386
|
+
|
|
387
|
+
For a plugin implementation, see an SnippetLoaderSimple example
|
|
388
|
+
|
|
389
|
+
* [implementation](lib/sbuilder/snippet_loader_simple.rb)
|
|
390
|
+
|
|
391
|
+
* [rpsec test](spec/sbuilder/snippet_loader_simple_spec.rb)
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
For example, to activate `Sbuilder::Ethereum::Plugin` in
|
|
395
|
+
[sbuilder-ethereum](https://github.com/jarjuk/sbuilder-ethereum) GEM,
|
|
396
|
+
and to create a object instance with the name `solcLoader` use YAML
|
|
397
|
+
configuration in `sbuilder.yaml` section `extend.loaders`:
|
|
398
|
+
|
|
399
|
+
extend:
|
|
400
|
+
loaders:
|
|
401
|
+
- className: Sbuilder::Ethereum::Plugin
|
|
402
|
+
gem: sbuilder-ethereum
|
|
403
|
+
configuration:
|
|
404
|
+
solc_command: "/home/jj/work/sbuilder-ethereum/bin/solc"
|
|
405
|
+
objects:
|
|
406
|
+
- objectName: solcLoader
|
|
407
|
+
configuration:
|
|
408
|
+
preferences:
|
|
409
|
+
tla-trace: false
|
|
410
|
+
|
|
411
|
+
In this example, class method `Sbuilder::Ethereum::Plugin.configure`
|
|
412
|
+
accepts a setting `solc_command`, object method
|
|
413
|
+
`Sbuilder::Ethereum::Plugin#configure` accepts `preferences` hash with
|
|
414
|
+
a property `tla-trace`. See documentation for
|
|
415
|
+
[sbuilder-ethereum](https://github.com/jarjuk/sbuilder-ethereum) GEM
|
|
416
|
+
for more details on these settings.
|
|
417
|
+
|
|
418
|
+
Plugin `Sbuilder::Ethereum::Plugin` hooks to *API Loader Extension
|
|
419
|
+
Point* and to *Snippet Loader Extension Point*. Loading over these
|
|
420
|
+
extensions points is activated using the following `sbuilder.yaml`
|
|
421
|
+
configuration in `interfaces` and `snippets` -sections:
|
|
422
|
+
|
|
423
|
+
interfaces:
|
|
424
|
+
- objectName: solcLoader
|
|
425
|
+
url:
|
|
426
|
+
- solidity/demo1.sol
|
|
427
|
+
snippets:
|
|
428
|
+
- objectName: solcLoader
|
|
429
|
+
snippets:
|
|
430
|
+
|
|
431
|
+
Notice, how this YAML snippet uses object instance name `objectName:
|
|
432
|
+
solcLoader` defined in `extend.loaders` -section above.
|
|
399
433
|
|
|
400
434
|
## License
|
|
401
435
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.4
|
data/lib/cli/cli-customer.rb
CHANGED
|
@@ -27,6 +27,18 @@ module Sbuilder
|
|
|
27
27
|
# ------------------------------------------------------------------
|
|
28
28
|
#{Sbuilder::CliText::SBUILDER_EXTENSION}
|
|
29
29
|
|
|
30
|
+
# ------------------------------------------------------------------
|
|
31
|
+
#{Sbuilder::CliText::SBUILDER_SNIPPETS}
|
|
32
|
+
|
|
33
|
+
snippets:
|
|
34
|
+
|
|
35
|
+
- className: Sbuilder::SnippetLoaderSimple
|
|
36
|
+
snippets:
|
|
37
|
+
|
|
38
|
+
# make /customer(post) to map to name 'dummy'
|
|
39
|
+
- metatype: service_implementation
|
|
40
|
+
appName: /customers(post)
|
|
41
|
+
name: dummy
|
|
30
42
|
|
|
31
43
|
# ------------------------------------------------------------------
|
|
32
44
|
#{Sbuilder::CliText::SBUILBER_INTERFACES}
|
|
@@ -96,12 +108,20 @@ module Sbuilder
|
|
|
96
108
|
EOS
|
|
97
109
|
|
|
98
110
|
EXTENSIONS_CUSTOMER_IF = <<-EOS.unindent
|
|
111
|
+
|
|
112
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
113
|
+
|
|
99
114
|
#{Sbuilder::CliText::EXTENSION_HEADER_IF}
|
|
100
115
|
#
|
|
116
|
+
#
|
|
101
117
|
# Exampl uses dummy process, which should be replaced with real implementation
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
#
|
|
119
|
+
# DEPRECATED: use snippets property in sbuilder.yaml
|
|
120
|
+
#
|
|
121
|
+
# - interface-extension:
|
|
122
|
+
# - matcher: /customers(post)
|
|
123
|
+
# implementation: dummy
|
|
124
|
+
#
|
|
105
125
|
EOS
|
|
106
126
|
|
|
107
127
|
|
data/lib/cli/cli-pet.rb
CHANGED
|
@@ -24,6 +24,18 @@ module Sbuilder
|
|
|
24
24
|
# sbuilder
|
|
25
25
|
|
|
26
26
|
SBUILDER_YAML_PET= <<-EOS
|
|
27
|
+
# sbuilder.ymal - for pet example
|
|
28
|
+
#
|
|
29
|
+
# ------------------------------------------------------------------
|
|
30
|
+
#{Sbuilder::CliText::SBUILDER_EXTENSION}
|
|
31
|
+
extend:
|
|
32
|
+
loaders:
|
|
33
|
+
|
|
34
|
+
- className: Sbuilder::SnippetLoaderSimple
|
|
35
|
+
configuration:
|
|
36
|
+
src_dir: src/pet
|
|
37
|
+
|
|
38
|
+
# ------------------------------------------------------------------
|
|
27
39
|
#{Sbuilder::CliText::SBUILBER_INTERFACES}
|
|
28
40
|
|
|
29
41
|
interfaces:
|
|
@@ -40,6 +52,34 @@ module Sbuilder
|
|
|
40
52
|
file: #{FILE_INFRASTRUCTURE_PETSTORE}
|
|
41
53
|
|
|
42
54
|
|
|
55
|
+
# ------------------------------------------------------------------
|
|
56
|
+
#{Sbuilder::CliText::SBUILDER_SNIPPETS}
|
|
57
|
+
snippets:
|
|
58
|
+
|
|
59
|
+
- className: Sbuilder::SnippetLoaderSimple
|
|
60
|
+
snippets:
|
|
61
|
+
|
|
62
|
+
- metatype: service_implementation
|
|
63
|
+
appName: /pets(post)
|
|
64
|
+
file: interface_post_pet.tla
|
|
65
|
+
|
|
66
|
+
- metatype: service_implementation
|
|
67
|
+
appName: /pets/{id}(delete)
|
|
68
|
+
file: interface_delete_pet.tla
|
|
69
|
+
|
|
70
|
+
- metatype: service_implementation
|
|
71
|
+
appName: /pets/{id}(get)
|
|
72
|
+
file: interface_get_pet.tla
|
|
73
|
+
|
|
74
|
+
- metatype: service_implementation
|
|
75
|
+
appName: /tags(post)
|
|
76
|
+
file: interface_post_tag.tla
|
|
77
|
+
|
|
78
|
+
- metatype: service_implementation
|
|
79
|
+
appName: /tags(put)
|
|
80
|
+
file: interface_put_tag.tla
|
|
81
|
+
|
|
82
|
+
|
|
43
83
|
# ------------------------------------------------------------------
|
|
44
84
|
#{Sbuilder::CliText::SBUILDER_RESOLVERS}
|
|
45
85
|
resolvers:
|
|
@@ -300,6 +340,9 @@ module Sbuilder
|
|
|
300
340
|
EOS
|
|
301
341
|
|
|
302
342
|
EXTENSIONS_PETSTORE_COMMON = <<-EOS
|
|
343
|
+
|
|
344
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
345
|
+
|
|
303
346
|
#{Sbuilder::CliText::EXTENSION_HEADER_DOM}
|
|
304
347
|
|
|
305
348
|
#
|
|
@@ -320,25 +363,28 @@ module Sbuilder
|
|
|
320
363
|
|
|
321
364
|
#{Sbuilder::CliText::EXTENSION_HEADER_SETUP}
|
|
322
365
|
|
|
323
|
-
- interface-extension:
|
|
324
|
-
|
|
325
|
-
|
|
366
|
+
# - interface-extension:
|
|
367
|
+
# - matcher: /pets(post)
|
|
368
|
+
# implementation: post_pet
|
|
326
369
|
|
|
327
|
-
|
|
328
|
-
|
|
370
|
+
# - matcher: /pets/{id}(delete)
|
|
371
|
+
# implementation: delete_pet
|
|
329
372
|
|
|
330
|
-
|
|
331
|
-
|
|
373
|
+
# - matcher: /pets/{id}(get)
|
|
374
|
+
# implementation: get_pet
|
|
332
375
|
|
|
333
|
-
|
|
334
|
-
|
|
376
|
+
# - matcher: /tags(post)
|
|
377
|
+
# implementation: post_tag
|
|
335
378
|
|
|
336
|
-
|
|
337
|
-
|
|
379
|
+
# - matcher: /tags(put)
|
|
380
|
+
# implementation: put_tag
|
|
338
381
|
|
|
339
382
|
EOS
|
|
340
383
|
|
|
341
384
|
EXTENSIONS_PETSTORE_RUN1 = <<-EOS
|
|
385
|
+
|
|
386
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
387
|
+
|
|
342
388
|
#{Sbuilder::CliText::EXTENSION_HEADER_SETUP}
|
|
343
389
|
#
|
|
344
390
|
|
|
@@ -370,6 +416,9 @@ module Sbuilder
|
|
|
370
416
|
|
|
371
417
|
|
|
372
418
|
EXTENSIONS_PETSTORE_RUN2 = <<-EOS
|
|
419
|
+
|
|
420
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
421
|
+
|
|
373
422
|
#
|
|
374
423
|
#
|
|
375
424
|
|
|
@@ -384,8 +433,10 @@ module Sbuilder
|
|
|
384
433
|
- interface: /pets/{id}(get)
|
|
385
434
|
|
|
386
435
|
EOS
|
|
387
|
-
|
|
388
436
|
EXTENSIONS_PETSTORE_RUN_SVG = <<-EOS
|
|
437
|
+
|
|
438
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
439
|
+
|
|
389
440
|
#
|
|
390
441
|
# Just enough behaviour to create a decent graph
|
|
391
442
|
#
|
|
@@ -447,6 +498,9 @@ module Sbuilder
|
|
|
447
498
|
|
|
448
499
|
|
|
449
500
|
EXTENSIONS_PETSTORE_RUN3 = <<-EOS
|
|
501
|
+
|
|
502
|
+
#{Sbuilder::CliText::EXTENSION_HEADER_PREFS}
|
|
503
|
+
|
|
450
504
|
#
|
|
451
505
|
#
|
|
452
506
|
|