tla-sbuilder 0.3.4 → 0.3.7
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 +65 -70
- data/VERSION +1 -1
- data/lib/sbuilder/constants.rb +4 -4
- data/lib/sbuilder/controller.rb +232 -76
- data/lib/sbuilder/default-sbuilder.yaml +66 -22
- data/lib/sbuilder/facade/api_loader_facade.rb +47 -11
- data/lib/sbuilder/facade/facade_constants.rb +26 -0
- data/lib/sbuilder/facade/loader_plugin_root.rb +4 -1
- data/lib/sbuilder/facade/param_set_root.rb +38 -1
- data/lib/sbuilder/facade/snippet_loader_facade.rb +90 -8
- data/lib/sbuilder/factory.rb +9 -4
- data/lib/sbuilder/model.rb +25 -3
- data/lib/sbuilder/param_set.rb +8 -7
- data/mustache/cfg/const_def.mustache +2 -0
- data/mustache/{setup → config}/assumptions_activate.mustache +0 -0
- data/mustache/{setup → config}/domains_run.mustache +0 -0
- data/mustache/config/module_footer.mustache +1 -0
- data/mustache/config/module_header.mustache +10 -0
- data/mustache/{setup → config}/operator_run.mustache +0 -0
- data/mustache/{setup → config}/operator_tick.mustache +0 -0
- data/mustache/config/steps_run.mustache +43 -0
- data/mustache/{setup → config}/steps_run_bind_rule.mustache +5 -2
- data/mustache/{setup → config}/steps_run_bind_set.mustache +11 -5
- data/mustache/{setup → config}/steps_run_parameterBind.mustache +10 -4
- data/mustache/{setup → config}/steps_run_parameterExact.mustache +11 -3
- data/mustache/inherit/inherit_config.mustache +29 -0
- data/mustache/interface_processes.mustache +6 -2
- data/mustache/interfaces/interface_mapper.mustache +12 -0
- data/mustache/possibility/module_extends.mustache +1 -1
- data/mustache/possibility/operator_set_step_input.mustache +8 -0
- data/mustache/possibility/possibility_definition.mustache +4 -4
- data/mustache/possibility/possility_setup.mustache +4 -3
- data/mustache/setup/module_header.mustache +3 -1
- data/mustache/setup/operator_set_step_input.mustache +8 -0
- data/mustache/state_type_invariant-infrastructure-service.mustache +2 -2
- data/mustache/tla/const_def.mustache +1 -0
- data/mustache/tla/macro_run.mustache +10 -2
- data/mustache/tla/plc_run_state.mustache +2 -0
- data/src/pet/infrastructure_id_get.tla +6 -2
- data/src/pet/service_pet_post.tla +2 -2
- data/src/pet/service_tag_post.tla +1 -1
- data/tla-sbuilder.gemspec +1 -1
- metadata +21 -13
- data/mustache/setup/steps_run.mustache +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da5bfdebad06728053bd1d9be7b5fb8bc6bf4d5f
|
4
|
+
data.tar.gz: 1ac862f608a98cb6ae42e973ad9f9ca22e7c0cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f511f243f72f46b30cd191ad984ef858f6a62317c81fe98f05d8c97784481c707b72e1f1f06539b56e8a19784f5e75bc88641cdf63bfd44a052aba623c852011
|
7
|
+
data.tar.gz: c2844d67ae0c95aa6668abf2e52bd45f84a5edbad182faef7b5493461257d6c95fa944c80b8c53e77d5ab76174ba1023c09cde671ca59df6e407b973f9973f7c
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3.
|
4
|
+
# Sbuilder - A Specification Builder for TLA+ Tools - $Release:0.3.7$
|
5
5
|
|
6
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)
|
@@ -64,21 +64,16 @@ model:
|
|
64
64
|
* **operator**: TLA+ language constructs, which enable "to define all
|
65
65
|
the data structures and operations that occur in the specification"
|
66
66
|
|
67
|
-
* **
|
68
|
-
|
67
|
+
* **procedures**: implementation of target system application *services* as TLA
|
68
|
+
[PlusCal](http://research.microsoft.com/en-us/um/people/lamport/tla/pluscal.html)
|
69
|
+
procedures in TLA+ language
|
69
70
|
|
70
|
-
* **
|
71
|
-
|
71
|
+
* **macros**: TLA PlusCal implementation of common behavior, for
|
72
|
+
example to modify system state
|
72
73
|
|
73
|
-
* **
|
74
|
-
|
75
|
-
|
76
|
-
* **interface**: implementation of *application interface* extension
|
77
|
-
points using PlusCal macros in TLA+ language
|
78
|
-
|
79
|
-
* **correctness**: operator definitions, and INVARIANT directives in
|
80
|
-
TLA+ language specifying properties, which must be not violated in
|
81
|
-
specification executions
|
74
|
+
* **invariant**: operator definitions, and INVARIANT directives
|
75
|
+
in TLA+ language specifying properties, which must be not
|
76
|
+
violated in specification executions
|
82
77
|
|
83
78
|
* **possibility**: optional operator definitions to increase
|
84
79
|
confidence in correctness invariants
|
@@ -103,7 +98,7 @@ blueprints* are html-pages including code snippets from Sbuilder *code
|
|
103
98
|
repository*, or code generated based on *interface specifications*.
|
104
99
|
|
105
100
|
|
106
|
-
## Two Operating Modes
|
101
|
+
## <a id="OPERATING-MODES">Two Operating Modes</a>
|
107
102
|
|
108
103
|
Sbuilder supports two operating modes:
|
109
104
|
|
@@ -123,6 +118,8 @@ better understanding, 2) to get the design right, 3) and to write
|
|
123
118
|
better code for the system being
|
124
119
|
built. [more details](MODELING-PIPELINE.md)
|
125
120
|
|
121
|
+
See [sbuilder-example](https://github.com/jarjuk/sbuilder-example) for
|
122
|
+
a toy example of using sbuilder in *Modeling Pipeline* mode.
|
126
123
|
|
127
124
|
|
128
125
|
### <a id="EMBEDDED-MODE">Embedded Mode</a>
|
@@ -135,11 +132,12 @@ complexities in creating a formal model, Sbuilder can be embedded into
|
|
135
132
|
a framework, and to use implementation code in creating formal model
|
136
133
|
of the application.
|
137
134
|
|
138
|
-
An example of embedded sbuilder is
|
135
|
+
An example of embedded sbuilder is in
|
139
136
|
[sbuilder-ethereum](https://github.com/jarjuk/sbuilder-ethereum).
|
140
137
|
|
141
138
|
|
142
139
|
|
140
|
+
|
143
141
|
## <a id="USAGE">Usage</a>
|
144
142
|
|
145
143
|
### Pre-requisites
|
@@ -151,6 +149,11 @@ have Java and
|
|
151
149
|
[TLA+ Tools](http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html)
|
152
150
|
installed.
|
153
151
|
|
152
|
+
TLA+ Tools jar can be obtained from
|
153
|
+
[download page](https://tla.msr-inria.inria.fr/tlatoolbox/dist), see
|
154
|
+
[TLA+ Tools](http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html)
|
155
|
+
for more instructions on installation.
|
156
|
+
|
154
157
|
|
155
158
|
### Installation
|
156
159
|
|
@@ -166,12 +169,7 @@ and run
|
|
166
169
|
|
167
170
|
bundle install
|
168
171
|
|
169
|
-
|
170
|
-
[download page](https://tla.msr-inria.inria.fr/tlatoolbox/dist), see
|
171
|
-
[TLA+ Tools](http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html)
|
172
|
-
for more instructions on installation.
|
173
|
-
|
174
|
-
### To Use Pet Store Example Application
|
172
|
+
### <a id="PET-STORE-EXAMPLE">To Use Pet Store Example Application</a>
|
175
173
|
|
176
174
|
Create default directories used by `sbuilder` in current working directory
|
177
175
|
|
@@ -235,7 +233,7 @@ The **possibility** to reach this state can be demonstrated running
|
|
235
233
|
and observing **Error: Evaluating invariant** `possible_tag_with_invalid_address` **failed.**
|
236
234
|
|
237
235
|
|
238
|
-
### Create Own Model
|
236
|
+
### <a id="CREATE-OWN-MODEL">Create Own Model</a>
|
239
237
|
|
240
238
|
See [on-line documentation](http://jarjuk.github.io/tla-sbuilder.html)
|
241
239
|
for more details.
|
@@ -266,18 +264,39 @@ To run the model checking for setup `default` using TLA+tools jar in
|
|
266
264
|
|
267
265
|
|
268
266
|
Create TLA snippets in directory `src`, and include template snippets
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
For example, put the following code to
|
267
|
+
into Sbuilder context using Snippet Loader plugin
|
268
|
+
`Sbuilder::SnippetLoaderSimple`.
|
273
269
|
|
274
|
-
at_least_two_tags == Cardinality( v_tags ) > 1
|
275
270
|
|
276
|
-
file `src/operator_at_least_two_tags.tla
|
277
|
-
specification code by adding following line into `src/operator`
|
271
|
+
For example, put the following code into file `src/operator_at_least_two_tags.tla`
|
278
272
|
|
279
|
-
|
273
|
+
at_least_two_tags == Cardinality( v_tags ) > 1
|
280
274
|
|
275
|
+
and add configuration in `snippets` section in `cnf/sbuilder.yaml`,
|
276
|
+
which gives the class name of the plugin to use
|
277
|
+
(`Sbuilder::SnippetLoaderSimple`), defines metatype (`framework-svc`),
|
278
|
+
application name (`at_least_two_tags`), and filename of the snippet in
|
279
|
+
default `src` -directory (`operator_at_least_two_tags.tla`). The use
|
280
|
+
of metatype allows single appName to mapped to several unique
|
281
|
+
specNames by adding a metatype specific prefix to the appName. In this
|
282
|
+
example, `framework-svc` metatype adds empty prefix to appName.
|
283
|
+
|
284
|
+
snippets:
|
285
|
+
- className: Sbuilder::SnippetLoaderSimple
|
286
|
+
snippets:
|
287
|
+
|
288
|
+
- metatype: framework-svc
|
289
|
+
appName: at_least_two_tags
|
290
|
+
file: operator_at_least_two_tags.tla
|
291
|
+
|
292
|
+
|
293
|
+
Run `bundle exec sbuilder.rb generate`, and observe that
|
294
|
+
`at_least_two_tags` operator, indeed, is included into generated
|
295
|
+
formal model e.g. in file `gen/customer1/tla/model.tla`:
|
296
|
+
|
297
|
+
(* SNIPPET: framework-svc/at_least_two_tags --> at_least_two_tags *)
|
298
|
+
at_least_two_tags == Cardinality( v_tags ) > 1
|
299
|
+
(* --END OF SNIPPET-- *)
|
281
300
|
|
282
301
|
## Manage State Space Explosion, and Allow Scaling
|
283
302
|
|
@@ -313,6 +332,16 @@ option `--filter-list` to continue after parser error, and to
|
|
313
332
|
configure manually modules call flow analyzer would otherwise omit
|
314
333
|
from the specification code.
|
315
334
|
|
335
|
+
## <a id="CONFIGURATION">Configuration</a>
|
336
|
+
|
337
|
+
### <a id="SBUILDER-YAML">Main configuration file sbuilder.yaml</a>
|
338
|
+
|
339
|
+
TBD
|
340
|
+
|
341
|
+
### <a id="SETUP-CONF">Setups modeling environment</a>
|
342
|
+
|
343
|
+
TBD
|
344
|
+
|
316
345
|
## Extending Sbuilder
|
317
346
|
|
318
347
|
### <a id="API_LOADER">API Loader Extension Point</a>
|
@@ -390,46 +419,12 @@ For a plugin implementation, see an SnippetLoaderSimple example
|
|
390
419
|
|
391
420
|
* [rpsec test](spec/sbuilder/snippet_loader_simple_spec.rb)
|
392
421
|
|
422
|
+
*Snippet loader plugins* are activated in the same way as *API loader
|
423
|
+
plugins* using a configuration in `extend.loaders` -section in
|
424
|
+
`cnf/sbuilder.yaml`
|
393
425
|
|
394
|
-
|
395
|
-
[
|
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.
|
426
|
+
An example of using *Snippet Loader Plugin* was presented
|
427
|
+
[earlier](#CREATE-OWN-MODEL) in this [README](README.md).
|
433
428
|
|
434
429
|
## License
|
435
430
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/sbuilder/constants.rb
CHANGED
@@ -166,8 +166,8 @@ module Sbuilder
|
|
166
166
|
|
167
167
|
BASE_EXTENSIONS_DOMAIN = [
|
168
168
|
{
|
169
|
-
'domain' => "BOOLEAN",
|
170
|
-
'type' => 'BOOLEAN',
|
169
|
+
'domain' => Sbuilder::FacadeConstants::DOMAIN_BOOLEAN, # "BOOLEAN",
|
170
|
+
'type' => Sbuilder::FacadeConstants::DOMAIN_BOOLEAN, # 'BOOLEAN',
|
171
171
|
}
|
172
172
|
]
|
173
173
|
|
@@ -213,8 +213,8 @@ module Sbuilder
|
|
213
213
|
:allowed => %w( implementation completion ),
|
214
214
|
},
|
215
215
|
:snippet_loader_instantiate => {
|
216
|
-
:required => %w(
|
217
|
-
:allowed => %w( className objectName configuration ),
|
216
|
+
:required => %w( ),
|
217
|
+
:allowed => %w( className objectName configuration snippets ),
|
218
218
|
:one_of => %w( className objectName ),
|
219
219
|
},
|
220
220
|
:api_loader_instantiate => {
|
data/lib/sbuilder/controller.rb
CHANGED
@@ -357,7 +357,7 @@ module Sbuilder
|
|
357
357
|
begin
|
358
358
|
Utils::Validate.validateProperties( interfaceParamsetDef, Constants::VALIDATION[:api_loader_instantiate][:required], Constants::VALIDATION[:api_loader_instantiate][:allowed] )
|
359
359
|
Utils::Validate.oneOf( interfaceParamsetDef, Constants::VALIDATION[:api_loader_instantiate][:one_of_class_or_object] )
|
360
|
-
Utils::Validate.oneOf( interfaceParamsetDef, Constants::VALIDATION[:api_loader_instantiate][:one_of_file_or_url] )
|
360
|
+
# Utils::Validate.oneOf( interfaceParamsetDef, Constants::VALIDATION[:api_loader_instantiate][:one_of_file_or_url] )
|
361
361
|
|
362
362
|
# validateProperties( interfaceParamsetDef, @@interfaceLoaderDef_required, @@interfaceLoaderDef_allowed )
|
363
363
|
# validateOne( interfaceParamsetDef, @@interfaceLoaderDef_oneof )
|
@@ -448,7 +448,12 @@ module Sbuilder
|
|
448
448
|
# @todo move implementation extension to model construct phase and
|
449
449
|
# initalize symbol table herre
|
450
450
|
def load
|
451
|
-
@logger.info( "#{__method__} load started" )
|
451
|
+
@logger.info( "#{__method__} load started" )
|
452
|
+
|
453
|
+
# create sbuilder (e.g. domain BOOLEAN) + application model
|
454
|
+
# extension (literals identified in application)
|
455
|
+
baseExtensionDefine
|
456
|
+
|
452
457
|
loadResolvers( getResolversConfig )
|
453
458
|
loadInterfaces( getInterfaceConfig )
|
454
459
|
loadInvariants( getInvariantConfig )
|
@@ -456,11 +461,6 @@ module Sbuilder
|
|
456
461
|
# extract static partial calls in mustache templates into an array
|
457
462
|
resolveExtensionPartials
|
458
463
|
|
459
|
-
# create sbuilder (e.g. domain BOOLEAN) + application model
|
460
|
-
# extension (literals identified in application)
|
461
|
-
|
462
|
-
baseExtensionDefine
|
463
|
-
|
464
464
|
# create domain model i.e. resolve domains
|
465
465
|
resolve
|
466
466
|
|
@@ -470,11 +470,12 @@ module Sbuilder
|
|
470
470
|
# init symbol table with names in sbuilder & interface model
|
471
471
|
initializeSymbolTable
|
472
472
|
|
473
|
-
#
|
474
|
-
|
473
|
+
# moved to processSetup
|
474
|
+
# # snippet load extension point
|
475
|
+
# loadSnippets( getSnippetConfig )
|
475
476
|
|
476
|
-
# topological sort
|
477
|
-
sortPartials
|
477
|
+
# # topological sort
|
478
|
+
# sortPartials
|
478
479
|
|
479
480
|
end
|
480
481
|
|
@@ -547,10 +548,15 @@ module Sbuilder
|
|
547
548
|
end
|
548
549
|
end
|
549
550
|
|
551
|
+
# @see {.baseMetatypes}
|
552
|
+
def baseMetatypes
|
553
|
+
self.class.baseMetatypes
|
554
|
+
end
|
555
|
+
|
550
556
|
# @return [Hash:Array] baseMetatype definitions
|
551
557
|
# @option baseMetatype [Symbol] :name
|
552
558
|
# @option baseMetatype [Symbol] :desc
|
553
|
-
def baseMetatypes
|
559
|
+
def self.baseMetatypes
|
554
560
|
Sbuilder::Constants::META_MODEL
|
555
561
|
end
|
556
562
|
|
@@ -955,6 +961,13 @@ module Sbuilder
|
|
955
961
|
# extensions
|
956
962
|
loadExtensions( setupName )
|
957
963
|
|
964
|
+
# snippet load extension point
|
965
|
+
loadSnippets( getSnippetConfig )
|
966
|
+
|
967
|
+
# topological sort
|
968
|
+
sortPartials
|
969
|
+
|
970
|
+
|
958
971
|
# DEPREACTED # initializeSymbolTable called after extension load
|
959
972
|
# (but before generation) because 'interface-extension' sets
|
960
973
|
# META_MODEL_SERVICE_IMPLEMENTATION
|
@@ -1095,6 +1108,25 @@ module Sbuilder
|
|
1095
1108
|
#
|
1096
1109
|
def generateTemplate( setupName, outputPath, fileHandle, generateDef, mustache )
|
1097
1110
|
|
1111
|
+
str = generateTemplateString( setupName, outputPath, generateDef, mustache )
|
1112
|
+
|
1113
|
+
# output to file
|
1114
|
+
fileHandle.puts str
|
1115
|
+
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
##
|
1119
|
+
# Create string to output in {#generateTemplate}.
|
1120
|
+
#
|
1121
|
+
# @param outputPath [String] see {#generateTemplate}
|
1122
|
+
#
|
1123
|
+
#
|
1124
|
+
# @param mustache [Sbuilder::Template] see {#generateTemplate}
|
1125
|
+
#
|
1126
|
+
# @param generateDef [Hash] see {#generateTemplate}
|
1127
|
+
#
|
1128
|
+
def generateTemplateString( setupName, outputPath, generateDef, mustache )
|
1129
|
+
|
1098
1130
|
# validate configuration
|
1099
1131
|
validateProperties( generateDef, @@validGenerateDef_required, @@validGenerateDef_allowed )
|
1100
1132
|
|
@@ -1106,74 +1138,74 @@ module Sbuilder
|
|
1106
1138
|
# # Iterate each 'template' in one 'generateDef' array (most often just one template)
|
1107
1139
|
# templates = generateDef['template'].is_a?( Array ) ? generateDef['template'] : [ generateDef['template'] ]
|
1108
1140
|
template = getGenerateTemplate( generateDef )
|
1109
|
-
# @todo: remove array
|
1110
|
-
templates = [template]
|
1111
1141
|
|
1112
1142
|
# Support template paramaters
|
1113
1143
|
templateParameters = generateDef['templateParameters'].nil? ? {} : generateDef['templateParameters']
|
1114
1144
|
|
1115
1145
|
# optional parameters added in generate -section
|
1116
1146
|
renderData['PARAMETERS'] = templateParameters
|
1147
|
+
|
1148
|
+
renderData['CONFIG'] = @opts
|
1117
1149
|
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
:timestamp => Time.new.strftime( "%Y-%m-%d %H:%M:%S" ),
|
1131
|
-
:setup => setupName,
|
1132
|
-
:outputDirectory => File.dirname( outputPath ),
|
1133
|
-
:outputFile => File.basename( outputPath ),
|
1134
|
-
:outputModule => File.basename( outputPath, ".*" ),
|
1135
|
-
}
|
1136
|
-
|
1137
|
-
renderData['ACTIONS'] = {
|
1138
|
-
:cat => lambda do |path_template|
|
1139
|
-
path = mustache.render_str( path_template, renderData )
|
1140
|
-
File.readlines( path.strip ).join('')
|
1141
|
-
end,
|
1142
|
-
:dump_partials => lambda do |partial_type|
|
1143
|
-
partialNames = partials[partial_type] || []
|
1144
|
-
"#{partial_type} --> #{partialNames.join( ',' )}"
|
1145
|
-
end,
|
1150
|
+
renderData['META'] =
|
1151
|
+
{
|
1152
|
+
:desc => generateDef['desc'],
|
1153
|
+
:modelData => generateDef['modelData'],
|
1154
|
+
:template => template,
|
1155
|
+
:version => Sbuilder::version,
|
1156
|
+
:model_version => Sbuilder::model_version,
|
1157
|
+
:timestamp => Time.new.strftime( "%Y-%m-%d %H:%M:%S" ),
|
1158
|
+
:setup => setupName,
|
1159
|
+
:outputDirectory => File.dirname( outputPath ),
|
1160
|
+
:outputFile => File.basename( outputPath ),
|
1161
|
+
:outputModule => File.basename( outputPath, ".*" ),
|
1146
1162
|
}
|
1147
1163
|
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1164
|
+
renderData['ACTIONS'] = {
|
1165
|
+
:cat => lambda do |path_template|
|
1166
|
+
path = mustache.render_str( path_template, renderData )
|
1167
|
+
File.readlines( path.strip ).join('')
|
1168
|
+
end,
|
1169
|
+
:dump_partials => lambda do |partial_type|
|
1170
|
+
partialNames = partials[partial_type] || []
|
1171
|
+
"#{partial_type} --> #{partialNames.join( ',' )}"
|
1172
|
+
end,
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
# specName <- SPEC_NAME( metatype, appName )
|
1176
|
+
renderData['SPEC_NAME'] = lambda do |type_appName|
|
1177
|
+
key = mustache.render_str( type_appName, renderData )
|
1178
|
+
keys = key.split( '.' )
|
1179
|
+
begin
|
1180
|
+
return key if ( keys.length == 1 ) # just a name
|
1181
|
+
ret = getSymbolTable.lookupSymbol(keys[1], keys[0] )
|
1182
|
+
rescue Exception => ee
|
1183
|
+
msg =<<-EOS
|
1156
1184
|
Error
|
1157
1185
|
|
1158
1186
|
#{ee}
|
1159
1187
|
when accessing symbol table using key #{type_appName}
|
1160
1188
|
|
1161
1189
|
EOS
|
1162
|
-
|
1163
|
-
|
1164
|
-
end
|
1165
|
-
ret
|
1190
|
+
@logger.error( "#{__method__} #{msg}" )
|
1191
|
+
raise ControllerException.new, msg, ee.backtrace
|
1166
1192
|
end
|
1167
|
-
|
1193
|
+
ret
|
1194
|
+
end
|
1168
1195
|
|
1169
|
-
|
1170
|
-
|
1196
|
+
# snippetEntry['PARAM_SET_FIELD_DOMAIN_INIT'] = lambda do |accesKey|
|
1197
|
+
# raise "herer #{accessKey}"
|
1198
|
+
# end
|
1199
|
+
|
1171
1200
|
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1201
|
+
# support 'PREFERENCES'
|
1202
|
+
renderData.merge!( getSetupPREFERENCES(setupName) )
|
1203
|
+
|
1204
|
+
# finally render i.e. create string to output
|
1205
|
+
begin
|
1206
|
+
str = mustache.to_str( template, renderData )
|
1207
|
+
rescue Exception => ee
|
1208
|
+
msg =<<-EOS
|
1177
1209
|
Error
|
1178
1210
|
|
1179
1211
|
#{ee}
|
@@ -1183,19 +1215,126 @@ module Sbuilder
|
|
1183
1215
|
#{renderData.to_yaml}
|
1184
1216
|
|
1185
1217
|
EOS
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1218
|
+
@logger.error( "#{__method__} #{msg}" )
|
1219
|
+
raise ControllerException.new, msg, ee.backtrace
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
# Log (a little bit too early :(
|
1223
|
+
@logger.info( "#{__method__} templateName=#{template}" )
|
1224
|
+
output( 3, " ---> #{generateDef['desc']} (#{template})" )
|
1225
|
+
|
1226
|
+
# return rendersed string
|
1227
|
+
str
|
1228
|
+
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
|
1232
|
+
# def generateTemplate( setupName, outputPath, fileHandle, generateDef, mustache )
|
1233
|
+
|
1234
|
+
# # validate configuration
|
1235
|
+
# validateProperties( generateDef, @@validGenerateDef_required, @@validGenerateDef_allowed )
|
1236
|
+
|
1237
|
+
# # access data to output - and filter it
|
1238
|
+
# renderData = templateData( generateDef['modelData'] )
|
1239
|
+
# # e.g. prune interfaces not used in setup
|
1240
|
+
# renderData = setupFilter( generateDef['modelData'], renderData )
|
1241
|
+
|
1242
|
+
# # # Iterate each 'template' in one 'generateDef' array (most often just one template)
|
1243
|
+
# # templates = generateDef['template'].is_a?( Array ) ? generateDef['template'] : [ generateDef['template'] ]
|
1244
|
+
# template = getGenerateTemplate( generateDef )
|
1245
|
+
# # @todo: remove array
|
1246
|
+
# templates = [template]
|
1247
|
+
|
1248
|
+
# # Support template paramaters
|
1249
|
+
# templateParameters = generateDef['templateParameters'].nil? ? {} : generateDef['templateParameters']
|
1250
|
+
|
1251
|
+
# # optional parameters added in generate -section
|
1252
|
+
# renderData['PARAMETERS'] = templateParameters
|
1253
|
+
|
1254
|
+
# # META-data added to data to render
|
1255
|
+
# templates.each do |template|
|
1256
|
+
|
1257
|
+
# renderData['CONFIG'] = @opts
|
1258
|
+
|
1259
|
+
# renderData['META'] =
|
1260
|
+
# {
|
1261
|
+
# :desc => generateDef['desc'],
|
1262
|
+
# :modelData => generateDef['modelData'],
|
1263
|
+
# :template => template,
|
1264
|
+
# :version => Sbuilder::version,
|
1265
|
+
# :model_version => Sbuilder::model_version,
|
1266
|
+
# :timestamp => Time.new.strftime( "%Y-%m-%d %H:%M:%S" ),
|
1267
|
+
# :setup => setupName,
|
1268
|
+
# :outputDirectory => File.dirname( outputPath ),
|
1269
|
+
# :outputFile => File.basename( outputPath ),
|
1270
|
+
# :outputModule => File.basename( outputPath, ".*" ),
|
1271
|
+
# }
|
1272
|
+
|
1273
|
+
# renderData['ACTIONS'] = {
|
1274
|
+
# :cat => lambda do |path_template|
|
1275
|
+
# path = mustache.render_str( path_template, renderData )
|
1276
|
+
# File.readlines( path.strip ).join('')
|
1277
|
+
# end,
|
1278
|
+
# :dump_partials => lambda do |partial_type|
|
1279
|
+
# partialNames = partials[partial_type] || []
|
1280
|
+
# "#{partial_type} --> #{partialNames.join( ',' )}"
|
1281
|
+
# end,
|
1282
|
+
# }
|
1283
|
+
|
1284
|
+
# # specName <- SPEC_NAME( metatype, appName )
|
1285
|
+
# renderData['SPEC_NAME'] = lambda do |type_appName|
|
1286
|
+
# key = mustache.render_str( type_appName, renderData )
|
1287
|
+
# keys = key.split( '.' )
|
1288
|
+
# begin
|
1289
|
+
# ret = getSymbolTable.lookupSymbol(keys[1], keys[0] )
|
1290
|
+
# rescue Exception => ee
|
1291
|
+
# msg =<<-EOS
|
1292
|
+
# Error
|
1293
|
+
|
1294
|
+
# #{ee}
|
1295
|
+
# when accessing symbol table using key #{type_appName}
|
1189
1296
|
|
1297
|
+
# EOS
|
1298
|
+
# @logger.error( "#{__method__} #{msg}" )
|
1299
|
+
# raise ControllerException.new, msg, ee.backtrace
|
1300
|
+
# end
|
1301
|
+
# ret
|
1302
|
+
# end
|
1190
1303
|
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1304
|
+
|
1305
|
+
# # support 'PREFERENCES'
|
1306
|
+
# renderData.merge!( getSetupPREFERENCES(setupName) )
|
1307
|
+
|
1308
|
+
# # finally render i.e. create string to output
|
1309
|
+
# begin
|
1310
|
+
# str = mustache.to_str( template, renderData )
|
1311
|
+
# rescue Exception => ee
|
1312
|
+
# msg =<<-EOS
|
1313
|
+
# Error
|
1314
|
+
|
1315
|
+
# #{ee}
|
1316
|
+
|
1317
|
+
# when rendering template '#{template} using data
|
1318
|
+
|
1319
|
+
# #{renderData.to_yaml}
|
1320
|
+
|
1321
|
+
# EOS
|
1322
|
+
# @logger.error( "#{__method__} #{msg}" )
|
1323
|
+
# raise ControllerException.new, msg, ee.backtrace
|
1324
|
+
# end
|
1325
|
+
|
1195
1326
|
|
1196
|
-
|
1327
|
+
# # output to file
|
1328
|
+
# @logger.info( "#{__method__} templateName=#{template}" )
|
1329
|
+
# output( 3, " ---> #{generateDef['desc']} (#{template})" )
|
1330
|
+
# fileHandle.puts str
|
1331
|
+
|
1332
|
+
# end # templates.each
|
1333
|
+
|
1334
|
+
# end
|
1335
|
+
|
1336
|
+
|
1197
1337
|
|
1198
|
-
end
|
1199
1338
|
|
1200
1339
|
|
1201
1340
|
|
@@ -1374,16 +1513,26 @@ module Sbuilder
|
|
1374
1513
|
|
1375
1514
|
return @controller_config if @controller_config
|
1376
1515
|
|
1377
|
-
@logger.info( "#{__method__} loading config from #{getConfigFilePath}" )
|
1378
|
-
yaml_lines = Sbuilder::Utils::NetIo.read_lines( getConfigFilePath )
|
1379
|
-
@controller_config = YAML.load( yaml_lines )
|
1516
|
+
# @logger.info( "#{__method__} loading config from #{getConfigFilePath}" )
|
1517
|
+
# yaml_lines = Sbuilder::Utils::NetIo.read_lines( getConfigFilePath )
|
1518
|
+
# @controller_config = YAML.load( yaml_lines )
|
1519
|
+
@controller_config = getConfigSbuilder()
|
1380
1520
|
# allow empty generate section
|
1381
1521
|
@controller_config = {} if @controller_config.nil?
|
1382
1522
|
@controller_config['generate'] = [] unless @controller_config['generate']
|
1383
1523
|
@logger.debug( "#{__method__} config in #{getConfigFilePath} controller_config= #{@controller_config.to_yaml}" )
|
1384
1524
|
|
1385
1525
|
yaml_lines = Sbuilder::Utils::NetIo.read_lines( getInternalConfigFilePath )
|
1386
|
-
|
1526
|
+
begin
|
1527
|
+
internal_config = YAML.load( yaml_lines )
|
1528
|
+
rescue Exception => e
|
1529
|
+
msg = <<-EOS
|
1530
|
+
#{e}
|
1531
|
+
Error encountred, when parsing yaml #{yaml_lines}
|
1532
|
+
EOS
|
1533
|
+
@logger.error( "#{__method__}: #{msg}" )
|
1534
|
+
raise ControllerException.new, msg, e.backtrace
|
1535
|
+
end
|
1387
1536
|
internal_config['generate'] = [] unless internal_config['generate']
|
1388
1537
|
@logger.debug( "#{__method__} internal_config= #{internal_config.to_yaml}" )
|
1389
1538
|
|
@@ -1394,6 +1543,13 @@ module Sbuilder
|
|
1394
1543
|
@controller_config
|
1395
1544
|
end
|
1396
1545
|
|
1546
|
+
# @return [Hash] configuration parsed getConfigFilePath
|
1547
|
+
def getConfigSbuilder
|
1548
|
+
@logger.info( "#{__method__} loading config from #{getConfigFilePath}" )
|
1549
|
+
yaml_lines = Sbuilder::Utils::NetIo.read_lines( getConfigFilePath )
|
1550
|
+
return YAML.load( yaml_lines )
|
1551
|
+
end
|
1552
|
+
|
1397
1553
|
def getSetups
|
1398
1554
|
getConfig()['setups']
|
1399
1555
|
end
|
@@ -1716,7 +1872,7 @@ module Sbuilder
|
|
1716
1872
|
elsif paramSetDef['url'] then
|
1717
1873
|
return paramSetDef['url']
|
1718
1874
|
else
|
1719
|
-
|
1875
|
+
warn "Param set definition #{paramSetDef} should define 'file' or 'url'"
|
1720
1876
|
end
|
1721
1877
|
|
1722
1878
|
end
|