tla-sbuilder 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4731a435e4630bf464dd4d183d3a40df97e1e38
4
- data.tar.gz: 8c4e8a335e829e7df768069dfb3b276e199f2913
3
+ metadata.gz: a2598df840dc392c2decb758b1dbc7f057cd6e6a
4
+ data.tar.gz: c58a5b8370bb4571dd7d4b33f6f5acb9c8049115
5
5
  SHA512:
6
- metadata.gz: 7135b56dc4e078cc4f950402b3245e5bf239ea5718da7fd86c20f48fbdec39d00e06cc93f34fc2a8dfd90e727a5e6e6b9ddb41f212c510c9f604f28cc9a6954c
7
- data.tar.gz: ad58191062c7e450f97f2e8f51c6deddf1eed8a39378c1775a44770be3dae2708b185340ce7022e194d04edadaac308a4b289999383568381f9ed3895bcfd89a
6
+ metadata.gz: d64be8f51018a61900294b67cf884b19db0e752b98b935fde5c8c9565e9c93765afd1277896f57470153b587a44c0bb08fed3cbbf57e085dff7b68c78a58c114
7
+ data.tar.gz: 16637b1375dc71c8a281b04f42373c0e89d13805529baff758ed8e9bddf92163e697f6f2c1a3bd5824b300f3737b9843213f5f40da55122888c573ec4cb82ae0
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.2.1$
4
+ # Sbuilder - A Specification Builder for TLA+ Tools - $Release:0.2.2$
5
5
 
6
6
  A tool to generate runnable specification models in
