foobara 0.0.142 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +25 -0
- data/projects/builtin_types/lib/foobara/builtin_types.rb +1 -0
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_defaults_from_element_types_to_root.rb +9 -2
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/desugarizers/symbolize_defaults.rb +1 -1
- data/projects/builtin_types/src/attributes/supported_transformers/defaults/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/hash_with_symbolic_keys.rb +1 -1
- data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/alphabetize_required.rb +5 -5
- data/projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_required_from_element_types_to_root.rb +12 -2
- data/projects/builtin_types/src/builtin_types.rb +1 -1
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/class_desugarizer.rb +10 -2
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/class_type_desugarizer.rb +7 -2
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_class_desugarizer.rb +3 -4
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/instance_of_symbol_desugarizer.rb +3 -4
- data/projects/builtin_types/src/duck/supported_validators/instance_of/type_declaration_extension/extend_registered_type_declaration/type_declaration_validators/is_valid_class.rb +1 -1
- data/projects/builtin_types/src/duck/supported_validators/instance_of.rb +1 -0
- data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/cast_one_of.rb +4 -3
- data/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +3 -3
- data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/desugarizers/set_size.rb +1 -1
- data/projects/builtin_types/src/tuple/supported_processors/element_type_declarations/type_declaration_extension/extend_tuple_type_declaration/type_declaration_validators/size_matches.rb +2 -4
- data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +12 -12
- data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +4 -2
- data/projects/command/src/command_pattern_implementation/concerns/result_type.rb +0 -4
- data/projects/command_connectors/src/command_connector.rb +41 -16
- data/projects/command_connectors/src/command_registry.rb +7 -4
- data/projects/command_connectors/src/transformed_command.rb +55 -43
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +1 -0
- data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +4 -0
- data/projects/common/src/possible_error.rb +27 -21
- data/projects/detached_entity/src/concerns/types.rb +7 -1
- data/projects/detached_entity/src/detached_entity_type.rb +10 -0
- data/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +1 -1
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/hash_desugarizer.rb +6 -9
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/primary_key_desugarizer.rb +2 -1
- data/projects/domain/src/domain_module_extension.rb +12 -4
- data/projects/domain/src/is_manifestable.rb +19 -7
- data/projects/entity/src/concerns/types.rb +6 -1
- data/projects/foobara/lib/foobara/all.rb +4 -4
- data/projects/manifest/src/foobara/manifest/type.rb +11 -2
- data/projects/manifest/src/foobara/manifest/type_declaration.rb +46 -2
- data/projects/model/src/concerns/aliases.rb +8 -0
- data/projects/model/src/concerns/reflection.rb +2 -2
- data/projects/model/src/concerns/types.rb +35 -20
- data/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +12 -8
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +1 -1
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +15 -1
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +7 -5
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +4 -7
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +0 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +28 -9
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +8 -7
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -7
- data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +14 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +8 -9
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +6 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +5 -2
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +8 -7
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +4 -1
- data/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +20 -5
- data/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +23 -5
- data/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +18 -0
- data/projects/model_attribute_helpers/src/attribute_helpers.rb +44 -26
- data/projects/namespace/src/is_namespace.rb +58 -90
- data/projects/namespace/src/namespace/lookup_mode.rb +13 -2
- data/projects/namespace/src/namespace_helpers.rb +1 -0
- data/projects/namespace/src/prefixless_registry.rb +2 -0
- data/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +20 -1
- data/projects/persistence/src/entity_base/transaction.rb +14 -11
- data/projects/persistence/src/entity_base/transaction_table.rb +10 -49
- data/projects/persistence/src/entity_base.rb +39 -0
- data/projects/persistence/src/persistence.rb +4 -0
- data/projects/type_declarations/src/attributes.rb +15 -9
- data/projects/type_declarations/src/attributes_transformers/from_yaml.rb +1 -1
- data/projects/type_declarations/src/desugarizer_pipeline.rb +9 -0
- data/projects/type_declarations/src/dsl/attributes.rb +14 -5
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +24 -4
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +23 -9
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb +3 -7
- data/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +15 -4
- data/projects/type_declarations/src/handlers/extend_array_type_declaration.rb +12 -2
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/key_type_declaration_desugarizer.rb +48 -0
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb +3 -11
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration/value_type_declaration_desugarizer.rb +51 -0
- data/projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb +12 -2
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb +1 -1
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +17 -7
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/hash_desugarizer.rb +16 -19
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration/to_type_transformer.rb +3 -6
- data/projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb +13 -2
- data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +3 -3
- data/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +16 -4
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +20 -6
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb +3 -9
- data/projects/type_declarations/src/handlers/extend_tuple_type_declaration.rb +12 -2
- data/projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb +7 -9
- data/projects/type_declarations/src/handlers/registered_type_declaration.rb +22 -7
- data/projects/type_declarations/src/lazy_element_types/array.rb +19 -0
- data/projects/type_declarations/src/lazy_element_types/attributes.rb +27 -0
- data/projects/type_declarations/src/lazy_element_types/hash.rb +38 -0
- data/projects/type_declarations/src/lazy_element_types/tuple.rb +23 -0
- data/projects/type_declarations/src/sensitive_type_remover.rb +6 -1
- data/projects/type_declarations/src/sensitive_type_removers/attributes.rb +2 -0
- data/projects/type_declarations/src/type_builder.rb +46 -21
- data/projects/type_declarations/src/type_declaration.rb +295 -0
- data/projects/type_declarations/src/type_declaration_handler.rb +10 -11
- data/projects/type_declarations/src/type_declarations.rb +18 -88
- data/projects/types/src/type.rb +34 -9
- data/projects/value/src/mutator.rb +1 -4
- data/projects/value/src/processor/casting.rb +7 -2
- data/projects/value/src/processor/pipeline.rb +9 -1
- data/projects/value/src/processor.rb +0 -8
- data/projects/value/src/transformer.rb +1 -3
- data/projects/value/src/validator.rb +0 -2
- data/projects/weak_object_set/src/weak_object_set.rb +2 -0
- metadata +11 -8
- data/projects/type_declarations/src/handlers/registered_type_declaration/desugarizer_metadata_cleanup_desugarizer.rb +0 -29
- data/projects/type_declarations/src/handlers/registered_type_declaration/short_type_name_desugarizer.rb +0 -62
- data/projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb +0 -32
- data/projects/type_declarations/src/handlers/registered_type_declaration/strict_stringified_desugarizer.rb +0 -39
- data/projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb +0 -30
- data/projects/type_declarations/src/handlers/registered_type_declaration/type_desugarizer.rb +0 -24
@@ -92,25 +92,24 @@ module Foobara
|
|
92
92
|
[desugarizer, type_declaration_validator, to_type_transformer]
|
93
93
|
end
|
94
94
|
|
95
|
-
def process_value(raw_type_declaration)
|
96
|
-
# TODO: deep_dup this again??
|
97
|
-
super.tap do |type_outcome|
|
98
|
-
if type_outcome.success?
|
99
|
-
type_outcome.result.raw_declaration_data = raw_type_declaration
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
95
|
def desugarizer
|
105
96
|
# TODO: memoize this?
|
106
|
-
|
97
|
+
DesugarizerPipeline.new(processors: desugarizers)
|
107
98
|
end
|
108
99
|
|
109
100
|
def desugarize(value)
|
110
|
-
|
101
|
+
unless value.strict?
|
102
|
+
if desugarizer.applicable?(value)
|
103
|
+
value = desugarizer.process_value!(value)
|
104
|
+
value.is_strict = true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
value
|
111
109
|
end
|
112
110
|
|
113
111
|
def type_declaration_validator
|
112
|
+
# TODO: memoize this
|
114
113
|
Value::Processor::Pipeline.new(processors: type_declaration_validators)
|
115
114
|
end
|
116
115
|
|
@@ -30,11 +30,14 @@ module Foobara
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def remove_sensitive_types(strict_type_declaration)
|
33
|
-
|
33
|
+
declaration = TypeDeclaration.new(strict_type_declaration)
|
34
|
+
declaration.is_strict = true
|
35
|
+
|
36
|
+
handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)
|
34
37
|
|
35
38
|
sensitive_type_remover = sensitive_type_removers[handler.class.name]
|
36
39
|
|
37
|
-
if sensitive_type_remover
|
40
|
+
if sensitive_type_remover&.applicable?(strict_type_declaration)
|
38
41
|
sensitive_type_remover.process_value!(strict_type_declaration)
|
39
42
|
else
|
40
43
|
strict_type_declaration
|
@@ -51,12 +54,16 @@ module Foobara
|
|
51
54
|
end
|
52
55
|
|
53
56
|
def sensitive_value_remover_class_for_type(type)
|
54
|
-
|
57
|
+
declaration_data = type.declaration_data
|
58
|
+
declaration = TypeDeclaration.new(declaration_data)
|
59
|
+
declaration.is_strict = true
|
60
|
+
|
61
|
+
handler = GlobalDomain.foobara_type_builder.type_declaration_handler_for(declaration)
|
55
62
|
remover_class = sensitive_value_removers[handler.class.name]
|
56
63
|
|
57
64
|
unless remover_class
|
58
65
|
# :nocov:
|
59
|
-
raise "No sensitive value remover found for #{
|
66
|
+
raise "No sensitive value remover found for #{declaration_data}"
|
60
67
|
# :nocov:
|
61
68
|
end
|
62
69
|
|
@@ -89,7 +96,11 @@ module Foobara
|
|
89
96
|
end
|
90
97
|
|
91
98
|
def stringified?
|
92
|
-
foobara_manifest_context_mode == Mode::STRINGIFIED
|
99
|
+
foobara_manifest_context_mode == Mode::STRINGIFIED || strict_stringified?
|
100
|
+
end
|
101
|
+
|
102
|
+
def include_processors?
|
103
|
+
foobara_manifest_context_include_processors?
|
93
104
|
end
|
94
105
|
|
95
106
|
# TODO: we should desugarize these but can't because of a bug where desugarizing entities results in creating the
|
@@ -105,8 +116,8 @@ module Foobara
|
|
105
116
|
Thread.inheritable_thread_local_var_get("foobara_manifest_context")
|
106
117
|
end
|
107
118
|
|
108
|
-
allowed_context_keys = [:detached, :to_include, :mode, :remove_sensitive]
|
109
|
-
booleans = [:detached, :remove_sensitive]
|
119
|
+
allowed_context_keys = [:detached, :to_include, :mode, :remove_sensitive, :include_processors]
|
120
|
+
booleans = [:detached, :remove_sensitive, :include_processors]
|
110
121
|
|
111
122
|
booleans.each do |context_item|
|
112
123
|
define_method "foobara_manifest_context_#{context_item}?" do
|
@@ -137,84 +148,3 @@ module Foobara
|
|
137
148
|
end
|
138
149
|
end
|
139
150
|
end
|
140
|
-
|
141
|
-
=begin
|
142
|
-
how many handlers do we need??
|
143
|
-
|
144
|
-
|
145
|
-
find registered type by symbol
|
146
|
-
|
147
|
-
extend registered type (find it by symbol and use it to construct new type with additional processors)
|
148
|
-
|
149
|
-
Duck
|
150
|
-
AtomicDuck
|
151
|
-
Number
|
152
|
-
Integer
|
153
|
-
BigInteger
|
154
|
-
Float
|
155
|
-
BigDecimal
|
156
|
-
String
|
157
|
-
Email
|
158
|
-
Phone
|
159
|
-
Datetime
|
160
|
-
Date
|
161
|
-
Boolean
|
162
|
-
Duckture
|
163
|
-
Array
|
164
|
-
Tuple
|
165
|
-
AssociativeArray
|
166
|
-
Attributes
|
167
|
-
Model
|
168
|
-
Address
|
169
|
-
UsAddress
|
170
|
-
Entity
|
171
|
-
|
172
|
-
Duck (RegisteredTypeExtensionTypeDeclarationHandler)
|
173
|
-
AtomicDuck (N/A)
|
174
|
-
Number (N/A)
|
175
|
-
Integer (RegisteredTypeExtensionTypeDeclarationHandler)
|
176
|
-
BigInteger (RegisteredTypeExtensionTypeDeclarationHandler)
|
177
|
-
Float (RegisteredTypeExtensionTypeDeclarationHandler)
|
178
|
-
BigDecimal (RegisteredTypeExtensionTypeDeclarationHandler)
|
179
|
-
String (RegisteredTypeExtensionTypeDeclarationHandler)
|
180
|
-
Email (implement in terms of string extension)
|
181
|
-
Phone (implement in terms of string extension)
|
182
|
-
Datetime (RegisteredTypeExtensionTypeDeclarationHandler)
|
183
|
-
Date (RegisteredTypeExtensionTypeDeclarationHandler)
|
184
|
-
Boolean (RegisteredTypeExtensionTypeDeclarationHandler)
|
185
|
-
Duckture (N/A)
|
186
|
-
Array (hmmmm we need an element processor initialized with the element type...)
|
187
|
-
Tuple (hmmmm we need an element processor initialized with the elements type...)
|
188
|
-
AssociativeArray (hmmmm we need an element processor initialized with the key type and the value type...)
|
189
|
-
Attributes (we need an element processor initialized with the attribute_types)
|
190
|
-
Model (same as above but need to add a name attribute...)
|
191
|
-
Address (implement in terms of model)
|
192
|
-
UsAddress (implement in terms of Address)
|
193
|
-
Entity (same as above but with a primary key processor of some sort)
|
194
|
-
|
195
|
-
|
196
|
-
TypeDeclarationHandler
|
197
|
-
RegisteredAtomTypeExtensionTypeDeclarationHandler
|
198
|
-
RegisteredStructuredTypeExtensionTypeDeclarationHandler
|
199
|
-
ExtendArrayTypeDeclarationHandler
|
200
|
-
ExtendTupleTypeDeclarationHandler
|
201
|
-
ExtendAssociativeArrayTypeDeclaration
|
202
|
-
ExtendAttributesTypeDeclaration
|
203
|
-
ExtendModelTypeDeclarationHandler
|
204
|
-
ExtendEntityTypeDeclarationHandler
|
205
|
-
|
206
|
-
I think we need these type declarations but not necessarily Type subclasses for all of these types
|
207
|
-
|
208
|
-
Maybe just one Type class??
|
209
|
-
|
210
|
-
let's see...
|
211
|
-
|
212
|
-
for atom could just not support element_types nor size
|
213
|
-
for array element_types could just be applied repeating?? Kind of goofy
|
214
|
-
For tuple element_types could be applied repeating and size validator could be added
|
215
|
-
for associative array... element_types need to be a hash instead of an array. Is that OK?
|
216
|
-
Or could be an array of pairs... like Hash#to_a ? Maybe we just operate off of #each? Seems that will work, wow...
|
217
|
-
For Attributes same as associative array but with key processor of symbol plus an attributes_processor
|
218
|
-
For model add a name processor
|
219
|
-
for entity add a primary key processor of some sort...
|
220
|
-
=end
|
data/projects/types/src/type.rb
CHANGED
@@ -21,7 +21,6 @@ module Foobara
|
|
21
21
|
:element_processors,
|
22
22
|
:structure_count,
|
23
23
|
:is_builtin,
|
24
|
-
:raw_declaration_data,
|
25
24
|
:name,
|
26
25
|
:target_classes,
|
27
26
|
:description,
|
@@ -77,6 +76,15 @@ module Foobara
|
|
77
76
|
validate_processors!
|
78
77
|
end
|
79
78
|
|
79
|
+
# TODO: replace the concept of builtin? with primitive?
|
80
|
+
def primitive?
|
81
|
+
declaration_data.is_a?(::Symbol)
|
82
|
+
end
|
83
|
+
|
84
|
+
def derived?
|
85
|
+
declaration_data.is_a?(::Hash)
|
86
|
+
end
|
87
|
+
|
80
88
|
def sensitive?
|
81
89
|
sensitive
|
82
90
|
end
|
@@ -86,11 +94,23 @@ module Foobara
|
|
86
94
|
end
|
87
95
|
|
88
96
|
def element_type
|
89
|
-
@element_type || base_type&.element_type
|
97
|
+
type = @element_type || base_type&.element_type
|
98
|
+
|
99
|
+
if type.is_a?(::Symbol)
|
100
|
+
type = @element_type = TypeDeclarations::LazyElementTypes.const_get(type).resolve(self)
|
101
|
+
end
|
102
|
+
|
103
|
+
type
|
90
104
|
end
|
91
105
|
|
92
106
|
def element_types
|
93
|
-
@element_types || base_type&.element_types
|
107
|
+
types = @element_types || base_type&.element_types
|
108
|
+
|
109
|
+
if types.is_a?(::Symbol)
|
110
|
+
types = @element_types = TypeDeclarations::LazyElementTypes.const_get(types).resolve(self)
|
111
|
+
end
|
112
|
+
|
113
|
+
types
|
94
114
|
end
|
95
115
|
|
96
116
|
def has_sensitive_types?
|
@@ -310,7 +330,7 @@ module Foobara
|
|
310
330
|
end
|
311
331
|
|
312
332
|
Value::Processor::Casting.new(
|
313
|
-
{ cast_to:
|
333
|
+
{ cast_to: reference_or_declaration_data },
|
314
334
|
casters:,
|
315
335
|
target_classes:,
|
316
336
|
enforce_unique:
|
@@ -380,7 +400,7 @@ module Foobara
|
|
380
400
|
|
381
401
|
if registered?
|
382
402
|
# TODO: we should just use the symbol and nothing else in this context instead of a hash with 1 element.
|
383
|
-
|
403
|
+
foobara_manifest_reference.to_sym
|
384
404
|
elsif remove_sensitive
|
385
405
|
TypeDeclarations.remove_sensitive_types(declaration_data)
|
386
406
|
else
|
@@ -396,6 +416,7 @@ module Foobara
|
|
396
416
|
def foobara_manifest
|
397
417
|
to_include = TypeDeclarations.foobara_manifest_context_to_include
|
398
418
|
remove_sensitive = TypeDeclarations.foobara_manifest_context_remove_sensitive?
|
419
|
+
include_processors = TypeDeclarations.include_processors?
|
399
420
|
|
400
421
|
types = []
|
401
422
|
|
@@ -435,11 +456,13 @@ module Foobara
|
|
435
456
|
h[:sensitive_exposed] = true
|
436
457
|
end
|
437
458
|
|
438
|
-
|
439
|
-
|
440
|
-
|
459
|
+
if include_processors
|
460
|
+
h.merge!(
|
461
|
+
supported_processor_manifest.merge(
|
462
|
+
Util.remove_blank(processors: processor_manifest)
|
463
|
+
)
|
441
464
|
)
|
442
|
-
|
465
|
+
end
|
443
466
|
|
444
467
|
target_classes.sort_by(&:name).each do |target_class|
|
445
468
|
if target_class.respond_to?(:foobara_manifest)
|
@@ -450,6 +473,8 @@ module Foobara
|
|
450
473
|
super.merge(h)
|
451
474
|
end
|
452
475
|
|
476
|
+
# TODO: replace the concept of builtin? with primitive? and delete this method since
|
477
|
+
# primitive? already exists.
|
453
478
|
def builtin?
|
454
479
|
is_builtin
|
455
480
|
end
|
@@ -89,8 +89,13 @@ module Foobara
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def error_message(value)
|
92
|
-
type = declaration_data[:cast_to]
|
93
|
-
|
92
|
+
type = declaration_data[:cast_to]
|
93
|
+
|
94
|
+
if type.is_a?(::Hash)
|
95
|
+
type = type[:type]
|
96
|
+
end
|
97
|
+
|
98
|
+
article = type.to_s =~ /^[aeiouy]/i ? "an" : "a"
|
94
99
|
|
95
100
|
"Cannot cast #{value.inspect} to #{article} #{type}. Expected it to #{applies_message}"
|
96
101
|
end
|
@@ -14,7 +14,15 @@ module Foobara
|
|
14
14
|
|
15
15
|
def process_outcome(old_outcome)
|
16
16
|
processors.inject(old_outcome) do |outcome, processor|
|
17
|
-
|
17
|
+
return outcome if outcome.fatal?
|
18
|
+
|
19
|
+
value = outcome.result
|
20
|
+
|
21
|
+
if processor.applicable?(value)
|
22
|
+
processor.process_outcome(outcome)
|
23
|
+
else
|
24
|
+
outcome
|
25
|
+
end
|
18
26
|
end
|
19
27
|
end
|
20
28
|
|
@@ -232,8 +232,6 @@ module Foobara
|
|
232
232
|
|
233
233
|
value = old_outcome.result
|
234
234
|
|
235
|
-
return old_outcome unless applicable?(value)
|
236
|
-
|
237
235
|
process_value(value).tap do |outcome|
|
238
236
|
outcome.add_errors(old_outcome.error_collection)
|
239
237
|
end
|
@@ -324,12 +322,6 @@ module Foobara
|
|
324
322
|
def foobara_manifest
|
325
323
|
to_include = TypeDeclarations.foobara_manifest_context_to_include
|
326
324
|
|
327
|
-
unless scoped_path_set?
|
328
|
-
if self.class.scoped_path_set?
|
329
|
-
self.scoped_path = self.class.scoped_path
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
325
|
possible_errors = self.possible_errors.map do |possible_error|
|
334
326
|
[possible_error.key.to_s, possible_error.foobara_manifest]
|
335
327
|
end
|
@@ -95,6 +95,7 @@ module Foobara
|
|
95
95
|
monitor.synchronize do
|
96
96
|
ref = ref_for(object_or_object_id)
|
97
97
|
|
98
|
+
# TODO: is this necessary? Why not check weakref_alive? now that we're in a mutex?
|
98
99
|
object = begin
|
99
100
|
ref&.__getobj__
|
100
101
|
rescue WeakRef::RefError
|
@@ -122,6 +123,7 @@ module Foobara
|
|
122
123
|
def each
|
123
124
|
monitor.synchronize do
|
124
125
|
objects.each_value do |ref|
|
126
|
+
# Is this still necessary now that we're in a mutex?
|
125
127
|
object = begin
|
126
128
|
ref.__getobj__
|
127
129
|
rescue WeakRef::RefError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -373,6 +373,7 @@ files:
|
|
373
373
|
- projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
|
374
374
|
- projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb
|
375
375
|
- projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb
|
376
|
+
- projects/model/src/extensions/type_declarations/lazy_element_types/model.rb
|
376
377
|
- projects/model/src/model.rb
|
377
378
|
- projects/model/src/sensitive_type_removers/extended_model.rb
|
378
379
|
- projects/model/src/sensitive_type_removers/model.rb
|
@@ -421,6 +422,7 @@ files:
|
|
421
422
|
- projects/type_declarations/src/attributes_transformers/reject.rb
|
422
423
|
- projects/type_declarations/src/caster.rb
|
423
424
|
- projects/type_declarations/src/desugarizer.rb
|
425
|
+
- projects/type_declarations/src/desugarizer_pipeline.rb
|
424
426
|
- projects/type_declarations/src/dsl/attributes.rb
|
425
427
|
- projects/type_declarations/src/element_processor.rb
|
426
428
|
- projects/type_declarations/src/error_extension.rb
|
@@ -430,7 +432,9 @@ files:
|
|
430
432
|
- projects/type_declarations/src/handlers/extend_array_type_declaration/to_type_transformer.rb
|
431
433
|
- projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb
|
432
434
|
- projects/type_declarations/src/handlers/extend_associative_array_type_declaration.rb
|
435
|
+
- projects/type_declarations/src/handlers/extend_associative_array_type_declaration/key_type_declaration_desugarizer.rb
|
433
436
|
- projects/type_declarations/src/handlers/extend_associative_array_type_declaration/to_type_transformer.rb
|
437
|
+
- projects/type_declarations/src/handlers/extend_associative_array_type_declaration/value_type_declaration_desugarizer.rb
|
434
438
|
- projects/type_declarations/src/handlers/extend_attributes_type_declaration.rb
|
435
439
|
- projects/type_declarations/src/handlers/extend_attributes_type_declaration/dsl_desugarizer.rb
|
436
440
|
- projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb
|
@@ -442,13 +446,11 @@ files:
|
|
442
446
|
- projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb
|
443
447
|
- projects/type_declarations/src/handlers/extend_tuple_type_declaration/to_type_transformer.rb
|
444
448
|
- projects/type_declarations/src/handlers/registered_type_declaration.rb
|
445
|
-
- projects/type_declarations/src/handlers/registered_type_declaration/desugarizer_metadata_cleanup_desugarizer.rb
|
446
|
-
- projects/type_declarations/src/handlers/registered_type_declaration/short_type_name_desugarizer.rb
|
447
|
-
- projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb
|
448
|
-
- projects/type_declarations/src/handlers/registered_type_declaration/strict_stringified_desugarizer.rb
|
449
|
-
- projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb
|
450
449
|
- projects/type_declarations/src/handlers/registered_type_declaration/to_type_transformer.rb
|
451
|
-
- projects/type_declarations/src/
|
450
|
+
- projects/type_declarations/src/lazy_element_types/array.rb
|
451
|
+
- projects/type_declarations/src/lazy_element_types/attributes.rb
|
452
|
+
- projects/type_declarations/src/lazy_element_types/hash.rb
|
453
|
+
- projects/type_declarations/src/lazy_element_types/tuple.rb
|
452
454
|
- projects/type_declarations/src/processor.rb
|
453
455
|
- projects/type_declarations/src/remove_sensitive_values_transformer.rb
|
454
456
|
- projects/type_declarations/src/sensitive_type_remover.rb
|
@@ -459,6 +461,7 @@ files:
|
|
459
461
|
- projects/type_declarations/src/to_type_transformer.rb
|
460
462
|
- projects/type_declarations/src/transformer.rb
|
461
463
|
- projects/type_declarations/src/type_builder.rb
|
464
|
+
- projects/type_declarations/src/type_declaration.rb
|
462
465
|
- projects/type_declarations/src/type_declaration_error.rb
|
463
466
|
- projects/type_declarations/src/type_declaration_handler.rb
|
464
467
|
- projects/type_declarations/src/type_declaration_handler_registry.rb
|
@@ -535,7 +538,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
535
538
|
- !ruby/object:Gem::Version
|
536
539
|
version: '0'
|
537
540
|
requirements: []
|
538
|
-
rubygems_version: 3.
|
541
|
+
rubygems_version: 3.7.1
|
539
542
|
specification_version: 4
|
540
543
|
summary: A command-centric and discoverable software framework with a focus on domain
|
541
544
|
concepts and abstracting away integration code
|
@@ -1,29 +0,0 @@
|
|
1
|
-
Foobara.require_project_file("type_declarations", "desugarizer")
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module TypeDeclarations
|
5
|
-
module Handlers
|
6
|
-
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
7
|
-
# type_symbol is basically just a flag that lets us know that type is fully qualified.
|
8
|
-
# rather hacky but other potential workarounds seemed gnarlier
|
9
|
-
class DesugarizerMetadataCleanupDesugarizer < TypeDeclarations::Desugarizer
|
10
|
-
def applicable?(strict_type_declaration)
|
11
|
-
strict_type_declaration.is_a?(::Hash)
|
12
|
-
end
|
13
|
-
|
14
|
-
def desugarize(strict_type_declaration)
|
15
|
-
strict_type_declaration = strict_type_declaration.dup
|
16
|
-
|
17
|
-
strict_type_declaration.delete(:_desugarized)
|
18
|
-
|
19
|
-
strict_type_declaration
|
20
|
-
end
|
21
|
-
|
22
|
-
def priority
|
23
|
-
Priority::LOWEST + 100
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
Foobara.require_project_file("type_declarations", "desugarizer")
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module TypeDeclarations
|
5
|
-
module Handlers
|
6
|
-
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
7
|
-
class ShortTypeNameDesugarizer < TypeDeclarations::Desugarizer
|
8
|
-
def applicable?(sugary_type_declaration)
|
9
|
-
return false if TypeDeclarations.strict_stringified? || TypeDeclarations.strict?
|
10
|
-
return false unless sugary_type_declaration.is_a?(::Hash)
|
11
|
-
|
12
|
-
sugary_type_declaration = sugary_type_declaration.dup
|
13
|
-
|
14
|
-
sugary_type_declaration = normalize_type(sugary_type_declaration)
|
15
|
-
|
16
|
-
if sugary_type_declaration.key?(:type) &&
|
17
|
-
!sugary_type_declaration.dig(:_desugarized, :type_absolutified)
|
18
|
-
type_symbol = sugary_type_declaration[:type]
|
19
|
-
|
20
|
-
(type_symbol.is_a?(::Symbol) || type_symbol.is_a?(::String)) && type_registered?(type_symbol)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def desugarize(sugary_type_declaration)
|
25
|
-
sugary_type_declaration = normalize_type(sugary_type_declaration)
|
26
|
-
|
27
|
-
type_symbol = sugary_type_declaration[:type]
|
28
|
-
type = lookup_type!(type_symbol)
|
29
|
-
|
30
|
-
desugarized = sugary_type_declaration[:_desugarized] || {}
|
31
|
-
desugarized[:type_absolutified] = true
|
32
|
-
# TODO: just use the symbol and nothing else??
|
33
|
-
# maybe confusing in languages with no distinction between symbol and string?
|
34
|
-
sugary_type_declaration.merge(type: type.full_type_symbol, _desugarized: desugarized)
|
35
|
-
end
|
36
|
-
|
37
|
-
# TODO: clean this up in a different desugarizer so we don't have to think about it here
|
38
|
-
def normalize_type(sugary_type_declaration)
|
39
|
-
if sugary_type_declaration.key?("type") && !sugary_type_declaration.key?(:type)
|
40
|
-
if Util.all_symbolizable_keys?(sugary_type_declaration)
|
41
|
-
sugary_type_declaration = Util.symbolize_keys(sugary_type_declaration)
|
42
|
-
type_symbol = sugary_type_declaration[:type]
|
43
|
-
|
44
|
-
if type_symbol.is_a?(::String)
|
45
|
-
sugary_type_declaration[:type] = type_symbol.to_sym
|
46
|
-
end
|
47
|
-
end
|
48
|
-
else
|
49
|
-
sugary_type_declaration = sugary_type_declaration.dup
|
50
|
-
end
|
51
|
-
|
52
|
-
sugary_type_declaration
|
53
|
-
end
|
54
|
-
|
55
|
-
def priority
|
56
|
-
Priority::FIRST + 2
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/projects/type_declarations/src/handlers/registered_type_declaration/strict_desugarizer.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
Foobara.require_project_file("type_declarations", "desugarizer")
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module TypeDeclarations
|
5
|
-
module Handlers
|
6
|
-
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
7
|
-
# type_symbol is basically just a flag that lets us know that type is fully qualified.
|
8
|
-
# rather hacky but other potential workarounds seemed gnarlier
|
9
|
-
class StrictDesugarizer < TypeDeclarations::Desugarizer
|
10
|
-
def applicable?(strict_type_declaration)
|
11
|
-
# TODO: we shouldn't have to check if this is a hash. This means some other desugarizer is unnecessarily
|
12
|
-
# processing a type declaration as if it were sugary. Find and fix that to speed this up a tiny bit.
|
13
|
-
return false unless strict_type_declaration.is_a?(::Hash) && TypeDeclarations.strict?
|
14
|
-
|
15
|
-
!strict_type_declaration.dig(:_desugarized, :type_absolutified)
|
16
|
-
end
|
17
|
-
|
18
|
-
def desugarize(strict_type_declaration)
|
19
|
-
strict_type_declaration = Util.symbolize_keys(strict_type_declaration)
|
20
|
-
desugarized = strict_type_declaration[:_desugarized] || {}
|
21
|
-
desugarized[:type_absolutified] = true
|
22
|
-
strict_type_declaration.merge(_desugarized: desugarized)
|
23
|
-
end
|
24
|
-
|
25
|
-
def priority
|
26
|
-
Priority::FIRST
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Foobara.require_project_file("type_declarations", "desugarizer")
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module TypeDeclarations
|
5
|
-
module Handlers
|
6
|
-
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
7
|
-
# type_symbol is basically just a flag that lets us know that type is fully qualified.
|
8
|
-
# rather hacky but other potential workarounds seemed gnarlier
|
9
|
-
class StrictStringifiedDesugarizer < TypeDeclarations::Desugarizer
|
10
|
-
def applicable?(sugary_type_declaration)
|
11
|
-
# TODO: we shouldn't have to check if this is a hash. This means some other desugarizer is unnecessarily
|
12
|
-
# processing a type declaration as if it were sugary. Find and fix that to speed this up a tiny bit.
|
13
|
-
return false unless sugary_type_declaration.is_a?(::Hash) && TypeDeclarations.strict_stringified?
|
14
|
-
|
15
|
-
!sugary_type_declaration.dig(:_desugarized, :type_absolutified)
|
16
|
-
end
|
17
|
-
|
18
|
-
def desugarize(sugary_type_declaration)
|
19
|
-
sugary_type_declaration = Util.symbolize_keys(sugary_type_declaration)
|
20
|
-
type_symbol = sugary_type_declaration[:type]
|
21
|
-
|
22
|
-
type = Foobara.foobara_root_namespace.foobara_lookup_type!(type_symbol,
|
23
|
-
mode: Namespace::LookupMode::ABSOLUTE)
|
24
|
-
|
25
|
-
type_symbol = type.full_type_symbol
|
26
|
-
|
27
|
-
desugarized = sugary_type_declaration[:_desugarized] || {}
|
28
|
-
desugarized[:type_absolutified] = true
|
29
|
-
sugary_type_declaration.merge(_desugarized: desugarized, type: type_symbol)
|
30
|
-
end
|
31
|
-
|
32
|
-
def priority
|
33
|
-
Priority::FIRST
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/projects/type_declarations/src/handlers/registered_type_declaration/symbol_desugarizer.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
Foobara.require_project_file("type_declarations", "desugarizer")
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module TypeDeclarations
|
5
|
-
module Handlers
|
6
|
-
class RegisteredTypeDeclaration < TypeDeclarationHandler
|
7
|
-
# TODO: make a quick way to convert a couple simple procs into a transformer
|
8
|
-
class SymbolDesugarizer < TypeDeclarations::Desugarizer
|
9
|
-
def applicable?(sugary_type_declaration)
|
10
|
-
if sugary_type_declaration.is_a?(::Symbol)
|
11
|
-
type_registered?(sugary_type_declaration)
|
12
|
-
elsif sugary_type_declaration.is_a?(::String) && TypeDeclarations.stringified?
|
13
|
-
applicable?(sugary_type_declaration.to_sym)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def desugarize(symbol)
|
18
|
-
# TODO: just use the symbol and nothing else??
|
19
|
-
# maybe confusing in languages with no distinction between symbol and string?
|
20
|
-
{ type: symbol.to_sym }
|
21
|
-
end
|
22
|
-
|
23
|
-
def priority
|
24
|
-
Priority::FIRST
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|