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.
Files changed (48) hide show
  1. data/lib/potrubi.rb +1 -1
  2. data/lib/potrubi/bootstrap.rb +1 -1
  3. data/lib/potrubi/core.rb +3 -3
  4. data/lib/potrubi/dsl.rb +86 -0
  5. data/lib/potrubi/dsl/accessor.rb +76 -0
  6. data/lib/potrubi/dsl/cache_2d.rb +811 -0
  7. data/lib/potrubi/dsl/contract.rb +731 -0
  8. data/lib/potrubi/dsl/super.rb +517 -0
  9. data/lib/potrubi/klass/syntax/alias.rb +150 -0
  10. data/lib/potrubi/klass/syntax/braket.rb +115 -25
  11. data/lib/potrubi/klass/syntax/builder.rb +45 -0
  12. data/lib/potrubi/klass/syntax/method.rb +436 -0
  13. data/lib/potrubi/klass/syntax/mixin/name_generation.rb +85 -0
  14. data/lib/potrubi/klass/syntax/mixin/new_aliases.rb +76 -0
  15. data/lib/potrubi/klass/syntax/mixin/new_brakets.rb +89 -0
  16. data/lib/potrubi/klass/syntax/mixin/new_methods.rb +158 -0
  17. data/lib/potrubi/klass/syntax/mixin/new_snippets.rb +74 -0
  18. data/lib/potrubi/klass/syntax/mixin/new_statements.rb +0 -0
  19. data/lib/potrubi/klass/syntax/mixin/statement_management.rb +69 -0
  20. data/lib/potrubi/klass/syntax/mixin/synel_management.rb +168 -0
  21. data/lib/potrubi/klass/syntax/snippet.rb +386 -0
  22. data/lib/potrubi/klass/syntax/statement.rb +91 -0
  23. data/lib/potrubi/klass/syntax/super.rb +88 -0
  24. data/lib/potrubi/mixin/bootstrap_common.rb +38 -12
  25. data/lib/potrubi/mixin/configuration.rb +31 -3
  26. data/lib/potrubi/mixin/contract.rb +5 -14
  27. data/lib/potrubi/mixin/contract/recipes.rb +307 -0
  28. data/lib/potrubi/mixin/dynamic-recipes.rb +1 -11
  29. data/lib/potrubi/mixin/dynamic.rb +223 -115
  30. data/lib/potrubi/mixin/exception.rb +3 -22
  31. data/lib/potrubi/mixin/filesys.rb +5 -21
  32. data/lib/potrubi/mixin/initialize.rb +11 -6
  33. data/lib/potrubi/mixin/konstant.rb +14 -118
  34. data/lib/potrubi/mixin/logger.rb +28 -41
  35. data/lib/potrubi/mixin/pathandnames.rb +4 -34
  36. data/lib/potrubi/mixin/persistence.rb +115 -10
  37. data/lib/potrubi/mixin/script.rb +0 -5
  38. data/lib/potrubi/mixin/{text-snippets → snippet-dictionaries}/methods-text-snippets.rb +138 -49
  39. data/lib/potrubi/mixin/{text-snippets.rb → snippet-manager.rb} +51 -39
  40. data/lib/potrubi/mixin/util.rb +66 -20
  41. data/lib/potrubi/version.rb +1 -1
  42. data/test/potrubi/mixin/bootstrap_common.rb +205 -0
  43. data/test/potrubi/mixin/konstant.rb +216 -0
  44. data/test/potrubi/mixin/logger.rb +124 -0
  45. data/test/ts_bootstrap_mixins.rb +16 -0
  46. data/test/ts_core_mixins.rb +7 -0
  47. metadata +31 -6
  48. data/lib/potrubi/mixin/contract-recipes.rb +0 -226
