potrubi 0.0.3 → 0.0.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.
- data/lib/potrubi.rb +1 -1
- data/lib/potrubi/bootstrap.rb +1 -1
- data/lib/potrubi/core.rb +3 -3
- data/lib/potrubi/dsl.rb +86 -0
- data/lib/potrubi/dsl/accessor.rb +76 -0
- data/lib/potrubi/dsl/cache_2d.rb +811 -0
- data/lib/potrubi/dsl/contract.rb +731 -0
- data/lib/potrubi/dsl/super.rb +517 -0
- data/lib/potrubi/klass/syntax/alias.rb +150 -0
- data/lib/potrubi/klass/syntax/braket.rb +115 -25
- data/lib/potrubi/klass/syntax/builder.rb +45 -0
- data/lib/potrubi/klass/syntax/method.rb +436 -0
- data/lib/potrubi/klass/syntax/mixin/name_generation.rb +85 -0
- data/lib/potrubi/klass/syntax/mixin/new_aliases.rb +76 -0
- data/lib/potrubi/klass/syntax/mixin/new_brakets.rb +89 -0
- data/lib/potrubi/klass/syntax/mixin/new_methods.rb +158 -0
- data/lib/potrubi/klass/syntax/mixin/new_snippets.rb +74 -0
- data/lib/potrubi/klass/syntax/mixin/new_statements.rb +0 -0
- data/lib/potrubi/klass/syntax/mixin/statement_management.rb +69 -0
- data/lib/potrubi/klass/syntax/mixin/synel_management.rb +168 -0
- data/lib/potrubi/klass/syntax/snippet.rb +386 -0
- data/lib/potrubi/klass/syntax/statement.rb +91 -0
- data/lib/potrubi/klass/syntax/super.rb +88 -0
- data/lib/potrubi/mixin/bootstrap_common.rb +38 -12
- data/lib/potrubi/mixin/configuration.rb +31 -3
- data/lib/potrubi/mixin/contract.rb +5 -14
- data/lib/potrubi/mixin/contract/recipes.rb +307 -0
- data/lib/potrubi/mixin/dynamic-recipes.rb +1 -11
- data/lib/potrubi/mixin/dynamic.rb +223 -115
- data/lib/potrubi/mixin/exception.rb +3 -22
- data/lib/potrubi/mixin/filesys.rb +5 -21
- data/lib/potrubi/mixin/initialize.rb +11 -6
- data/lib/potrubi/mixin/konstant.rb +14 -118
- data/lib/potrubi/mixin/logger.rb +28 -41
- data/lib/potrubi/mixin/pathandnames.rb +4 -34
- data/lib/potrubi/mixin/persistence.rb +115 -10
- data/lib/potrubi/mixin/script.rb +0 -5
- data/lib/potrubi/mixin/{text-snippets → snippet-dictionaries}/methods-text-snippets.rb +138 -49
- data/lib/potrubi/mixin/{text-snippets.rb → snippet-manager.rb} +51 -39
- data/lib/potrubi/mixin/util.rb +66 -20
- data/lib/potrubi/version.rb +1 -1
- data/test/potrubi/mixin/bootstrap_common.rb +205 -0
- data/test/potrubi/mixin/konstant.rb +216 -0
- data/test/potrubi/mixin/logger.rb +124 -0
- data/test/ts_bootstrap_mixins.rb +16 -0
- data/test/ts_core_mixins.rb +7 -0
- metadata +31 -6
- data/lib/potrubi/mixin/contract-recipes.rb +0 -226
data/lib/potrubi.rb
CHANGED
data/lib/potrubi/bootstrap.rb
CHANGED
@@ -6,7 +6,7 @@ requireList.each {|r| require_relative "mixin/#{r}"}
|
|
6
6
|
|
7
7
|
mixinContent = Module.new do
|
8
8
|
|
9
|
-
# Include the mixins
|
9
|
+
# Include the mixins because of class method usage
|
10
10
|
|
11
11
|
includeList = [Potrubi::Mixin::Logger,
|
12
12
|
Potrubi::Mixin::BootstrapCommon,
|
data/lib/potrubi/core.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
|
2
|
-
# Core Mixin
|
2
|
+
# Potrubi Core Mixin
|
3
3
|
|
4
4
|
require_relative 'bootstrap'
|
5
5
|
|
6
|
-
requireList = %w(dynamic
|
6
|
+
requireList = %w(dynamic snippet-manager exception contract konstant pathandnames)
|
7
7
|
requireList.each {|r| require_relative "mixin/#{r}"}
|
8
8
|
|
9
9
|
mixinContent = Module.new do
|
10
10
|
|
11
|
-
# Include the mixins
|
11
|
+
# Include the mixins because of class method usage
|
12
12
|
|
13
13
|
includeList = [Potrubi::Bootstrap,
|
14
14
|
Potrubi::Mixin::Dynamic,
|
data/lib/potrubi/dsl.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
# potrubi dsl
|
3
|
+
|
4
|
+
# to ease the creation of verbs, accessors, etc in class bodies
|
5
|
+
|
6
|
+
# Uses conventions for names etc dedined by (in) verb mixin
|
7
|
+
|
8
|
+
require_relative './bootstrap'
|
9
|
+
|
10
|
+
requireList = %w(mixin/util dsl/super)
|
11
|
+
requireList.each {|r| require_relative "#{r}"}
|
12
|
+
|
13
|
+
classMethods = Module.new do
|
14
|
+
|
15
|
+
include Potrubi::Bootstrap
|
16
|
+
include Potrubi::Mixin::Util
|
17
|
+
|
18
|
+
def dsl(dslTarget, dslDefs=nil, &dslBlok)
|
19
|
+
eye = :'DSL::dsl'
|
20
|
+
|
21
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(dslTarget: dslTarget, dslDefs: dslDefs, dslBlok: dslBlok))
|
22
|
+
|
23
|
+
require_relative "dsl"
|
24
|
+
|
25
|
+
potrubi_bootstrap_mustbe_module_or_croak(dslTarget, eye)
|
26
|
+
|
27
|
+
dslDefs && potrubi_bootstrap_mustbe_hash_or_croak(dslDefs, eye)
|
28
|
+
|
29
|
+
if Kernel.block_given? then
|
30
|
+
|
31
|
+
dslVerb = Potrubi::DSL::Super.new_verb({target: dslTarget, verb: :Super}, dslDefs, &dslBlok)
|
32
|
+
|
33
|
+
dslVerb.assert
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_mx(eye, potrubi_bootstrap_logger_fmt_who(dslTarget: dslTarget, dslDefs: dslDefs))
|
38
|
+
|
39
|
+
self
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
instanceMethods = Module.new do
|
46
|
+
|
47
|
+
include Potrubi::Bootstrap
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
@to_s ||= potrubi_bootstrap_logger_fmt(potrubi_bootstrap_logger_instance_telltale('PotDSL'))
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initialization
|
54
|
+
# ##############
|
55
|
+
|
56
|
+
def initialize(dslArgs=nil, &dslBlok)
|
57
|
+
eye = :'ctx_dsl i'
|
58
|
+
|
59
|
+
dslAttr = 'wantbeused'
|
60
|
+
|
61
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(dslArgs: dslArgs, dslBlok: dslBlok))
|
62
|
+
|
63
|
+
case dslArgs
|
64
|
+
when NilClass then nil
|
65
|
+
when Hash then potrubi_bootstrap_mustbe_hash_or_croak(dslArgs, eye).each {|k, v| __send__("#{k}=", v) }
|
66
|
+
else
|
67
|
+
potrubi_bootstrap_surprise_exception(dslArgs, eye, "dslArgs is what?")
|
68
|
+
end
|
69
|
+
|
70
|
+
Kernel.block_given? && instance_eval(&dslBlok)
|
71
|
+
|
72
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_mx(eye, potrubi_bootstrap_logger_fmt_who(subVerbs: get_subverbs.size, dslArgs: dslArgs, dslBlok: dslBlok))
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
module Potrubi
|
79
|
+
class DSL
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Potrubi::DSL.__send__(:include, instanceMethods) # Instance Methods
|
84
|
+
Potrubi::DSL.extend(classMethods) # Class Methods
|
85
|
+
|
86
|
+
__END__
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
# potrubi contract dsl
|
3
|
+
|
4
|
+
# to ease the creation of contracts, accessors, etc in class bodies
|
5
|
+
|
6
|
+
# Uses conventions for names etc dedined by (in) contract mixin
|
7
|
+
|
8
|
+
requireList = %w(contract ../mixin/util)
|
9
|
+
requireList.each {|r| require_relative "#{r}"}
|
10
|
+
require "potrubi/klass/syntax/braket"
|
11
|
+
|
12
|
+
instanceMethods = Module.new do
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
potrubi_bootstrap_logger_fmt(potrubi_bootstrap_logger_instance_telltale('DSLAcc'), potrubi_bootstrap_logger_fmt(n: name))
|
16
|
+
end
|
17
|
+
|
18
|
+
def type_handlers
|
19
|
+
puts "ACCESSOR TYPE_HANDLERS"
|
20
|
+
@type_handlers ||=
|
21
|
+
begin
|
22
|
+
{
|
23
|
+
accessor: :accessor,
|
24
|
+
}.each_with_object({}) {|(k,v), h| h[k] = "make_contract_description_#{v}_or_croak".to_sym }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def express_or_croak
|
29
|
+
make_contract_description_accessor_or_croak
|
30
|
+
end
|
31
|
+
|
32
|
+
# Accessor Handlers
|
33
|
+
# #################
|
34
|
+
|
35
|
+
def make_contract_description_accessor_or_croak(descArgs=nil, &descBlok)
|
36
|
+
eye = :'DSLAcc::m_ctx_desc_acc'
|
37
|
+
|
38
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
39
|
+
|
40
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ms(eye, potrubi_bootstrap_logger_fmt_who(default: default))
|
41
|
+
|
42
|
+
descContract = case
|
43
|
+
when (descDefault = default) then
|
44
|
+
descDefaultText = case descDefault
|
45
|
+
when NilClass then 'nil'
|
46
|
+
when String then "'#{descDefault}'" # need quotes
|
47
|
+
when Symbol then ":#{descDefault}" # need to supply colon
|
48
|
+
when Proc then descDefault.call
|
49
|
+
else
|
50
|
+
descDefault.to_s
|
51
|
+
end
|
52
|
+
{name => {edit: {ACCESSOR_DEFAULT: descDefaultText}, spec: spec}}
|
53
|
+
|
54
|
+
else
|
55
|
+
{name => type}
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descContract: descContract, descArgs: descArgs, descBlok: descBlok))
|
60
|
+
|
61
|
+
descContract
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
module Potrubi
|
68
|
+
class DSL
|
69
|
+
class Accessor < Potrubi::DSL::Contract
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Potrubi::DSL::Accessor.__send__(:include, instanceMethods) # Instance Methods
|
75
|
+
|
76
|
+
__END__
|
@@ -0,0 +1,811 @@
|
|
1
|
+
|
2
|
+
# potrubi contract dsl
|
3
|
+
|
4
|
+
# to ease the creation of a 2d cache (e.g. hash) with named methods
|
5
|
+
# and using contracts
|
6
|
+
|
7
|
+
# Uses conventions for names etc dedined by (in) contract mixin
|
8
|
+
|
9
|
+
requireList = %w(../klass/syntax/builder ../mixin/util ../klass/syntax/method)
|
10
|
+
requireList.each {|r| require_relative "#{r}"}
|
11
|
+
|
12
|
+
classMethods = Module.new do
|
13
|
+
|
14
|
+
def prepare_order(*a, &b)
|
15
|
+
@prepare_order ||= {
|
16
|
+
validate: :validate,
|
17
|
+
name: :prepare_name,
|
18
|
+
scope: :prepare_scope,
|
19
|
+
}.each_with_object({}) {|(k,v),h| h[k] = "#{v}_or_croak".to_sym }
|
20
|
+
end
|
21
|
+
|
22
|
+
def syntax_order(*a, &b)
|
23
|
+
@syntax_order ||= {
|
24
|
+
scope: :scope,
|
25
|
+
add: :add,
|
26
|
+
delete: :delete,
|
27
|
+
each: :each,
|
28
|
+
select: :select,
|
29
|
+
size: :size,
|
30
|
+
}.each_with_object({}) {|(k,v),h| h[k] = "make_syntax_#{v}_or_croak".to_sym }
|
31
|
+
end
|
32
|
+
|
33
|
+
def syntax_builder
|
34
|
+
@syntax_builder ||= Potrubi::Klass::Syntax::Builder
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
instanceMethods = Module.new do
|
40
|
+
|
41
|
+
include Potrubi::Mixin::Util
|
42
|
+
|
43
|
+
attr_accessor :singular_name, :plural_name
|
44
|
+
attr_accessor :scope
|
45
|
+
attr_accessor :key, :key_n, :key_v, :key_validate_method, :key_normalise_method
|
46
|
+
attr_accessor :value, :value_n, :value_v, :value_validate_method, :value_normalise_method
|
47
|
+
attr_accessor :cache_variable, :cache_container, :cache_validate_method, :cache_new_method, :cache_instance_variable, :cache_local_variable
|
48
|
+
|
49
|
+
# Find Accessor Methods
|
50
|
+
# #####################
|
51
|
+
|
52
|
+
findAttrs = {
|
53
|
+
name: :symbol,
|
54
|
+
singular_name: :symbol,
|
55
|
+
plural_name: :symbol,
|
56
|
+
key_v: :symbol,
|
57
|
+
value_v: :symbol,
|
58
|
+
}
|
59
|
+
|
60
|
+
findAttrsTexts = findAttrs.map do | attrName, attrCtx |
|
61
|
+
"def find_#{attrName}_or_croak
|
62
|
+
r = potrubi_bootstrap_mustbe_#{attrCtx}_or_croak(#{attrName}, :'f_#{attrName}')
|
63
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(:'f_#{attrName}', potrubi_bootstrap_logger_fmt_who('#{attrName}' => r))
|
64
|
+
r
|
65
|
+
end
|
66
|
+
"
|
67
|
+
end
|
68
|
+
|
69
|
+
findAttrsText = findAttrsTexts.flatten.compact.join("\n")
|
70
|
+
|
71
|
+
module_eval(findAttrsText)
|
72
|
+
|
73
|
+
findNames = {
|
74
|
+
singular: :symbol,
|
75
|
+
plural: :symbol,
|
76
|
+
}
|
77
|
+
|
78
|
+
findNamesTexts = findNames.map do | nameName, nameCtx |
|
79
|
+
"
|
80
|
+
def find_#{nameName}_or_croak_method_name_or_croak(*names)
|
81
|
+
r = syntax_builder.name_builder_method_or_croak(*names, find_#{nameName}_name_or_croak)
|
82
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(:'f_#{nameName}_or_croak_method_name', potrubi_bootstrap_logger_fmt_who('#{nameName}' => r))
|
83
|
+
r
|
84
|
+
end
|
85
|
+
def find_#{nameName}_method_name_or_croak(*names)
|
86
|
+
r = syntax_builder.name_builder_method(*names, find_#{nameName}_name_or_croak)
|
87
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(:'f_#{nameName}_method_name', potrubi_bootstrap_logger_fmt_who('#{nameName}' => r))
|
88
|
+
r
|
89
|
+
end
|
90
|
+
"
|
91
|
+
end
|
92
|
+
|
93
|
+
findNamesText = findNamesTexts.flatten.compact.join("\n")
|
94
|
+
|
95
|
+
module_eval(findNamesText)
|
96
|
+
|
97
|
+
def edits
|
98
|
+
@edits ||= []
|
99
|
+
end
|
100
|
+
|
101
|
+
def specs
|
102
|
+
@specs ||= []
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_edits_or_croak(*newEdits)
|
106
|
+
eye = :a_edits
|
107
|
+
newEditsNrm = newEdits.flatten.compact
|
108
|
+
newEdistNrm.each {|a| potrubi_bootstrap_mustbe_hash_or_croak(a) } # validate
|
109
|
+
curEdits = edits.concat(newEditsNrm) # concat updates self
|
110
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(curEdits: curEdits, newEdits: newEditsNrm))
|
111
|
+
curEdits
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_specs_or_croak(*newSpecs)
|
115
|
+
eye = :a_specs
|
116
|
+
newSpecsNrm = newSpecs.flatten.compact
|
117
|
+
newSpecsNrm.each {|a| potrubi_bootstrap_mustbe_hash_or_croak(a) } # validate
|
118
|
+
curSpecs = specs.concat(newSpecsNrm) # concat updates self
|
119
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(curSpecs: curSpecs, newSpecs: newSpecsNrm))
|
120
|
+
curSpecs
|
121
|
+
end
|
122
|
+
|
123
|
+
def reduce_specs_or_croak
|
124
|
+
eye = :'rdc_specs'
|
125
|
+
|
126
|
+
specHash = potrubi_util_reduce_hashes_or_croak(*specs)
|
127
|
+
|
128
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(specHash: specHash))
|
129
|
+
|
130
|
+
specHash
|
131
|
+
end
|
132
|
+
|
133
|
+
def make_syntax_specs_or_croak
|
134
|
+
eye = 'DSL:C2d:m_syn_specs'
|
135
|
+
|
136
|
+
syntaxSpecs = reduce_specs_or_croak.values.map {|s| s.to_s }.join("\n")
|
137
|
+
|
138
|
+
syntaxSpecs
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def to_s
|
144
|
+
potrubi_bootstrap_logger_fmt(potrubi_bootstrap_logger_instance_telltale('DSLC2d'), potrubi_bootstrap_logger_fmt(n: name))
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def type_handlers
|
149
|
+
@type_handlers ||=
|
150
|
+
begin
|
151
|
+
{
|
152
|
+
d2: :prepare,
|
153
|
+
}.each_with_object({}) {|(k,v), h| h[k] = "#{v}_or_croak".to_sym }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def assert_self
|
158
|
+
prepare_or_croak
|
159
|
+
express
|
160
|
+
end
|
161
|
+
|
162
|
+
def express
|
163
|
+
make_syntax_or_croak
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
# Prepare Methods
|
169
|
+
# ###############
|
170
|
+
|
171
|
+
|
172
|
+
def prepare_or_croak(descArgs=nil, &descBlok)
|
173
|
+
eye = :'DSLC2d::pro'
|
174
|
+
|
175
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
176
|
+
|
177
|
+
prepareOrder = self.class.prepare_order(type)
|
178
|
+
|
179
|
+
prepareOrder.each {|k, v| __send__(v, k) }
|
180
|
+
|
181
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
182
|
+
|
183
|
+
self
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
def normalise_cache_name_or_croak(cacheName=nil)
|
188
|
+
cacheName ? cacheName.to_s.to_sym : nil
|
189
|
+
end
|
190
|
+
|
191
|
+
def pluralise_cache_name_or_croak(cacheSingularName)
|
192
|
+
"#{cacheSingularName}_plu_name"
|
193
|
+
end
|
194
|
+
|
195
|
+
def singularise_cache_name_or_croak(cachePluralName)
|
196
|
+
"#{cachePluralName}_snl_name"
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
def prepare_name_or_croak(prcsArgs=nil, &prcsBlok)
|
201
|
+
eye = :'DSLC2d::pre_name'
|
202
|
+
|
203
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(prcsArgs: prcsArgs, prcsBlok: prcsBlok))
|
204
|
+
|
205
|
+
cacheName = find_name_or_croak
|
206
|
+
|
207
|
+
cacheSingularName = normalise_cache_name_or_croak(singular_name)
|
208
|
+
cachePluralName = normalise_cache_name_or_croak(plural_name)
|
209
|
+
|
210
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ms(eye, 'PRE NORM', potrubi_bootstrap_logger_fmt_who(cacheName: cacheName, cacheSingularName: cacheSingularName, cachePluralName: cachePluralName))
|
211
|
+
|
212
|
+
# cache name expected to be the plural name
|
213
|
+
|
214
|
+
cachePluralName ||= cacheName
|
215
|
+
|
216
|
+
cacheSingularName ||= singularise_cache_name_or_croak(cachePluralName)
|
217
|
+
|
218
|
+
|
219
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ms(eye, 'POST NORM', potrubi_bootstrap_logger_fmt_who(cacheName: cacheName, cacheSingularName: cacheSingularName, cachePluralName: cachePluralName))
|
220
|
+
|
221
|
+
cacheSingularNameNrm = normalise_cache_name_or_croak(cacheSingularName)
|
222
|
+
cachePluralNameNrm = normalise_cache_name_or_croak(cachePluralName)
|
223
|
+
|
224
|
+
potrubi_bootstrap_mustbe_symbol_or_croak(cacheSingularNameNrm)
|
225
|
+
potrubi_bootstrap_mustbe_symbol_or_croak(cachePluralNameNrm)
|
226
|
+
|
227
|
+
(cacheSingularNameNrm == cachePluralNameNrm) && potrubi_bootstrap_duplicate_exception(cacheSingularNameNrm, eye, "singular and plural names the same")
|
228
|
+
|
229
|
+
self.singular_name = cacheSingularNameNrm
|
230
|
+
self.plural_name = cachePluralNameNrm
|
231
|
+
|
232
|
+
self
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
def prepare_scope_or_croak(prcsArgs=nil, &prcsBlok)
|
237
|
+
eye = :'DSLC2d::pro_scope'
|
238
|
+
|
239
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(prcsArgs: prcsArgs, prcsBlok: prcsBlok))
|
240
|
+
|
241
|
+
cacheName = name
|
242
|
+
cacheScope = scope
|
243
|
+
|
244
|
+
scopeVariable = case cacheScope
|
245
|
+
when :local then "@LOCAL_CACHE_VARIABLE_#{cacheName}_#{rand(1000000000)}".downcase
|
246
|
+
when :global then "$POTRUBI_GLOBAL_CACHE_VARIABLE_#{cacheName}".upcase
|
247
|
+
else
|
248
|
+
potrubi_bootstrap_surprise_exception(cacheScope, eye, "cacheScope >#{cacheScope}< is what?")
|
249
|
+
end
|
250
|
+
|
251
|
+
self.cache_variable = scopeVariable
|
252
|
+
|
253
|
+
self.cache_instance_variable ||= :cache_store # name of the instance variable holding the cache in getter/setter
|
254
|
+
self.cache_local_variable ||= :cacheStore # name of the local variable for the cache
|
255
|
+
|
256
|
+
cacheContainer = (cache_container || :hash).to_s.capitalize
|
257
|
+
|
258
|
+
case cacheContainer
|
259
|
+
when 'Hash' then
|
260
|
+
self.cache_validate_method ||= 'potrubi_bootstrap_mustbe_hash_or_croak'
|
261
|
+
self.cache_new_method ||= '{}'
|
262
|
+
else
|
263
|
+
self.cache_new_method ||= "#{cacheContainer}.new"
|
264
|
+
end
|
265
|
+
|
266
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(cacheName: cacheName, scopeVariable: scopeVariable, cacheScope: cacheScope))
|
267
|
+
|
268
|
+
self
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
# Syntax Methods
|
274
|
+
# ##############
|
275
|
+
|
276
|
+
def make_syntax_or_croak(descArgs=nil, &descBlok)
|
277
|
+
eye = :'DSLC2d::m_syn'
|
278
|
+
|
279
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
280
|
+
|
281
|
+
syntaxOrder = self.class.syntax_order(type)
|
282
|
+
|
283
|
+
syntaxOrder.each {|k, v| __send__(v, k) }
|
284
|
+
|
285
|
+
make_syntax_specs_or_croak
|
286
|
+
|
287
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
288
|
+
|
289
|
+
self
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
# Scope Syntax Methods
|
294
|
+
# ####################
|
295
|
+
|
296
|
+
def make_syntax_scope_or_croak(descArgs=nil, &descBlok)
|
297
|
+
eye = :'DSLC2d::m_syn_scope'
|
298
|
+
|
299
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
300
|
+
|
301
|
+
syntaxBuilder = syntax_builder
|
302
|
+
|
303
|
+
cacheName = find_name_or_croak
|
304
|
+
|
305
|
+
cacheVariable = cache_variable
|
306
|
+
cacheInstanceVariable = cache_instance_variable
|
307
|
+
cacheNewMethod = cache_new_method
|
308
|
+
cacheValidateMethod = cache_validate_method
|
309
|
+
|
310
|
+
syntaxScopeGetter = syntaxBuilder.new_method do
|
311
|
+
|
312
|
+
getter_name cacheName
|
313
|
+
|
314
|
+
getter_eye cacheName
|
315
|
+
|
316
|
+
syntaxCacheVariable = named_expression :assign_if_not_set, cacheVariable, cacheNewMethod
|
317
|
+
|
318
|
+
assign_instance_variable cacheInstanceVariable, syntaxCacheVariable
|
319
|
+
|
320
|
+
syntaxCacheInstanceVariable = instance_variable cacheInstanceVariable
|
321
|
+
|
322
|
+
logger_call who_only: {cacheInstanceVariable => syntaxCacheInstanceVariable}
|
323
|
+
|
324
|
+
result syntaxCacheInstanceVariable
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
syntaxScopeSetter = nil
|
329
|
+
|
330
|
+
syntaxScopeSetter = syntaxBuilder.new_method do
|
331
|
+
|
332
|
+
setter_name cacheName
|
333
|
+
|
334
|
+
setter_eye cacheName
|
335
|
+
|
336
|
+
signature :newCache
|
337
|
+
|
338
|
+
syntaxCacheInstanceVariable = instance_variable cacheInstanceVariable
|
339
|
+
|
340
|
+
assign_instance_variable cacheInstanceVariable,
|
341
|
+
named_expression(:method_call, cacheValidateMethod, get_signature)
|
342
|
+
|
343
|
+
|
344
|
+
logger_call who_only: {cacheInstanceVariable => syntaxCacheInstanceVariable}
|
345
|
+
|
346
|
+
result syntaxCacheInstanceVariable
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
add_specs_or_croak(scope_getter: syntaxScopeGetter, scope_setter: syntaxScopeSetter)
|
351
|
+
|
352
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
353
|
+
|
354
|
+
self
|
355
|
+
|
356
|
+
end
|
357
|
+
|
358
|
+
# Add Syntax Methods
|
359
|
+
# ##################
|
360
|
+
|
361
|
+
# add is semantically merge
|
362
|
+
|
363
|
+
def normalise_and_validate_method_map
|
364
|
+
@normalise_and_validate_method_map ||= { key_normalise_method: :nVal,
|
365
|
+
value_normalise_method: :vVal,
|
366
|
+
key_validate_method: :nVal,
|
367
|
+
value_validate_method: :vVal,
|
368
|
+
}
|
369
|
+
end
|
370
|
+
|
371
|
+
def make_syntax_add_or_croak(descArgs=nil, &descBlok)
|
372
|
+
eye = :'DSLC2d::m_syn_add'
|
373
|
+
|
374
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
375
|
+
|
376
|
+
syntaxBuilder = syntax_builder
|
377
|
+
|
378
|
+
self.key_normalise_method = 'key_norm_thd' # TESTING
|
379
|
+
self.value_validate_method = 'val_val_mth'
|
380
|
+
|
381
|
+
add_specs_or_croak(add_multiple_or_croak: make_syntax_add_plural_or_croak,
|
382
|
+
add_multiple_rescue: syntaxBuilder.new_method_rescue(:add, find_plural_name_or_croak),
|
383
|
+
add_single_or_croak:
|
384
|
+
syntaxBuilder.new_method_caller_callee(caller: find_singular_or_croak_method_name_or_croak(:add),
|
385
|
+
callee: find_plural_or_croak_method_name_or_croak(:add),
|
386
|
+
caller_sig: [:x, :y],
|
387
|
+
callee_args: '{x => y}',
|
388
|
+
),
|
389
|
+
add_singular_rescue: syntaxBuilder.new_method_rescue(:add, find_singular_name_or_croak),
|
390
|
+
|
391
|
+
add_merge_aliases:
|
392
|
+
syntaxBuilder.new_aliases(find_plural_or_croak_method_name_or_croak(:add) => find_plural_method_name_or_croak(:merge),
|
393
|
+
)
|
394
|
+
|
395
|
+
)
|
396
|
+
|
397
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
398
|
+
|
399
|
+
self
|
400
|
+
|
401
|
+
end
|
402
|
+
|
403
|
+
def make_syntax_add_plural_or_croak(descArgs=nil, &descBlok)
|
404
|
+
eye = :'DSLC2d::m_syn_add_plu'
|
405
|
+
|
406
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
407
|
+
|
408
|
+
syntaxBuilder = syntax_builder
|
409
|
+
|
410
|
+
cacheName = find_name_or_croak
|
411
|
+
cachePluralName = find_plural_name_or_croak
|
412
|
+
|
413
|
+
cacheInstanceVariable = cache_instance_variable
|
414
|
+
cacheLocalVariable = cache_local_variable
|
415
|
+
|
416
|
+
syntaxAddPLUOrCroak = syntaxBuilder.new_method(parent: self) do
|
417
|
+
|
418
|
+
syntaxCacheInstanceVariable = instance_variable cacheInstanceVariable
|
419
|
+
|
420
|
+
croak_name :add, cachePluralName
|
421
|
+
|
422
|
+
set_eye :a, cachePluralName
|
423
|
+
|
424
|
+
signature :args_and_block, :add
|
425
|
+
|
426
|
+
contracts addArgs: :hash
|
427
|
+
|
428
|
+
assign_local_variable cacheLocalVariable, name_builder_method_getter(cacheName)
|
429
|
+
|
430
|
+
iterator :each, :addValues, :nVal, :vVal do
|
431
|
+
|
432
|
+
snippet "
|
433
|
+
#{cacheLocalVariable}[nVal] = case
|
434
|
+
when (r = #{cacheInstanceVariable}.has_key?(nVal)) then
|
435
|
+
Kernel.block_given? ? addBlok.call(nVal, r, vVal) : potrubi_bootstrap_duplicate_exception(nVal, eye, 'nVal seen twice')
|
436
|
+
else
|
437
|
+
vVal
|
438
|
+
end
|
439
|
+
"
|
440
|
+
|
441
|
+
end
|
442
|
+
|
443
|
+
logger_call who_only: {cacheInstanceVariable => syntaxCacheInstanceVariable}
|
444
|
+
|
445
|
+
set_result_self
|
446
|
+
|
447
|
+
end
|
448
|
+
|
449
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
450
|
+
|
451
|
+
syntaxAddPLUOrCroak
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
# Delete Syntax Methods
|
456
|
+
# ##################
|
457
|
+
|
458
|
+
def make_syntax_delete_or_croak(descArgs=nil, &descBlok)
|
459
|
+
eye = :'DSLC2d::m_syn_delete'
|
460
|
+
|
461
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
462
|
+
|
463
|
+
syntaxBuilder = syntax_builder
|
464
|
+
|
465
|
+
self.key_normalise_method = 'key_norm_thd' # TESTING
|
466
|
+
self.value_validate_method = 'val_val_mth'
|
467
|
+
|
468
|
+
add_specs_or_croak(
|
469
|
+
delete_multiple_or_croak: make_syntax_delete_plural_or_croak,
|
470
|
+
delete_multiple_rescue: syntaxBuilder.new_method_rescue(:delete, find_plural_name_or_croak),
|
471
|
+
|
472
|
+
delete_single_or_croak:
|
473
|
+
syntaxBuilder.new_method_caller_callee(caller: find_singular_or_croak_method_name_or_croak(:delete),
|
474
|
+
callee: find_plural_or_croak_method_name_or_croak(:delete),
|
475
|
+
caller_sig: [:x, :y],
|
476
|
+
callee_args: '{x => y}',
|
477
|
+
),
|
478
|
+
delete_singular_rescue: syntaxBuilder.new_method_rescue(:delete, find_singular_name_or_croak),
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
)
|
483
|
+
|
484
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
485
|
+
|
486
|
+
self
|
487
|
+
|
488
|
+
end
|
489
|
+
|
490
|
+
def make_syntax_delete_plural_or_croak(descArgs=nil, &descBlok)
|
491
|
+
eye = :'DSLC2d::m_syn_delete_plu'
|
492
|
+
|
493
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
494
|
+
|
495
|
+
syntaxBuilder = syntax_builder
|
496
|
+
|
497
|
+
cacheName = find_name_or_croak
|
498
|
+
cachePluralName = find_plural_name_or_croak
|
499
|
+
|
500
|
+
cacheInstanceVariable = cache_instance_variable
|
501
|
+
cacheLocalVariable = cache_local_variable
|
502
|
+
|
503
|
+
syntaxDeletePLUOrCroak = syntaxBuilder.new_method(parent: self) do
|
504
|
+
|
505
|
+
syntaxCacheInstanceVariable = instance_variable cacheInstanceVariable
|
506
|
+
|
507
|
+
croak_name :delete, cachePluralName
|
508
|
+
|
509
|
+
set_eye :d, cachePluralName
|
510
|
+
|
511
|
+
signature :values_and_block, :del
|
512
|
+
|
513
|
+
assign_local_variable cacheLocalVariable, name_builder_method_getter(cacheName)
|
514
|
+
|
515
|
+
snippet "
|
516
|
+
deleteResult = delValues.flatten.compact.each_with_object({}) {|k,h| #{cacheLocalVariable}.has_key?(k) && (h[k] = #{cacheLocalVariable}[k]) }
|
517
|
+
"
|
518
|
+
|
519
|
+
logger_call who_only: {'deleteResult' => :deleteResult}
|
520
|
+
|
521
|
+
result :deleteResult
|
522
|
+
|
523
|
+
end
|
524
|
+
|
525
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
526
|
+
|
527
|
+
syntaxDeletePLUOrCroak
|
528
|
+
|
529
|
+
end
|
530
|
+
|
531
|
+
|
532
|
+
# Each Syntax Methods
|
533
|
+
# ###################
|
534
|
+
|
535
|
+
def make_syntax_each_or_croak(descArgs=nil, &descBlok)
|
536
|
+
eye = :'DSLC2d::m_syn_each'
|
537
|
+
|
538
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
539
|
+
|
540
|
+
syntaxBuilder = syntax_builder
|
541
|
+
|
542
|
+
add_specs_or_croak(each: make_syntax_each_singular_or_croak)
|
543
|
+
|
544
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
545
|
+
|
546
|
+
self
|
547
|
+
|
548
|
+
end
|
549
|
+
|
550
|
+
def make_syntax_each_singular_or_croak(descArgs=nil, &descBlok)
|
551
|
+
eye = :'DSLC2d::m_syn_each_snl'
|
552
|
+
|
553
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
554
|
+
|
555
|
+
syntaxBuilder = syntax_builder
|
556
|
+
|
557
|
+
cacheName = find_name_or_croak
|
558
|
+
cacheSingularName = find_singular_name_or_croak
|
559
|
+
|
560
|
+
cacheInstanceVariable = cache_instance_variable
|
561
|
+
cacheLocalVariable = cache_local_variable
|
562
|
+
|
563
|
+
syntaxEachSNLOrCroak = syntaxBuilder.new_method(parent: self) do
|
564
|
+
|
565
|
+
name :each, cacheSingularName
|
566
|
+
|
567
|
+
set_eye :e, cacheSingularName
|
568
|
+
|
569
|
+
signature :args_and_block, :each
|
570
|
+
|
571
|
+
assign_local_variable cacheLocalVariable, name_builder_method_getter(cacheName)
|
572
|
+
|
573
|
+
snippet "
|
574
|
+
eachResult = case
|
575
|
+
when Kernel.block_given? then
|
576
|
+
#{cacheLocalVariable}.each {|v| yield v }
|
577
|
+
self
|
578
|
+
else
|
579
|
+
#{cacheLocalVariable}.to_enum(:each)
|
580
|
+
end
|
581
|
+
"
|
582
|
+
|
583
|
+
logger_call who_only: {'eachResult' => :eachResult}
|
584
|
+
|
585
|
+
result :eachResult
|
586
|
+
|
587
|
+
end
|
588
|
+
|
589
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
590
|
+
|
591
|
+
syntaxEachSNLOrCroak
|
592
|
+
|
593
|
+
end
|
594
|
+
|
595
|
+
# Select / Reject Syntax Methods
|
596
|
+
# ##############################
|
597
|
+
|
598
|
+
def make_syntax_select_or_croak(descArgs=nil, &descBlok)
|
599
|
+
eye = :'DSLC2d::m_syn_select'
|
600
|
+
|
601
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
602
|
+
|
603
|
+
syntaxBuilder = syntax_builder
|
604
|
+
|
605
|
+
add_specs_or_croak(select: make_syntax_select_plural_or_croak,
|
606
|
+
reject: make_syntax_reject_plural_or_croak)
|
607
|
+
|
608
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
609
|
+
|
610
|
+
self
|
611
|
+
|
612
|
+
end
|
613
|
+
|
614
|
+
def make_syntax_select_plural_or_croak(descArgs=nil, &descBlok)
|
615
|
+
eye = :'DSLC2d::m_syn_select_snl'
|
616
|
+
|
617
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
618
|
+
|
619
|
+
syntaxBuilder = syntax_builder
|
620
|
+
|
621
|
+
cacheName = find_name_or_croak
|
622
|
+
cachePluralName = find_plural_name_or_croak
|
623
|
+
|
624
|
+
cacheLocalVariable = cache_local_variable
|
625
|
+
|
626
|
+
syntaxSelectPLUOrCroak = syntaxBuilder.new_method(parent: self) do
|
627
|
+
|
628
|
+
name :select, cachePluralName
|
629
|
+
|
630
|
+
set_eye :sel, cachePluralName
|
631
|
+
|
632
|
+
signature :args_and_block, :sel
|
633
|
+
|
634
|
+
assign_local_variable cacheLocalVariable, name_builder_method_getter(cacheName)
|
635
|
+
|
636
|
+
snippet "
|
637
|
+
selectResult = case
|
638
|
+
when Kernel.block_given? then #{cacheLocalVariable}.select {|v| yield v }
|
639
|
+
else
|
640
|
+
#{cacheLocalVariable}.to_enum(:each)
|
641
|
+
end
|
642
|
+
"
|
643
|
+
|
644
|
+
logger_call who_only: {'selectResult' => :selectResult}
|
645
|
+
|
646
|
+
result :selectResult
|
647
|
+
|
648
|
+
end
|
649
|
+
|
650
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
651
|
+
|
652
|
+
syntaxSelectPLUOrCroak
|
653
|
+
|
654
|
+
end
|
655
|
+
|
656
|
+
def make_syntax_reject_plural_or_croak(descArgs=nil, &descBlok)
|
657
|
+
eye = :'DSLC2d::m_syn_reject_snl'
|
658
|
+
|
659
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
660
|
+
|
661
|
+
syntaxBuilder = syntax_builder
|
662
|
+
|
663
|
+
cacheName = find_name_or_croak
|
664
|
+
cachePluralName = find_plural_name_or_croak
|
665
|
+
cacheLocalVariable = cache_local_variable
|
666
|
+
|
667
|
+
syntaxRejectPLUOrCroak = syntaxBuilder.new_method(parent: self) do
|
668
|
+
|
669
|
+
name :reject, cachePluralName
|
670
|
+
|
671
|
+
set_eye :rej, cachePluralName
|
672
|
+
|
673
|
+
signature :args_and_block, :rej
|
674
|
+
|
675
|
+
assign_local_variable cacheLocalVariable, name_builder_method_getter(cacheName)
|
676
|
+
|
677
|
+
snippet "
|
678
|
+
rejectResult = case
|
679
|
+
when Kernel.block_given? then #{cacheLocalVariable}.reject {|v| yield v }
|
680
|
+
else
|
681
|
+
#{cacheLocalVariable}.to_enum(:each)
|
682
|
+
end
|
683
|
+
"
|
684
|
+
|
685
|
+
logger_call who_only: {'rejectResult' => :rejectResult}
|
686
|
+
|
687
|
+
result :rejectResult
|
688
|
+
|
689
|
+
end
|
690
|
+
|
691
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
692
|
+
|
693
|
+
syntaxRejectPLUOrCroak
|
694
|
+
|
695
|
+
end
|
696
|
+
|
697
|
+
# Size Syntax Methods
|
698
|
+
# ###################
|
699
|
+
|
700
|
+
def make_syntax_size_or_croak(descArgs=nil, &descBlok)
|
701
|
+
eye = :'DSLC2d::m_syn_size'
|
702
|
+
|
703
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
704
|
+
|
705
|
+
syntaxBuilder = syntax_builder
|
706
|
+
|
707
|
+
add_specs_or_croak(size: make_syntax_size_plural_or_croak)
|
708
|
+
|
709
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
710
|
+
|
711
|
+
self
|
712
|
+
|
713
|
+
end
|
714
|
+
|
715
|
+
def make_syntax_size_plural_or_croak(descArgs=nil, &descBlok)
|
716
|
+
eye = :'DSLC2d::m_syn_size_snl'
|
717
|
+
|
718
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
719
|
+
|
720
|
+
syntaxBuilder = syntax_builder
|
721
|
+
|
722
|
+
cacheName = find_name_or_croak
|
723
|
+
cachePluralName = find_plural_name_or_croak
|
724
|
+
cacheInstanceVariable = cache_instance_variable
|
725
|
+
|
726
|
+
syntaxSizeSNLOrCroak = syntaxBuilder.new_method(parent: self) do
|
727
|
+
|
728
|
+
syntaxCacheInstanceVariable = instance_variable cacheInstanceVariable
|
729
|
+
|
730
|
+
name :size, cachePluralName
|
731
|
+
|
732
|
+
set_eye :e, cachePluralName
|
733
|
+
|
734
|
+
snippet "
|
735
|
+
sizeResult = defined?(#{syntaxCacheInstanceVariable}) ? #{syntaxCacheInstanceVariable}.size : 0
|
736
|
+
"
|
737
|
+
|
738
|
+
logger_call who_only: {'sizeResult' => :sizeResult}
|
739
|
+
|
740
|
+
result :sizeResult
|
741
|
+
|
742
|
+
end
|
743
|
+
|
744
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(descArgs: descArgs, descBlok: descBlok))
|
745
|
+
|
746
|
+
syntaxSizeSNLOrCroak
|
747
|
+
|
748
|
+
end
|
749
|
+
|
750
|
+
# Assign Statement Methods for Normalise and Validate
|
751
|
+
# ###################################################
|
752
|
+
|
753
|
+
methodTexts = { key_normalise_method: :nVal,
|
754
|
+
value_normalise_method: :vVal,
|
755
|
+
key_validate_method: :nVal,
|
756
|
+
value_validate_method: :vVal,
|
757
|
+
}.map do | mthName, argNameDef |
|
758
|
+
"def add_statement_#{mthName}(mthInst=self, varName=nil);
|
759
|
+
callName = #{mthName}; # any method defined?
|
760
|
+
callName ? begin
|
761
|
+
argName = varName || '#{argNameDef}';
|
762
|
+
mthInst.add_statement_assign_local_variable(argName, mthInst.new_statement_method_call(callName, argName));
|
763
|
+
end
|
764
|
+
: self;
|
765
|
+
end;
|
766
|
+
"
|
767
|
+
end
|
768
|
+
|
769
|
+
methodText = methodTexts.flatten.compact.join("\n")
|
770
|
+
|
771
|
+
module_eval(methodText)
|
772
|
+
|
773
|
+
# Syntax Builder Methods
|
774
|
+
# ######################
|
775
|
+
|
776
|
+
def syntax_builder
|
777
|
+
@syntax_builder ||= self.class.syntax_builder
|
778
|
+
end
|
779
|
+
|
780
|
+
# Support Methods
|
781
|
+
# ###############
|
782
|
+
|
783
|
+
def validate_or_croak(prcsArgs=nil, &prcsBlok)
|
784
|
+
eye = :'DSLC2d::val'
|
785
|
+
|
786
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who(prcsArgs: prcsArgs, prcsBlok: prcsBlok))
|
787
|
+
|
788
|
+
potrubi_bootstrap_mustbe_symbol_or_croak(name, eye)
|
789
|
+
potrubi_bootstrap_mustbe_symbol_or_croak(scope, eye)
|
790
|
+
potrubi_bootstrap_mustbe_not_nil_or_croak(key, eye)
|
791
|
+
potrubi_bootstrap_mustbe_not_nil_or_croak(value, eye)
|
792
|
+
|
793
|
+
$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(prcsArgs: prcsArgs, prcsBlok: prcsBlok))
|
794
|
+
|
795
|
+
self
|
796
|
+
|
797
|
+
end
|
798
|
+
|
799
|
+
end
|
800
|
+
|
801
|
+
module Potrubi
|
802
|
+
class DSL
|
803
|
+
class Cache2D < Potrubi::DSL::Super
|
804
|
+
end
|
805
|
+
end
|
806
|
+
end
|
807
|
+
|
808
|
+
Potrubi::DSL::Cache2D.__send__(:include, instanceMethods) # Instance Methods
|
809
|
+
Potrubi::DSL::Cache2D.extend(classMethods) # Class Methods
|
810
|
+
|
811
|
+
__END__
|