7
7
  [TLA+ language](http://research.microsoft.com/en-us/um/people/lamport/tla/book.html)
@@ -12,23 +12,14 @@ and parts of it can be presented as
12
12
  [implementation blueprints](#BLUEPRINT) to developers.
13
13
 
14
14
  See
15
- [live documentation](http://jarjuk.github.io/tla-sbuilder/0.1.1.pre/features.html)
16
- for more details on configuring Sbuilder, and on features implemented
17
- by Sbuilder
18
15
 
19
- Blog posts giving background information on Sbuilder:
16
+ * [documentation](https://jarjuk.wordpress.com/sbuilder/) for
17
+ backgroun information, User's Guide and Developer's Guide
20
18
 
21
- * [Read an article "How Amazon uses formal methods"](https://jarjuk.wordpress.com/2016/03/03/sbuilder-1-problem):
22
- summarizes experiences Amazon has gained, when using TLA+ tools,
23
- what kind of benefits we should expect, when using formal methods to
24
- model business IT
19
+ * [live documentation](http://jarjuk.github.io/tla-sbuilder/0.2.2/features.html)
20
+ (Cucumber tests) for more details on configuring Sbuilder, and on
21
+ features implemented by Sbuilder
25
22
 
26
- * [Sbuilder introduction](https://jarjuk.wordpress.com/2016/03/03/sbuilder-2-intro/):
27
- mostly the same information as in this README
28
-
29
- * [Using Sbuilder to Model Business IT Systems](https://jarjuk.wordpress.com/2016/03/03/sbuilder-3-case/):
30
- a very loooong post demonstrating, how business IT system modeling
31
- can be done using Sbuilder
32
23
 
33
24
  ## <a id="TARGET-SYSTEM">Target Systems</a>
34
25
 
@@ -50,7 +41,7 @@ architecture identifies
50
41
  ## <a id="ELEMENTS-OF">Runnable Specification Code</a>
51
42
 
52
43
  Sbuilder combines three main elements to create runnable TLA+
53
- specification code:
44
+ Specification Code:
54
45
 
55
46
  1. **Interface specification**: Natively Sbuilder accepts
56
47
  [RESTfull](https://en.wikipedia.org/wiki/Representational_state_transfer)
@@ -281,7 +272,7 @@ and observing **Error: Evaluating invariant** `possible_tag_with_invalid_address
281
272
 
282
273
  ### Create Own Model
283
274
 
284
- See [live documentation](http://jarjuk.github.io/tla-sbuilder/0.1.1.pre/features.html) for more details.
275
+ See [cucumber test](http://jarjuk.github.io/tla-sbuilder/0.2.2/features.html) for more details.
285
276
 
286
277
  Create default directories used by `sbuilder` in current working directory
287
278
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -38,8 +38,6 @@ require_relative "sbuilder/resolver_loader.rb"
38
38
  require_relative "sbuilder/resolver_loader_yaml.rb"
39
39
 
40
40
 
41
- require_relative "sbuilder/param_set_loader_swagger.rb"
42
-
43
41
  require_relative "sbuilder/model.rb"
44
42
 
45
43
  require_relative "sbuilder/extension_loader.rb"
@@ -47,8 +45,11 @@ require_relative "sbuilder/extension_loader.rb"
47
45
  require_relative "sbuilder/factory.rb"
48
46
  require_relative "sbuilder/controller.rb"
49
47
 
48
+ require_relative "sbuilder/facade/api_loader_plugin.rb"
50
49
  require_relative "sbuilder/facade/api_loader.rb"
51
50
 
51
+ require_relative "sbuilder/param_set_loader_swagger.rb"
52
+
52
53
  require_relative "sbuilder/mustache/template_reader"
53
54
  require_relative "sbuilder/mustache/template_reader_context"
54
55
  require_relative "sbuilder/mustache/template"
@@ -12,6 +12,9 @@ module Sbuilder
12
12
 
13
13
  class ExtensionException < SbuilderException
14
14
  end
15
+
16
+ class PluginException < SbuilderException
17
+ end
15
18
 
16
19
 
17
20
  class DomainException < SbuilderException
@@ -0,0 +1,67 @@
1
+ module Sbuilder
2
+
3
+ # Abstract Parent class for Sbuilder for API loaders.
4
+ #
5
+ # Class implements following service groups
6
+ #
7
+ # - Constructor and Object Initialize
8
+ # - Framework Services for API loader
9
+ # - configure plugin
10
+ #
11
+
12
+ class ApiLoaderPlugin
13
+
14
+
15
+ include Sbuilder::Utils::MyLogger # mix logger
16
+
17
+ # ------------------------------------------------------------------
18
+ # @!group Constructor and Object Initialize
19
+
20
+ def initialize( factory, options = {} )
21
+ end
22
+
23
+ # Sbuilder controller calls 'setFacade' when new API loader object
24
+ # is contstructed. Sets instance variable '@facade' and '@logger'.
25
+ #
26
+ # @param [Sbuilder::ApiLoader] facace to Sbuilder services
27
+
28
+ def setFacade( facade )
29
+ @facade = facade
30
+ @logger = facade.createLogger( self.class.name.split('::').last )
31
+ end
32
+
33
+
34
+ # @!endgroup
35
+
36
+ # ------------------------------------------------------------------
37
+ # @!group Framework Services
38
+
39
+ # @return [Sbuilder::ApiLoader] facade to access Sbuilder servivices ( set in 'setFacade')
40
+ def facade
41
+ @facade
42
+ end
43
+
44
+ # @return [Logger] logger logging to Sbuiler log
45
+ def logger
46
+ # return STDERR logger - if logger not yet ready
47
+ Logger.new( STDERR ) unless @logger
48
+ @logger
49
+ end
50
+
51
+ # ------------------------------------------------------------------
52
+ # @!group Configure services - MUST be implement by plugin class
53
+
54
+ # Configure API loader - MUST be implemented by plugin class
55
+ # @param configuration [Hash] properties to configure
56
+
57
+ def self.configure( configuration )
58
+ raise PluginException.new <<-EOS
59
+ Plugin classes should implement method #{__method__}.
60
+ EOS
61
+ end
62
+
63
+ # @!endgroup
64
+
65
+ end # class ApiLoaderPlugin
66
+ end
67
+
@@ -9,36 +9,14 @@ module Sbuilder
9
9
 
10
10
 
11
11
 
12
- class ParamSetLoaderSwagger
12
+ class ParamSetLoaderSwagger < Sbuilder::ApiLoaderPlugin
13
13
 
14
- attr_reader :facade # [Sbuilder::ParamSetLoader]
15
- # facade to Sbuilder
16
-
17
- # ------------------------------------------------------------------
18
- # mixer
19
- PROGNAME = "LoadSwagger" # progname for logger
20
- include Sbuilder::Utils::MyLogger # mix logger
21
14
 
22
15
  # ------------------------------------------------------------------
23
16
  # constrcutore
24
17
  def initialize( options = {} )
25
- # @logger = getLogger( PROGNAME, options )
26
- # @logger.info( "#{__method__} initialized" )
27
-
28
- @facade = nil
29
-
30
18
  end
31
19
 
32
- # Facade gets injected, and used immediately to create logger
33
- # object.
34
- #
35
- # @param [Sbuilder::ApiLoader] facace to Sbuilder services
36
- #
37
- def setFacade( facade )
38
- @facade = facade
39
- #
40
- @logger = facade.createLogger( PROGNAME )
41
- end
42
20
 
43
21
  # ------------------------------------------------------------------
44
22
  # class method configure
@@ -46,15 +24,9 @@ module Sbuilder
46
24
  # @param configuration [Hash] properties to configure
47
25
  def self.configure( configuration )
48
26
  end
49
-
50
27
 
51
- # # extract 'intfractureServices' property from 'paramsetLoaderDef'
52
- # #
53
- # # @param paramsetLoaderDef [Hash] configuration in 'sbuilder.yaml'
54
- # #
55
- # def doConfigure( paramsetLoaderDef )
56
- # @infrastructureServices = true if paramsetLoaderDef['infrastructureServices']
57
- # end
28
+ # ------------------------------------------------------------------
29
+ # Loader methods
58
30
 
59
31
  # @param yamlFileUri [String] path or url to YAML file to process
60
32
  def readLines( yamlFileUri )
@@ -68,7 +40,7 @@ module Sbuilder
68
40
  # @param yamlFileUri [String] path or url to YAML file to process
69
41
 
70
42
  def load( yamlFileUri )
71
- @logger.info( "#{__method__} yamlFileUri=#{yamlFileUri}" )
43
+ logger.info( "#{__method__} yamlFileUri=#{yamlFileUri}" )
72
44
 
73
45
  begin
74
46
 
@@ -117,7 +89,7 @@ module Sbuilder
117
89
  def doLoadInterfaces( swagger_hash )
118
90
 
119
91
  interface_paramsSets = parseInterfaces( swagger_hash )
120
- @logger.info( "#{__method__} loaded=#{interface_paramsSets.length} interface_paramsSets" )
92
+ logger.info( "#{__method__} loaded=#{interface_paramsSets.length} interface_paramsSets" )
121
93
 
122
94
  interface_paramsSets.each do |interface|
123
95
  facade.modelInterface( interface )
@@ -185,7 +157,7 @@ module Sbuilder
185
157
  expandedDocs.each do |expandedDoc|
186
158
  # puts "#----->{op}-expandedDoc->#{expandedDoc}"
187
159
  expandedDoc.each do |parameterName,parameterProps|
188
- @logger.debug( "#{__method__} {op}-parameterName->#{parameterName}, parameterProps=>#{parameterProps}" )
160
+ logger.debug( "#{__method__} {op}-parameterName->#{parameterName}, parameterProps=>#{parameterProps}" )
189
161
  if hasRef( parameterProps ) then
190
162
  reference_parameter( paramSet, parameterName, getRefDocumentName( parameterProps ), parameterProps['type'] )
191
163
  else
@@ -206,7 +178,7 @@ module Sbuilder
206
178
  #
207
179
  def parseInterfaces( swagger_hash )
208
180
 
209
- @logger.info( "#{__method__} starting" )
181
+ logger.info( "#{__method__} starting" )
210
182
 
211
183
  # collect all interface paramsets together
212
184
  interfaces = []
@@ -220,8 +192,8 @@ module Sbuilder
220
192
  interfaceParamSet = facade.newInterface( path, op )
221
193
  paramSetResponse = interfaceParamSet.response
222
194
 
223
- @logger.info( "#{__method__} created interfaceParamSet=#{interfaceParamSet.getId}" )
224
- @logger.debug( "#{__method__} created interfaceParamSet.getId=#{interfaceParamSet.getId}, opdef=#{opdef}" )
195
+ logger.info( "#{__method__} created interfaceParamSet=#{interfaceParamSet.getId}" )
196
+ logger.debug( "#{__method__} created interfaceParamSet.getId=#{interfaceParamSet.getId}, opdef=#{opdef}" )
225
197
 
226
198
  # collect
227
199
  interfaces << interfaceParamSet
@@ -230,7 +202,7 @@ module Sbuilder
230
202
  # input paramters: 'paths'/<path>/<op>/'parameters'
231
203
 
232
204
  opdef['parameters'] && opdef['parameters'].map do |parameter|
233
- @logger.debug( "#{__method__} path/op #{path}/#{op} - parameter #{parameter}" )
205
+ logger.debug( "#{__method__} path/op #{path}/#{op} - parameter #{parameter}" )
234
206
  if parameter['schema'] then
235
207
  # in='body' => schema defined
236
208
  defintionReferenceName = getReferencedDefinitionName( parameter['schema'], swagger_hash )
@@ -239,7 +211,7 @@ module Sbuilder
239
211
  simple_parameter( interfaceParamSet, parameter['name'], parameter['type'] ) if parameter['name']
240
212
  else
241
213
  msg = "Empty parameter definition on #{path}/#{op} "
242
- @logger.error( "#{__method__} #{msg}" )
214
+ logger.error( "#{__method__} #{msg}" )
243
215
  warn msg
244
216
  end
245
217
 
@@ -253,11 +225,11 @@ module Sbuilder
253
225
 
254
226
  if response['schema'] then
255
227
  defintionReferenceName = getReferencedDefinitionName( response['schema'], swagger_hash )
256
- @logger.debug( "#{__method__} defintionReferenceName=#{defintionReferenceName}, op=#{op}, status_code=#{status_code}, response=#{response}" )
228
+ logger.debug( "#{__method__} defintionReferenceName=#{defintionReferenceName}, op=#{op}, status_code=#{status_code}, response=#{response}" )
257
229
  reference_parameter( paramSetResponse, "status_#{status_code}", defintionReferenceName, response['schema']['type'] )
258
230
 
259
231
  else
260
- @logger.debug( "#{path}-#{op}-#{status_code}: no response data for response #{response}" )
232
+ logger.debug( "#{path}-#{op}-#{status_code}: no response data for response #{response}" )
261
233
  # response object
262
234
  end
263
235
  end # responses
@@ -284,7 +256,7 @@ module Sbuilder
284
256
 
285
257
  swagger_parameter = facade.newParameterReference( name, defintionReferenceName, parameterType == 'array' )
286
258
 
287
- @logger.info( "#{__method__} param set =#{paramSet.getId}, parameter=#{swagger_parameter.getName}, parameter=#{swagger_parameter.reference}" )
259
+ logger.info( "#{__method__} param set =#{paramSet.getId}, parameter=#{swagger_parameter.getName}, parameter=#{swagger_parameter.reference}" )
288
260
 
289
261
  # add to parameter set
290
262
  paramSet.addParameter( swagger_parameter )
@@ -393,7 +365,7 @@ module Sbuilder
393
365
 
394
366
  # get document pointed by 'ref' in 'swagger_hash'
395
367
  def getDefinitionDoc( ref, swagger_hash )
396
- @logger.info( "#{__method__} ref=#{ref}" )
368
+ logger.info( "#{__method__} ref=#{ref}" )
397
369
 
398
370
  # currently supports only local references
399
371
  raise "Not valid local ref #{ref} in #{schemaObject}" unless valid_local_ref( ref )
@@ -403,7 +375,7 @@ module Sbuilder
403
375
 
404
376
  # puts "pathElements=#{pathElements} for ref=#{ref} in #{refs}"
405
377
  defininedDoc = swagger_hash.traverse( *pathElements )
406
- @logger.debug( "#{__method__} ref=#{ref} --> defininedDoc=#{defininedDoc}" )
378
+ logger.debug( "#{__method__} ref=#{ref} --> defininedDoc=#{defininedDoc}" )
407
379
  raise "Could not resolve definition reference '#{ref}'" if defininedDoc.nil?
408
380
  defininedDoc
409
381
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tla-sbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jarjuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
@@ -135,6 +135,7 @@ files:
135
135
  - lib/sbuilder/exception.rb
136
136
  - lib/sbuilder/extension_loader.rb
137
137
  - lib/sbuilder/facade/api_loader.rb
138
+ - lib/sbuilder/facade/api_loader_plugin.rb
138
139
  - lib/sbuilder/factory.rb
139
140
  - lib/sbuilder/model.rb
140
141
  - lib/sbuilder/mustache/template.rb