foobara 0.0.54 → 0.0.56
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 +11 -0
- data/projects/builtin_types/lib/foobara/builtin_types.rb +1 -0
- data/projects/builtin_types/src/attributes/transformers/remove_unexpected_attributes.rb +27 -0
- data/projects/builtin_types/src/date/casters/string.rb +2 -2
- data/projects/command_connectors/src/command_connector.rb +5 -4
- data/projects/manifest/src/foobara/manifest/domain.rb +3 -3
- data/projects/manifest/src/foobara/manifest/type.rb +15 -32
- data/projects/model/src/model.rb +15 -1
- data/projects/types/src/type.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc60d4f3abb03f4cb398aca513da228aaaf2359941a9d6873d970004b8faf1a8
|
4
|
+
data.tar.gz: d94f3b0f676dcf2a69ae1acdbad58efa0dc0ff8626f77de6219ca55b23ac7e41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6348c488613dfb77695af95e1951a0e373787a8277bcee39e26495ee5b1c66f46e8f30a46c24ae7db4050bade755a0fbf181a2618de0f149308c752660fe7352
|
7
|
+
data.tar.gz: 6fe896d06734768e017dfc21753d7de90da00fdde88a5822900876f2030e84c04539fddc0ecc9bf7eb638b4ef9e745c9aafd8afa0826c97dc115ce9029cce46b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## [0.0.56] - 2025-02-16
|
2
|
+
|
3
|
+
- Bump Ruby to 3.4.2
|
4
|
+
- Add a ignore_unexpected_attributes option to Model#initialize
|
5
|
+
|
6
|
+
## [0.0.55] - 2025-02-01
|
7
|
+
|
8
|
+
- Mark types as builtin directly and add builtin flag to manifest
|
9
|
+
- Pass Request#inputs through to Describe and other commands
|
10
|
+
- Fix bugs around what is considered a manifest entity/model
|
11
|
+
|
1
12
|
## [0.0.54] - 2025-01-31
|
2
13
|
|
3
14
|
- Change interface of base_type_for_manifest
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Foobara
|
2
|
+
module BuiltinTypes
|
3
|
+
module Attributes
|
4
|
+
module Transformers
|
5
|
+
class RemoveUnexpectedAttributes < Value::Transformer
|
6
|
+
class << self
|
7
|
+
def requires_parent_declaration_data?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def applicable?(hash)
|
13
|
+
Thread.foobara_var_get(:foobara_ignore_unexpected_attributes) && unexpected_attributes(hash).any?
|
14
|
+
end
|
15
|
+
|
16
|
+
def transform(hash)
|
17
|
+
hash.except(*unexpected_attributes(hash))
|
18
|
+
end
|
19
|
+
|
20
|
+
def unexpected_attributes(hash)
|
21
|
+
hash.keys - parent_declaration_data[:element_type_declarations].keys
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -15,11 +15,11 @@ module Foobara
|
|
15
15
|
parse(string)
|
16
16
|
end
|
17
17
|
|
18
|
-
private
|
19
|
-
|
20
18
|
NOT_DELIMITED_REGEX = /\A(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})\z/
|
21
19
|
DELIMITED_REGEX = /\A(?<year>\d{4,})(?<delimiter>[\/\\.|_:;-])(?<month>\d{1,2})\k<delimiter>(?<day>\d{1,2})\z/
|
22
20
|
|
21
|
+
private
|
22
|
+
|
23
23
|
def parse(string)
|
24
24
|
match = NOT_DELIMITED_REGEX.match(string) || DELIMITED_REGEX.match(string)
|
25
25
|
|
@@ -139,7 +139,8 @@ module Foobara
|
|
139
139
|
command_class = find_builtin_command_class("Describe")
|
140
140
|
full_command_name = command_class.full_command_name
|
141
141
|
|
142
|
-
inputs =
|
142
|
+
inputs = request.inputs.merge(manifestable:, request:)
|
143
|
+
|
143
144
|
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
144
145
|
transform_command_class(command_class)
|
145
146
|
when "describe_command"
|
@@ -154,7 +155,7 @@ module Foobara
|
|
154
155
|
command_class = find_builtin_command_class("Describe")
|
155
156
|
full_command_name = command_class.full_command_name
|
156
157
|
|
157
|
-
inputs =
|
158
|
+
inputs = request.inputs.merge(manifestable: transformed_command_class, request:)
|
158
159
|
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
159
160
|
transform_command_class(command_class)
|
160
161
|
when "describe_type"
|
@@ -169,14 +170,14 @@ module Foobara
|
|
169
170
|
command_class = find_builtin_command_class("Describe")
|
170
171
|
full_command_name = command_class.full_command_name
|
171
172
|
|
172
|
-
inputs =
|
173
|
+
inputs = request.inputs.merge(manifestable: type, request:)
|
173
174
|
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
174
175
|
transform_command_class(command_class)
|
175
176
|
when "manifest"
|
176
177
|
command_class = find_builtin_command_class("Describe")
|
177
178
|
full_command_name = command_class.full_command_name
|
178
179
|
|
179
|
-
inputs =
|
180
|
+
inputs = request.inputs.merge(manifestable: self, request:)
|
180
181
|
transformed_command_class = transformed_command_from_name(full_command_name) ||
|
181
182
|
transform_command_class(command_class)
|
182
183
|
when "ping"
|
@@ -20,15 +20,15 @@ module Foobara
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def detached_entities
|
23
|
-
@detached_entities ||=
|
23
|
+
@detached_entities ||= models.select(&:detached_entity?)
|
24
24
|
end
|
25
25
|
|
26
26
|
def entities
|
27
|
-
@entities ||=
|
27
|
+
@entities ||= detached_entities.select(&:entity?)
|
28
28
|
end
|
29
29
|
|
30
30
|
def models
|
31
|
-
@models ||= types.select(&:model?)
|
31
|
+
@models ||= types.select(&:model?).reject(&:builtin?)
|
32
32
|
end
|
33
33
|
|
34
34
|
def global?
|
@@ -27,44 +27,15 @@ module Foobara
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def entity?
|
30
|
-
|
31
|
-
|
32
|
-
while type
|
33
|
-
return true if type.reference.to_sym == :entity
|
34
|
-
|
35
|
-
type = type.base_type
|
36
|
-
end
|
37
|
-
|
38
|
-
false
|
30
|
+
!builtin? && extends_symbol?(:entity)
|
39
31
|
end
|
40
32
|
|
41
33
|
def detached_entity?
|
42
|
-
|
43
|
-
|
44
|
-
type = base_type
|
45
|
-
|
46
|
-
while type
|
47
|
-
return true if type.reference.to_sym == :detached_entity
|
48
|
-
|
49
|
-
type = type.base_type
|
50
|
-
end
|
51
|
-
|
52
|
-
false
|
34
|
+
!builtin? && extends_symbol?(:detached_entity)
|
53
35
|
end
|
54
36
|
|
55
37
|
def model?
|
56
|
-
|
57
|
-
return false if %w[entity detached_entity].include?(reference)
|
58
|
-
|
59
|
-
type = base_type
|
60
|
-
|
61
|
-
while type
|
62
|
-
return true if type.reference.to_sym == :model
|
63
|
-
|
64
|
-
type = type.base_type
|
65
|
-
end
|
66
|
-
|
67
|
-
false
|
38
|
+
!builtin? && extends_symbol?(:model)
|
68
39
|
end
|
69
40
|
|
70
41
|
def base_type
|
@@ -102,6 +73,18 @@ module Foobara
|
|
102
73
|
def builtin?
|
103
74
|
BuiltinTypes.builtin_reference?(reference)
|
104
75
|
end
|
76
|
+
|
77
|
+
def extends_symbol?(symbol)
|
78
|
+
type = base_type
|
79
|
+
|
80
|
+
while type
|
81
|
+
return true if type.reference.to_sym == symbol
|
82
|
+
|
83
|
+
type = type.base_type
|
84
|
+
end
|
85
|
+
|
86
|
+
false
|
87
|
+
end
|
105
88
|
end
|
106
89
|
end
|
107
90
|
end
|
data/projects/model/src/model.rb
CHANGED
@@ -171,7 +171,7 @@ module Foobara
|
|
171
171
|
attr_accessor :mutable
|
172
172
|
|
173
173
|
def initialize(attributes = nil, options = {})
|
174
|
-
allowed_options = %i[validate mutable]
|
174
|
+
allowed_options = %i[validate mutable ignore_unexpected_attributes]
|
175
175
|
invalid_options = options.keys - allowed_options
|
176
176
|
|
177
177
|
unless invalid_options.empty?
|
@@ -180,6 +180,12 @@ module Foobara
|
|
180
180
|
# :nocov:
|
181
181
|
end
|
182
182
|
|
183
|
+
if options[:ignore_unexpected_attributes]
|
184
|
+
Thread.foobara_with_var(:foobara_ignore_unexpected_attributes, true) do
|
185
|
+
return initialize(attributes, options.except(:ignore_unexpected_attributes))
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
183
189
|
validate = options[:validate]
|
184
190
|
|
185
191
|
if attributes.nil?
|
@@ -189,6 +195,14 @@ module Foobara
|
|
189
195
|
# :nocov:
|
190
196
|
end
|
191
197
|
else
|
198
|
+
if Thread.foobara_var_get(:foobara_ignore_unexpected_attributes)
|
199
|
+
outcome = attributes_type.process_value(attributes)
|
200
|
+
|
201
|
+
if outcome.success?
|
202
|
+
attributes = outcome.result
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
192
206
|
self.mutable = true
|
193
207
|
attributes.each_pair do |attribute_name, value|
|
194
208
|
write_attribute(attribute_name, value)
|
data/projects/types/src/type.rb
CHANGED
@@ -22,6 +22,7 @@ module Foobara
|
|
22
22
|
:structure_count,
|
23
23
|
:element_types,
|
24
24
|
:element_type,
|
25
|
+
:is_builtin,
|
25
26
|
:raw_declaration_data,
|
26
27
|
:name,
|
27
28
|
:target_classes,
|
@@ -322,7 +323,8 @@ module Foobara
|
|
322
323
|
target_classes: target_classes.map(&:name).sort,
|
323
324
|
declaration_data:,
|
324
325
|
types_depended_on: types.sort,
|
325
|
-
possible_errors: possible_errors_manifests
|
326
|
+
possible_errors: possible_errors_manifests,
|
327
|
+
builtin: builtin?
|
326
328
|
).merge(description:, base_type: base_type_for_manifest&.full_type_name&.to_sym)
|
327
329
|
|
328
330
|
h.merge!(
|
@@ -340,6 +342,10 @@ module Foobara
|
|
340
342
|
super.merge(h)
|
341
343
|
end
|
342
344
|
|
345
|
+
def builtin?
|
346
|
+
is_builtin
|
347
|
+
end
|
348
|
+
|
343
349
|
def base_type_for_manifest
|
344
350
|
base_type
|
345
351
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/desugarizers/move_required_from_element_types_to_root.rb
|
72
72
|
- projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_of_symbols.rb
|
73
73
|
- projects/builtin_types/src/attributes/supported_validators/required/type_declaration_extension/extend_attributes_type_declaration/type_declaration_validators/array_with_valid_attribute_names.rb
|
74
|
+
- projects/builtin_types/src/attributes/transformers/remove_unexpected_attributes.rb
|
74
75
|
- projects/builtin_types/src/big_decimal/casters/integer.rb
|
75
76
|
- projects/builtin_types/src/big_decimal/casters/string.rb
|
76
77
|
- projects/builtin_types/src/boolean/casters/numeric.rb
|