tla-sbuilder 0.2.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,76 @@
|
|
1
|
+
module Sbuilder
|
2
|
+
|
3
|
+
# Abstract Parent class for Sbuilder for Snippet 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
|
+
|
13
|
+
class SnippetLoaderPlugin < LoaderPluginRoot
|
14
|
+
|
15
|
+
|
16
|
+
# services to hook up framework
|
17
|
+
include SnippetLoaderPluginMixer
|
18
|
+
|
19
|
+
# def_delegator Sbuilder::SnippetLoaderPlugin, :validateProperties
|
20
|
+
|
21
|
+
# ------------------------------------------------------------------
|
22
|
+
# @!group Constructor and Object Initialize
|
23
|
+
|
24
|
+
def initialize( options = {} )
|
25
|
+
super( options )
|
26
|
+
end
|
27
|
+
|
28
|
+
# @!endgroup
|
29
|
+
|
30
|
+
# ------------------------------------------------------------------
|
31
|
+
# @!group Configure Plugin
|
32
|
+
|
33
|
+
# Configure API loader - MUST be implemented by plugin class
|
34
|
+
# @param configuration [Hash] properties to configure
|
35
|
+
|
36
|
+
def self.configure( configuration )
|
37
|
+
raise PluginException.new <<-EOS unless configuration.nil?
|
38
|
+
Plugin classes should implement class method #{__method__}
|
39
|
+
|
40
|
+
|
41
|
+
This error is raised when using 'configuration' -property in 'extend.loaders' array entry.
|
42
|
+
For example:
|
43
|
+
|
44
|
+
extend:
|
45
|
+
loaders:
|
46
|
+
- className: Sbuilder::XXXX::Plugin
|
47
|
+
gem: sbuilder-xxxx
|
48
|
+
configuration: any value
|
49
|
+
|
50
|
+
and the plugin class (e.g. Sbuilder::XXXX::Plugin) does not implement class
|
51
|
+
method '.#{__method__}'
|
52
|
+
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# @!endgroup
|
58
|
+
|
59
|
+
# ------------------------------------------------------------------
|
60
|
+
# @!group Register snippets to sbuilder
|
61
|
+
|
62
|
+
# Abstract method, which must be implemented by concrete snippet loader plugin
|
63
|
+
#
|
64
|
+
# This method should use 'handOver' method, which passes snippet,
|
65
|
+
# along with metadata, via snippet loader snippetFacade to sbuilder.
|
66
|
+
#
|
67
|
+
def doRegisterSnippets( snippetsDefs )
|
68
|
+
raise PluginException.new "Missing implementation for 'doRegisterSnippets'"
|
69
|
+
end
|
70
|
+
|
71
|
+
# @!endgroup
|
72
|
+
|
73
|
+
|
74
|
+
end # class SnippetLoaderPlugin
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Sbuilder
|
2
|
+
|
3
|
+
##
|
4
|
+
# Mixer module to include to API loader plugins
|
5
|
+
#
|
6
|
+
# Implement:
|
7
|
+
# - getter & setter for Snippet loader facade
|
8
|
+
|
9
|
+
module SnippetLoaderPluginMixer
|
10
|
+
|
11
|
+
##
|
12
|
+
# Sbuilder controller calls 'setFacade' when new API loader object
|
13
|
+
# is contstructed. Sets instance variable '@facade'.
|
14
|
+
#
|
15
|
+
# @param [Sbuilder::ApiLoaderFacade] facace to Sbuilder services
|
16
|
+
|
17
|
+
def setSnippetFacade( facade )
|
18
|
+
@snippetFacade = facade
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Sbuilder::ApiLoaderFacade] snippetFacade to access Sbuilder servivices ( set in 'setFacade')
|
22
|
+
def snippetFacade
|
23
|
+
@snippetFacade
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# A method available for plugin sub class, allowing sub class to
|
28
|
+
# register metatype prio
|
29
|
+
def registerMetatype( metatype, desc )
|
30
|
+
snippetFacade.registerMetatype( metatype, desc )
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# @param [Hash] snippetsDefs defining snippets to
|
35
|
+
# load. +snippetsDefs+ are passed un modified to plugin
|
36
|
+
# implementation
|
37
|
+
def registerSnippets( snippetsDefs )
|
38
|
+
# call implementation in concrete class
|
39
|
+
logger.info "#{__method__}, snippetsDefs=#{snippetsDefs}"
|
40
|
+
doRegisterSnippets( snippetsDefs )
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# def validateProperties( hash, required_props, allowed_props )
|
45
|
+
# SnippetLoaderPlugin.validateProperties( hash, required_props, allowed_props )
|
46
|
+
# end
|
47
|
+
|
48
|
+
def self.validateProperties( hash, required_props, allowed_props )
|
49
|
+
Sbuilder::Utils::Validate.validateProperties( hash, required_props, allowed_props )
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/sbuilder/factory.rb
CHANGED
@@ -7,7 +7,7 @@ module Sbuilder
|
|
7
7
|
@@singleton=nil # initiallly no factory object
|
8
8
|
attr_reader :options # remembers options
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :loaderPlugins # hash[Name->Class] with configure method
|
11
11
|
attr_reader :mapperRules # hash[Name->Class:ResolverRule]
|
12
12
|
attr_reader :mapperLoaders # hash[Name->Class:ResolverLoader]
|
13
13
|
attr_reader :parameters # hash[Name->Class:Parameter]
|
@@ -15,9 +15,17 @@ module Sbuilder
|
|
15
15
|
attr_reader :domains # hash[Name->Class:Domain]
|
16
16
|
attr_reader :extension_loaders # hash[Name->Class:ExtensionLoader]
|
17
17
|
|
18
|
+
# @attr [Sbuilder::SetupLoader:Array] array of setuploader
|
19
|
+
attr_reader :setup_loaders
|
20
|
+
|
21
|
+
# @attr [Hash] namedPluginObjects
|
22
|
+
# @option namedPluginObjects [String] name of ApiLoaderPlugin, SnippetLoaderPlugin
|
23
|
+
# @option namedPluginObjects [Object] object of ApiLoaderPlugin, SnippetLoaderPlugin
|
24
|
+
attr_accessor :namedPluginObjects
|
25
|
+
|
18
26
|
# ------------------------------------------------------------------
|
19
27
|
# mixer
|
20
|
-
PROGNAME =
|
28
|
+
PROGNAME = nil # progname for logger default class name
|
21
29
|
include Sbuilder::Utils::MyLogger # mix logger
|
22
30
|
|
23
31
|
|
@@ -29,34 +37,47 @@ module Sbuilder
|
|
29
37
|
@logger = getLogger( PROGNAME, options )
|
30
38
|
@logger.info( "#{__method__} initialized options=#{options}" )
|
31
39
|
@options = options
|
40
|
+
|
41
|
+
self.namedPluginObjects={}
|
32
42
|
initializeFactories
|
33
43
|
end
|
34
44
|
|
45
|
+
|
35
46
|
def initializeFactories
|
36
47
|
@extension_loaders={
|
37
48
|
Sbuilder::Constants::EXTENSION_LOADER_YAML => ExtensionLoader,
|
38
49
|
}
|
50
|
+
@setup_loaders = {
|
51
|
+
Sbuilder::Constants::SETUP_LOADER_ENVIRONMENT => SetupLoaderEnv,
|
52
|
+
Sbuilder::Constants::SETUP_LOADER_STEP => SetupLoaderEnv,
|
53
|
+
Sbuilder::Constants::SETUP_PREFERENCES_EXTENSION => SetupLoaderPref,
|
54
|
+
}
|
39
55
|
@parameters={
|
40
56
|
Sbuilder::Constants::PARAMETER => Parameter_Dom,
|
41
57
|
Sbuilder::Constants::PARAMETER_REF => Parameter_Ref,
|
42
58
|
}
|
43
59
|
@paramSets = {
|
44
60
|
Sbuilder::Constants::INTERFACE_OPERATION => ParamSet_If,
|
45
|
-
Sbuilder::Constants::
|
61
|
+
Sbuilder::Constants::DEFINITION => ParamSetDef,
|
62
|
+
Sbuilder::Constants::DEFINITION_FUNCTION => ParamSetDefFunc,
|
46
63
|
Sbuilder::Constants::PARAM_SET_STEPS => ParamSetStep,
|
47
64
|
}
|
48
65
|
|
49
|
-
@
|
66
|
+
@loaderPlugins = {
|
50
67
|
# Sbuilder::Constants::LOADER_SWAGGER => ParamSetLoaderSwagger
|
51
68
|
}
|
52
69
|
|
53
|
-
#
|
70
|
+
# add default loaders to sbuilder
|
54
71
|
addLoaders( [
|
55
|
-
{ 'gem' => '
|
72
|
+
{ 'gem' => './param_set_loader_swagger',
|
56
73
|
'className' => 'Sbuilder::ParamSetLoaderSwagger',
|
57
74
|
'configuration' => nil,
|
58
|
-
}
|
59
|
-
|
75
|
+
},
|
76
|
+
{ 'gem' => './snippet_loader_simple',
|
77
|
+
'className' => 'Sbuilder::SnippetLoaderSimple',
|
78
|
+
'configuration' => { 'src_dir' => options[:src_dir] },
|
79
|
+
},
|
80
|
+
], [ Sbuilder::Constants::LOADER_SWAGGER, nil] )
|
60
81
|
@mapperLoaders = {
|
61
82
|
Sbuilder::Constants::MAPPER_YAML => ResolverLoader_YAML
|
62
83
|
}
|
@@ -67,23 +88,42 @@ module Sbuilder
|
|
67
88
|
|
68
89
|
@domains = {
|
69
90
|
Sbuilder::Constants::TYPE_DOMAIN => Domain,
|
70
|
-
Sbuilder::Constants::
|
91
|
+
Sbuilder::Constants::TYPE_DOMAIN_TYPE => DomainType,
|
92
|
+
Sbuilder::Constants::TYPE_RANGE_DOMAIN => DomainRange,
|
93
|
+
Sbuilder::Constants::TYPE_VALUE_DOMAIN => DomainValue,
|
71
94
|
Sbuilder::Constants::TYPE_CARDINALITY_DOMAIN => DomainCardinality ,
|
72
95
|
}
|
73
96
|
|
74
97
|
end
|
75
98
|
|
76
|
-
|
99
|
+
|
100
|
+
# ------------------------------------------------------------------
|
101
|
+
# @!group Plugin extensions
|
102
|
+
|
103
|
+
# Configure additional plugin extensions
|
104
|
+
#
|
105
|
+
# @param arrOfLoaders [Hash:Array] with properties
|
106
|
+
# :name,:className
|
107
|
+
#
|
108
|
+
# @param name [String:Array] alias name to use (in addition to
|
109
|
+
# className)
|
77
110
|
#
|
78
|
-
# @param arrOfLoaders [Hash:Array] with properties :name,:className
|
79
|
-
# @param name [String:Array] alias name to use (in addition to className)
|
80
111
|
def addLoaders( arrOfLoaders, names=nil )
|
112
|
+
|
81
113
|
arrOfLoaders.each_with_index do |loader,index|
|
82
114
|
|
83
|
-
validateProperties( loader, ['className',
|
115
|
+
# validateProperties( loader, ['className', ], ['configuration', 'gem', 'objects'] )
|
116
|
+
Utils::Validate.validateProperties( loader, Constants::VALIDATION[:extend_loader][:required], Constants::VALIDATION[:extend_loader][:allowed] )
|
84
117
|
|
85
|
-
# load class module to context -
|
86
|
-
|
118
|
+
# load class module to context - unless Class already defined
|
119
|
+
if ! Class.const_defined?( loader['className'] )
|
120
|
+
Utils::Validate.validateProperties( loader, Constants::VALIDATION[:extend_loader][:required_after_classname], Constants::VALIDATION[:extend_loader][:allowed] )
|
121
|
+
if loader['gem'][0] == '.'
|
122
|
+
require_relative loader['gem']
|
123
|
+
else
|
124
|
+
require loader['gem']
|
125
|
+
end
|
126
|
+
end
|
87
127
|
|
88
128
|
begin
|
89
129
|
@logger.info "#{__method__} loader['className']=#{loader['className']}"
|
@@ -97,16 +137,98 @@ module Sbuilder
|
|
97
137
|
@logger.error( "#{__method__} #{msg}" )
|
98
138
|
raise NameError, msg, e.backtrace
|
99
139
|
end
|
100
|
-
klass.configure( loader['configuration'] )
|
101
140
|
# using className
|
102
141
|
name = loader['className']
|
103
|
-
paramSetLoaders[name] = klass
|
104
|
-
# using optional name
|
105
|
-
paramSetLoaders[names[index]] = klass if names
|
106
142
|
|
143
|
+
loaderPlugins[name] = klass
|
144
|
+
# @logger.info "#{__method__}, name=#{name}, configuration: #{loader['configuration']} "
|
145
|
+
klass.configure( loader['configuration'] )
|
146
|
+
# optional alias name
|
147
|
+
loaderPlugins[names[index]] = klass if names && names[index]
|
148
|
+
|
149
|
+
# if 'objects property defined'
|
150
|
+
loader['objects'] && loader['objects'].each do |objectConfiguration|
|
151
|
+
|
152
|
+
@logger.info "#{__method__}, objectConfiguration=#{objectConfiguration}"
|
153
|
+
|
154
|
+
Utils::Validate.validateProperties( objectConfiguration, Constants::VALIDATION[:extend_loader_object][:required], Constants::VALIDATION[:extend_loader_object][:allowed] )
|
155
|
+
|
156
|
+
# # create & configure object for 'className'
|
157
|
+
# o = klass.new( options ).configure( objectConfiguration['configuration'] )
|
158
|
+
o = getLoaderPlugin( loader['className'], objectConfiguration['configuration'] )
|
159
|
+
|
160
|
+
# add it to dictionary
|
161
|
+
@logger.info "#{__method__}, add=#{objectConfiguration['objectName']}, #{o}"
|
162
|
+
namedPluginObjects[ objectConfiguration['objectName'] ] = o
|
163
|
+
|
164
|
+
end # each object
|
165
|
+
|
166
|
+
end # each
|
167
|
+
end
|
168
|
+
|
169
|
+
# return 'objectName' plugin instance, or create new plugin object
|
170
|
+
# with 'className.new'.configure( configuration )
|
171
|
+
#
|
172
|
+
# @param [String] className name of the plugin, if nil objectName
|
173
|
+
# must be nil
|
174
|
+
#
|
175
|
+
# @param [Object] configuration to pass to className.new
|
176
|
+
#
|
177
|
+
# @param [String] objectName name of the plugin object, if nil
|
178
|
+
# className must be non nil.
|
179
|
+
#
|
180
|
+
#
|
181
|
+
# @return [ApiLoaderPlugin] plugin object instance
|
182
|
+
#
|
183
|
+
def getLoaderPlugin( className, configuration=nil, objectName=nil )
|
184
|
+
|
185
|
+
@logger.info "#{__method__}, className=#{className}, configuration=#{configuration}, objectName=#{objectName}"
|
186
|
+
|
187
|
+
raise FactoryException, "Must give either 'className' or 'objectName'" if
|
188
|
+
className.nil? && objectName.nil? || !className.nil? && !objectName.nil?
|
189
|
+
|
190
|
+
if objectName then
|
191
|
+
|
192
|
+
# get usign objectName
|
193
|
+
o = namedPluginObjects[objectName]
|
194
|
+
|
195
|
+
if o.nil? then
|
196
|
+
msg = <<-EOS
|
197
|
+
Unknown loader plugin object #{objectName}
|
198
|
+
|
199
|
+
Check array 'extend.loaders.objects' for 'objectName'
|
200
|
+
|
201
|
+
Known loader plugin object names: #{namedPluginObjects.keys.join(',')}
|
202
|
+
EOS
|
203
|
+
@logger.error( "#{__method__} #{msg}" )
|
204
|
+
raise NameError.new( msg )
|
205
|
+
|
206
|
+
end
|
207
|
+
@logger.info "#{__method__}, found #{objectName} --> #{o.class}"
|
208
|
+
return o
|
209
|
+
else
|
210
|
+
|
211
|
+
# create new 'unnamed object'
|
212
|
+
|
213
|
+
if loaderPlugins[className].nil? then
|
214
|
+
msg = <<-EOS
|
215
|
+
Unknown parameter className #{className}"
|
216
|
+
|
217
|
+
Validate classNames #{loaderPlugins.keys}
|
218
|
+
EOS
|
219
|
+
|
220
|
+
@logger.error( "#{__method__} #{msg}" )
|
221
|
+
raise NameError.new( msg )
|
222
|
+
end
|
223
|
+
newObject = loaderPlugins[className].new( options )
|
224
|
+
newObject.configure( configuration ) if configuration
|
225
|
+
return newObject
|
107
226
|
end
|
108
227
|
end
|
109
228
|
|
229
|
+
# @!endgroup
|
230
|
+
|
231
|
+
|
110
232
|
# ------------------------------------------------------------------
|
111
233
|
# singleton
|
112
234
|
class << self
|
@@ -140,29 +262,22 @@ module Sbuilder
|
|
140
262
|
return mapperLoaders[type].new( Factory.getFactory(options), options )
|
141
263
|
end
|
142
264
|
|
143
|
-
# @return [Sbuilder::
|
144
|
-
def
|
145
|
-
facade = Sbuilder::
|
265
|
+
# @return [Sbuilder::ApiLoaderFacade] api loader facade to Sbuilder
|
266
|
+
def getApiFacade( controller )
|
267
|
+
facade = Sbuilder::ApiLoaderFacade.new( Factory.getFactory(options), options )
|
268
|
+
facade.setController( controller )
|
269
|
+
return facade
|
270
|
+
end
|
271
|
+
|
272
|
+
# @return [Sbuilder::SnippetLoaderFacade] api loader facade to Sbuilder
|
273
|
+
def getSnippetFacade( controller )
|
274
|
+
facade = Sbuilder::SnippetLoaderFacade.new( Factory.getFactory(options), options )
|
146
275
|
facade.setController( controller )
|
147
276
|
return facade
|
148
277
|
end
|
149
278
|
|
150
279
|
|
151
|
-
# return object to load parameter sets
|
152
|
-
def getParamSetLoader( type )
|
153
|
-
if paramSetLoaders[type].nil? then
|
154
|
-
msg = <<-EOS
|
155
|
-
Unknown parameter type #{type}"
|
156
280
|
|
157
|
-
Validate types #{paramSetLoaders.keys}
|
158
|
-
EOS
|
159
|
-
|
160
|
-
@logger.error( "#{__method__} #{msg}" )
|
161
|
-
raise NameError.new( msg )
|
162
|
-
end
|
163
|
-
return paramSetLoaders[type].new( options )
|
164
|
-
end
|
165
|
-
|
166
281
|
# ------------------------------------------------------------------
|
167
282
|
# template reader
|
168
283
|
|
@@ -176,15 +291,21 @@ module Sbuilder
|
|
176
291
|
if options[:filter_src]
|
177
292
|
Sbuilder::TemplateContextReader.new( controller, @options )
|
178
293
|
else
|
179
|
-
|
294
|
+
getDefaultTemplateReader( controller )
|
295
|
+
# Sbuilder::TemplateReader.new( controller, @options )
|
180
296
|
end
|
181
297
|
# return @template_reader if @template_reader
|
182
298
|
# @template_reader = Sbuilder::TemplateReader.new( @options )
|
183
299
|
# @template_reader
|
184
300
|
end
|
185
301
|
|
302
|
+
# @return [TemplateReader] default reader
|
303
|
+
private def getDefaultTemplateReader( controller )
|
304
|
+
Sbuilder::TemplateReader.new( controller, @options )
|
305
|
+
end
|
306
|
+
|
186
307
|
# ------------------------------------------------------------------
|
187
|
-
#
|
308
|
+
# template
|
188
309
|
#
|
189
310
|
# @return [Template] mustache template generator
|
190
311
|
def getTemplate( reader )
|
@@ -193,31 +314,81 @@ module Sbuilder
|
|
193
314
|
# @template = Template.new( getTemplateReader, @options )
|
194
315
|
# @template
|
195
316
|
end
|
317
|
+
|
318
|
+
# @return [mustache] template to accept
|
319
|
+
def getSnippetFacadeMustache
|
320
|
+
return Mustache.new
|
321
|
+
end
|
322
|
+
|
323
|
+
|
324
|
+
# @return [Sbuilder::TemplateResolve] mustache template generator to resolver partials
|
325
|
+
def getTemplateResolver( controller )
|
326
|
+
reader = getDefaultTemplateReader( controller )
|
327
|
+
Sbuilder::TemplateResolve.new( reader, @options )
|
328
|
+
end
|
196
329
|
|
197
330
|
# ------------------------------------------------------------------
|
198
|
-
|
331
|
+
|
332
|
+
|
333
|
+
# @return [Sbuilder::Model] model created
|
199
334
|
def createModel
|
200
335
|
Sbuilder::Model.new( self, options )
|
201
336
|
end
|
337
|
+
|
338
|
+
# @return [Sbuilder::SymbolTable] symbol table created
|
339
|
+
def createSymbolTable
|
340
|
+
Sbuilder::SymbolTable.new( options )
|
341
|
+
end
|
342
|
+
|
202
343
|
|
203
344
|
# ------------------------------------------------------------------
|
204
|
-
#
|
205
|
-
|
206
|
-
|
345
|
+
# extesion loaders
|
346
|
+
|
347
|
+
# @param [String] setupName
|
348
|
+
def getExtensionLoader( type, setupName )
|
207
349
|
if extension_loaders[type].nil? then
|
208
350
|
|
209
351
|
msg = <<-EOS
|
210
|
-
Unknown extension
|
352
|
+
Unknown extension type #{type}"
|
211
353
|
|
212
|
-
Valid extension
|
354
|
+
Valid extension types #{extension_loaders.keys}
|
213
355
|
EOS
|
214
356
|
@logger.error( "#{__method__} #{msg}" )
|
215
357
|
raise NameError.new( msg )
|
216
358
|
end
|
217
|
-
extension_loaders[type].new( options )
|
359
|
+
ldr = extension_loaders[type].new( options )
|
360
|
+
ldr.setupName = setupName
|
361
|
+
ldr
|
218
362
|
# Sbuilder::ExtensionLoader.new( options )
|
219
363
|
end
|
220
364
|
|
365
|
+
# @param [String] type of controller to create
|
366
|
+
#
|
367
|
+
# @param [Sbuilder::Controller] controllre to associate with setup loader
|
368
|
+
#
|
369
|
+
# @param [String] setupName name of setup to extended
|
370
|
+
def getSetupLoader( type, controller, setupName )
|
371
|
+
if setup_loaders[type].nil? then
|
372
|
+
|
373
|
+
msg = <<-EOS
|
374
|
+
Unknown setup extension type #{type}"
|
375
|
+
|
376
|
+
Valid setup extesion types: #{setup_loaders.keys}
|
377
|
+
EOS
|
378
|
+
@logger.error( "#{__method__} #{msg}" )
|
379
|
+
raise NameError.new( msg )
|
380
|
+
end
|
381
|
+
ldr = setup_loaders[type].new( options, )
|
382
|
+
ldr.controller = controller
|
383
|
+
ldr.setupName = setupName
|
384
|
+
# Sbuilder::ExtensionLoader.new( options )
|
385
|
+
ldr
|
386
|
+
end
|
387
|
+
|
388
|
+
def getStepGenerator
|
389
|
+
Sbuilder::StepGenerator.new( options )
|
390
|
+
end
|
391
|
+
|
221
392
|
# ------------------------------------------------------------------
|
222
393
|
# mapper
|
223
394
|
|
@@ -277,6 +448,14 @@ module Sbuilder
|
|
277
448
|
parameters[type].new( options )
|
278
449
|
end
|
279
450
|
|
451
|
+
# ------------------------------------------------------------------
|
452
|
+
# parser
|
453
|
+
|
454
|
+
# @return [Sbuilder::ParserFacade] facade to parser
|
455
|
+
def createParserFacade
|
456
|
+
Sbuilder::ParserFacade.new( options )
|
457
|
+
end
|
458
|
+
|
280
459
|
# ------------------------------------------------------------------
|
281
460
|
# validate 'defintionHash' all 'required'/only 'allowed' props set
|
282
461
|
private def validateProperties( defintionHash, required, allowed=[] )
|