@@ -0,0 +1,85 @@
1
+
2
+ # potrubi contract dsl
3
+
4
+ # syntax methods: method
5
+
6
+ # to ease the creation of new methods using text manipulation
7
+
8
+ #require_relative '../../bootstrap'
9
+
10
+ #requireList = %w(base )
11
+ #requireList.each {|r| require_relative "#{r}"}
12
+ ###require "potrubi/klass/syntax/braket"
13
+
14
+
15
+ instanceMethods = Module.new do
16
+
17
+ #include Potrubi::Klass::Syntax::Mixin::Base
18
+
19
+ # Naming Methods
20
+ # ##############
21
+
22
+ def name_builder_instance_variable(*names)
23
+ name_creator('', '@', name_creator('_', *names))
24
+ end
25
+
26
+ def name_builder_method_getter(*names)
27
+ name_builder_method(*names)
28
+ end
29
+
30
+ def name_builder_method_setter(*names)
31
+ name_creator('', name_builder_method(*names), '=')
32
+ end
33
+
34
+ def name_builder_method_or_croak(*names)
35
+ name_creator('_', name_builder_method(*names), :or, :croak)
36
+ end
37
+
38
+ def name_builder_method(*names)
39
+ name_creator('_', *names)
40
+ end
41
+
42
+ def name_creator(sepChar, *names, &joinBlok)
43
+ r = names.flatten.compact
44
+ case
45
+ when Kernel.block_given? then r.map {|a| joinBlok.call(a) }.flatten.compact.join
46
+ else
47
+ #p = r.map {|a| [a, sepChar]}.flatten
48
+ #p.pop # last sepchar
49
+ #p.join('')
50
+ r.join(sepChar)
51
+ end
52
+ end
53
+
54
+ def name_builder_eye_getter(*eyes)
55
+ name_builder_eye(:g, *eyes)
56
+ end
57
+
58
+ def name_builder_eye_setter(*eyes)
59
+ name_builder_eye(:s, *eyes)
60
+ end
61
+
62
+ def name_builder_eye(*eyes)
63
+ name_builder_method(*eyes).to_sym
64
+ end
65
+
66
+ end
67
+
68
+
69
+
70
+ module Potrubi
71
+ class Klass
72
+ module Syntax
73
+ module Mixin
74
+ module NameGeneration
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ Potrubi::Klass::Syntax::Mixin::NameGeneration.__send__(:include, instanceMethods) # Instance Methods
82
+
83
+
84
+ __END__
85
+
@@ -0,0 +1,76 @@
1
+
2
+ # potrubi contract dsl
3
+
4
+ # syntax methods: method
5
+
6
+ # to ease the creation of new methods using text manipulation
7
+
8
+ #require_relative '../../bootstrap'
9
+
10
+ instanceMethods = Module.new do
11
+
12
+ #include Potrubi::Klass::Syntax::Mixin::Base
13
+
14
+ def alias_klass
15
+ @alias_klass ||= Potrubi::Klass::Syntax::Alias
16
+ end
17
+
18
+ # New Alias Methods
19
+ # #################
20
+
21
+ def new_alias(dslArgs=nil, &dslBlok) # class alias
22
+ eye = :'PotKlsSynMixAli::n_alias'
23
+ #puts("NEW ALIAS")
24
+ newAlias = alias_klass.new(dslArgs, &dslBlok)
25
+ #$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newAlias: newAlias), potrubi_bootstrap_logger_fmt_who_only(newAlias: newAlias, dslArgs: dslArgsNrm, dslBlok: dslBlok))
26
+ newAlias
27
+ ###STOPHERENEWALIASEXIT
28
+ end
29
+
30
+
31
+ def new_aliases(aliasDefs)
32
+ eye = :n_aliases
33
+
34
+ potrubi_bootstrap_mustbe_hash_or_croak(aliasDefs)
35
+
36
+ newAlias = new_alias do
37
+
38
+ aliasDefs.each do | srcMth, tgtMth |
39
+
40
+ add_statement_method_alias(srcMth, tgtMth)
41
+
42
+ end
43
+
44
+ end
45
+
46
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newAlias: newAlias, aliasDefs: aliasDefs))
47
+ #STOPHERENEWMETHODRESCUE
48
+
49
+ newAlias
50
+
51
+ end
52
+
53
+
54
+ end
55
+
56
+
57
+
58
+ module Potrubi
59
+ class Klass
60
+ module Syntax
61
+ module Mixin
62
+ module NewAliases
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ Potrubi::Klass::Syntax::Mixin::NewAliases.__send__(:include, instanceMethods) # Instance Methods
70
+
71
+
72
+ requireList = %w(../alias)
73
+ defined?(requireList) && requireList.each {|r| require_relative "#{r}"}
74
+
75
+ __END__
76
+
@@ -0,0 +1,89 @@
1
+
2
+ # potrubi contract dsl
3
+
4
+ # syntax methods for brakets
5
+
6
+ # to ease the creation of new methods using text manipulation
7
+
8
+ #require_relative '../../bootstrap'
9
+
10
+ #requireList = %w(base)
11
+ #requireList.each {|r| require_relative "#{r}"}
12
+ ###require "potrubi/klass/syntax/braket"
13
+
14
+ instanceMethods = Module.new do
15
+
16
+ #include Potrubi::Klass::Syntax::Mixin::Base
17
+
18
+ def braket_klass
19
+ @braket_klass ||= Potrubi::Klass::Syntax::Braket
20
+ end
21
+ alias_method :braket_method_klass, :braket_klass
22
+ alias_method :braket_statement_klass, :braket_klass
23
+ alias_method :braket_snippet_klass, :braket_klass
24
+
25
+ # Braket Methods
26
+ # ##############
27
+
28
+ def mustbe_braket_method_or_croak(braketMethod)
29
+ braketMethod.is_a?(braket_method_klass) ? braketMethod : potrubi_bootstrap_surprise_exception(braketMethod, :mustbe_bkt_mth, "braketMethod not a braket method")
30
+ end
31
+
32
+ def new_braket_method
33
+ braket_method_klass.new_method
34
+ end
35
+
36
+ # Statement Braket Methods
37
+ # ########################
38
+
39
+ def new_braket_statement
40
+ #puts("NEW BRAKET STATEMENT ")
41
+ #stateKls = braket_statement_klass
42
+ #puts("NEW BRAKET STATEMENT kls >#{stateKls.class}< >#{stateKls}<")
43
+ braket_statement_klass.new_statement
44
+ end
45
+
46
+ def mustbe_braket_statement_or_croak(braketStatement)
47
+ braketStatement.is_a?(braket_statement_klass) ? braketStatement : potrubi_bootstrap_surprise_exception(braketStatement, :mustbe_bkt_stm, "braketStatement not a braket statetment")
48
+ end
49
+
50
+ # Snippet Braket Methods
51
+ # ########################
52
+
53
+ def new_braket_snippet
54
+ #puts("NEW BRAKET SNIPPET ")
55
+ #stateKls = braket_snippet_klass
56
+ #puts("NEW BRAKET SNIPPET kls >#{stateKls.class}< >#{stateKls}<")
57
+ braket_snippet_klass.new_snippet
58
+ end
59
+
60
+ def mustbe_braket_snippet_or_croak(braketSnippet)
61
+ braketSnippet.is_a?(braket_snippet_klass) ? braketSnippet : potrubi_bootstrap_surprise_exception(braketSnippet, :mustbe_bkt_stm, "braketSnippet not a braket snippet")
62
+ end
63
+
64
+ end
65
+
66
+ module Potrubi
67
+ class Klass
68
+ module Syntax
69
+ module Mixin
70
+ module NewBrakets
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ Potrubi::Klass::Syntax::Mixin::NewBrakets.__send__(:include, instanceMethods) # Instance Methods
78
+
79
+
80
+ __END__
81
+
82
+ Potrubi::Klass::Syntax::Super.extend(classMethods) # Class Methods
83
+
84
+ __END__
85
+
86
+ m = Potrubi::DSL::Syntax::Super.new
87
+
88
+ __END__
89
+
@@ -0,0 +1,158 @@
1
+
2
+ # potrubi contract dsl
3
+
4
+ # syntax methods: method
5
+
6
+ # to ease the creation of new methods using text manipulation
7
+
8
+ #require_relative '../../bootstrap'
9
+
10
+
11
+
12
+ #__END__
13
+
14
+ instanceMethods = Module.new do
15
+
16
+ #include Potrubi::Klass::Syntax::Mixin::Base
17
+ include Potrubi::Klass::Syntax::Mixin::NewSnippets
18
+
19
+ # New Method Methods
20
+ # ##################
21
+
22
+
23
+ def method_klass
24
+ @method_klass ||= Potrubi::Klass::Syntax::Method
25
+ end
26
+
27
+ def new_method(dslArgs=nil, &dslBlok)
28
+ eye = :'PotKlsSynMixNewMths::n_mth'
29
+ puts("NEW METHOD USING SNIPPETS X1")
30
+ #potrubi_bootstrap_mustbe_symbol_or_croak(dslAttr, eye, "dslAttr is what?")
31
+
32
+ newMethod = method_klass.new(dslArgs)
33
+ puts("NEW METHOD USING SNIPPETS X2")
34
+ #newSnippet = snippet_klass.new(parent: newMethod.parent, delegate: newMethod, &dslBlok)
35
+ # use same synels collection
36
+ newSnippet = snippet_klass.new(synels: newMethod.synels, parent: newMethod.parent, delegate: newMethod, &dslBlok)
37
+
38
+ puts("NEW METHOD USING SNIPPETS X3")
39
+ #STOPHERENEWMETHODPOSTNEWSNIPOET
40
+ #newMethod.statements = newSnippet.statements
41
+ #newMethod.add_statements_or_croak(newSnippet.statements)
42
+
43
+ snipSyns = newSnippet.synels
44
+ #STOPHEREPREX3A
45
+ puts("NEW METHOD USING SNIPPETS X3a SYNELS >#{snipSyns.class}< >\n#{snipSyns.to_s}<")
46
+ #STOPHEREPOISTX3Q
47
+
48
+ #newMethod.add_synels_or_croak(newSnippet.synels)
49
+ #newMethod.synels = newSnippet.synels
50
+
51
+ puts("NEW METHOD USING SNIPPETS X4")
52
+ #$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newMethod: newMethod), potrubi_bootstrap_logger_fmt_who_only(dslAttr: dslAttr, dslArgs: dslArgsNrm, dslBlok: dslBlok))
53
+ newMethod
54
+ #STOPHERENEWMETHODEXIT
55
+ end
56
+
57
+ def keepkeepkeep_new_method(dslArgs=nil, &dslBlok)
58
+ eye = :'PotKlsSynSpr::n_mth'
59
+ #puts("NEW METHOD")
60
+ #potrubi_bootstrap_mustbe_symbol_or_croak(dslAttr, eye, "dslAttr is what?")
61
+ newMethod = method_klass.new(dslArgs, &dslBlok)
62
+ #$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newMethod: newMethod), potrubi_bootstrap_logger_fmt_who_only(dslAttr: dslAttr, dslArgs: dslArgsNrm, dslBlok: dslBlok))
63
+ newMethod
64
+ ###STOPHERENEWMETHODEXIT
65
+ end
66
+
67
+
68
+
69
+ def new_method_rescue(*methodNames)
70
+ eye = :n_mth_rsc
71
+
72
+ newMethod = new_method do
73
+
74
+ methodNameRescue = name_builder_method(*methodNames)
75
+ methodNameCroak = name_builder_method_or_croak(methodNameRescue)
76
+
77
+ set_name(methodNameRescue)
78
+ set_signature_generic
79
+ add_statement(
80
+ new_statement_method_call(methodNameCroak, get_signature),
81
+ ' ',
82
+ new_statement_rescue_nil,
83
+ #' rescue nil'
84
+ )
85
+ end
86
+
87
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newMethod: newMethod, name: methodNames))
88
+ #STOPHERENEWMETHODRESCUE
89
+
90
+ newMethod
91
+ end
92
+
93
+
94
+ def new_method_caller_callee(callArgs, &callBlok)
95
+ eye = :n_mth_caller_callee
96
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_me(eye, potrubi_bootstrap_logger_fmt_who_only(callArgs: callArgs, callBlok: callBlok))
97
+
98
+ potrubi_bootstrap_mustbe_hash_or_croak(callArgs, eye)
99
+
100
+ newMethod = new_method do
101
+
102
+ nameCallee = name_builder_method(callArgs[:callee])
103
+ nameCaller = name_builder_method(callArgs[:caller])
104
+
105
+ potrubi_bootstrap_mustbe_string_or_croak(nameCaller, eye)
106
+ potrubi_bootstrap_mustbe_string_or_croak(nameCallee, eye)
107
+
108
+ signCaller = callArgs[:caller_sig]
109
+ argsCalleeNom = callArgs[:callee_args]
110
+
111
+ argsCallee = case
112
+ when Kernel.block_given? then callBlok.call(signCaller)
113
+ when (! argsCalleeNom.nil?) then argsCalleeNom
114
+ else
115
+ potrubi_bootstrap_surprise_exception(nameCaller, eye, "no args for caller")
116
+ end
117
+
118
+
119
+
120
+ set_name(nameCaller)
121
+ set_signature(signCaller)
122
+ add_statement_method_call(nameCallee,
123
+ *argsCallee,
124
+ )
125
+
126
+ end
127
+
128
+ #$DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_mx(eye, potrubi_bootstrap_logger_fmt_who(newMethod: newMethod), potrubi_bootstrap_logger_fmt_who_only(nameCaller: nameCaller, nameCallee: nameCallee, signCaller: signCaller, argsCallee: argsCallee))
129
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_mx(eye, potrubi_bootstrap_logger_fmt_who(newMethod: newMethod), potrubi_bootstrap_logger_fmt_who_only(callArgs: callArgs, callBlok: callBlok))
130
+ #STOPHERENEWMETHODCALLMULTFROMSINGLE
131
+
132
+ newMethod
133
+ end
134
+
135
+
136
+ end
137
+
138
+
139
+
140
+ module Potrubi
141
+ class Klass
142
+ module Syntax
143
+ module Mixin
144
+ module NewMethods
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ Potrubi::Klass::Syntax::Mixin::NewMethods.__send__(:include, instanceMethods) # Instance Methods
152
+
153
+ requireList = %w(../method)
154
+ defined?(requireList) && requireList.each {|r| require_relative "#{r}"}
155
+ ###require "potrubi/klass/syntax/braket"
156
+
157
+ __END__
158
+
@@ -0,0 +1,74 @@
1
+
2
+ # potrubi contract dsl
3
+
4
+ # syntax methods: method
5
+
6
+ # to ease the creation of new methods using text manipulation
7
+
8
+ #require_relative '../../bootstrap'
9
+
10
+
11
+
12
+ #__END__
13
+
14
+ instanceMethods = Module.new do
15
+
16
+ #include Potrubi::Klass::Syntax::Mixin::Base
17
+
18
+ def snippet_klass
19
+ @snippet_klass ||= Potrubi::Klass::Syntax::Snippet
20
+ end
21
+
22
+ # New Snippet Methods
23
+ # ###################
24
+
25
+ def new_snippet(snipArgs=nil, &snipBlok) # class snippet
26
+ eye = :'PotKlsSynMixSni::n_snippet'
27
+ #puts("NEW SNIPPET")
28
+ newSnippet = snippet_klass.new(snipArgs, &snipBlok)
29
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newSnippet: newSnippet), potrubi_bootstrap_logger_fmt_who_only(snipArgs: snipArgs, snipBlok: snipBlok))
30
+ newSnippet
31
+ #STOPHERENEWSNIPPETEXIT
32
+ end
33
+
34
+ end
35
+
36
+ module Potrubi
37
+ class Klass
38
+ module Syntax
39
+ module Mixin
40
+ module NewSnippets
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Potrubi::Klass::Syntax::Mixin::NewSnippets.__send__(:include, instanceMethods) # Instance Methods
48
+
49
+ requireList = %w(../snippet)
50
+ defined?(requireList) && requireList.each {|r| require_relative "#{r}"}
51
+
52
+ __END__
53
+
54
+ def new_snippets(snippetDefs)
55
+ eye = :n_snippetes
56
+
57
+ potrubi_bootstrap_mustbe_hash_or_croak(snippetDefs)
58
+
59
+ newSnippet = new_snippet do
60
+
61
+ snippetDefs.each do | srcMth, tgtMth |
62
+
63
+ add_statement_method_snippet(srcMth, tgtMth)
64
+
65
+ end
66
+
67
+ end
68
+
69
+ $DEBUG_POTRUBI_BOOTSTRAP && potrubi_bootstrap_logger_ca(eye, potrubi_bootstrap_logger_fmt_who(newSnippet: newSnippet, snippetDefs: snippetDefs))
70
+ #STOPHERENEWMETHODRESCUE
71
+
72
+ newSnippet
73
+
74
+ end