foobara 0.0.84 → 0.0.86
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/CHANGELOG.md +8 -0
- data/projects/manifest/src/foobara/manifest/type_declaration.rb +5 -2
- data/projects/namespace/src/namespace_helpers.rb +14 -1
- data/projects/type_declarations/src/attributes.rb +16 -0
- data/projects/type_declarations/src/attributes_transformer.rb +33 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e400689de8a729a2ed91fc3fd0da0e447e4d773ece5a6efc42e4ee555eb665ef
|
4
|
+
data.tar.gz: 29f503d3d3263ad637add42716b757aba79688f98871a71cf9d011c72af28bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35490b924e4f50e2752936b26bbafd25e42b88c8be4a404e006befe58fb9b2b60be54eb54f039f4d5b2a455b409e256b5cbc8bc8496cc1a9e9bf94b52e17330f
|
7
|
+
data.tar.gz: 51745cf6ea9e92c93e6c2a944073232cb07126f35c6f0d10574b56f5b46ae2f91aef909008ab09b9d6d49711a9dc31c0b3ef2a74dc1b0cac4fbb1efe26ecf84b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# [0.0.86] - 2025-03-23
|
2
|
+
|
3
|
+
- Add an AttributesTransformer.only method to quickly get a TypedTransformer (helpful with inputs_transformers)
|
4
|
+
|
5
|
+
# [0.0.85] - 2025-03-22
|
6
|
+
|
7
|
+
- Add Manifest::TypeDeclaration#sensitive?
|
8
|
+
|
1
9
|
# [0.0.84] - 2025-03-22
|
2
10
|
|
3
11
|
- Remove sensitive values from command connector results
|
@@ -3,7 +3,7 @@ require_relative "base_manifest"
|
|
3
3
|
module Foobara
|
4
4
|
module Manifest
|
5
5
|
class TypeDeclaration < BaseManifest
|
6
|
-
optional_keys(:allow_nil, :one_of)
|
6
|
+
optional_keys(:allow_nil, :one_of, :sensitive, :sensitive_exposed)
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def new(root_manifest, path)
|
@@ -24,6 +24,10 @@ module Foobara
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def sensitive?
|
28
|
+
sensitive || sensitive_exposed
|
29
|
+
end
|
30
|
+
|
27
31
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
28
32
|
# TODO: create an Attribute class to encapsulate this situation
|
29
33
|
def attribute?
|
@@ -88,7 +92,6 @@ module Foobara
|
|
88
92
|
|
89
93
|
def to_model
|
90
94
|
raise "not an model" unless model?
|
91
|
-
raise "model extension instead of an model" unless relevant_manifest.size == 1
|
92
95
|
|
93
96
|
type = to_type
|
94
97
|
|
@@ -164,7 +164,20 @@ module Foobara
|
|
164
164
|
def foobara_autoset_scoped_path(mod, make_top_level: false)
|
165
165
|
return if mod.scoped_path_set?
|
166
166
|
|
167
|
-
|
167
|
+
mod_name = mod.name
|
168
|
+
|
169
|
+
if mod_name.nil?
|
170
|
+
parent = mod.superclass
|
171
|
+
super_name = nil
|
172
|
+
|
173
|
+
begin
|
174
|
+
super_name = parent.scoped_path_set? ? parent.scoped_full_name : parent.name
|
175
|
+
end until super_name
|
176
|
+
|
177
|
+
mod_name = [super_name, mod.object_id.to_s(16)].join("::")
|
178
|
+
end
|
179
|
+
|
180
|
+
scoped_path = mod_name.split("::")
|
168
181
|
|
169
182
|
adjusted_scoped_path = []
|
170
183
|
|
@@ -33,6 +33,22 @@ module Foobara
|
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
36
|
+
def only(declaration, *keys)
|
37
|
+
valid_keys = declaration[:element_type_declarations].keys
|
38
|
+
keys_to_keep = keys.map(&:to_sym)
|
39
|
+
invalid_keys = keys_to_keep - valid_keys
|
40
|
+
|
41
|
+
if invalid_keys.any?
|
42
|
+
# :nocov:
|
43
|
+
raise ArgumentError, "Invalid keys: #{invalid_keys} expected only #{valid_keys}"
|
44
|
+
# :nocov:
|
45
|
+
end
|
46
|
+
|
47
|
+
keys_to_reject = valid_keys - keys_to_keep
|
48
|
+
|
49
|
+
reject(declaration, keys_to_reject)
|
50
|
+
end
|
51
|
+
|
36
52
|
def reject(declaration, *keys)
|
37
53
|
# TODO: do we really need a deep dup?
|
38
54
|
declaration = Util.deep_dup(declaration)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Foobara
|
2
|
+
class AttributesTransformer < TypeDeclarations::TypedTransformer
|
3
|
+
class << self
|
4
|
+
attr_accessor :only_attributes
|
5
|
+
|
6
|
+
def type_declaration(from_type)
|
7
|
+
from_declaration = from_type.declaration_data
|
8
|
+
to_declaration = TypeDeclarations::Attributes.only(from_declaration, *only_attributes)
|
9
|
+
|
10
|
+
if TypeDeclarations.declarations_equal?(from_declaration, to_declaration)
|
11
|
+
from_type
|
12
|
+
else
|
13
|
+
from_type.foobara_domain.foobara_type_from_declaration(to_declaration)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def only(*attribute_names)
|
18
|
+
transformer_class = Class.new(self)
|
19
|
+
transformer_class.only_attributes = attribute_names
|
20
|
+
|
21
|
+
transformer_class
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def transform(inputs)
|
26
|
+
inputs.slice(*allowed_keys)
|
27
|
+
end
|
28
|
+
|
29
|
+
def allowed_keys
|
30
|
+
type.element_types.keys
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
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.0.
|
4
|
+
version: 0.0.86
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -359,6 +359,7 @@ files:
|
|
359
359
|
- projects/thread_parent/src/thread_parent.rb
|
360
360
|
- projects/type_declarations/lib/foobara/type_declarations.rb
|
361
361
|
- projects/type_declarations/src/attributes.rb
|
362
|
+
- projects/type_declarations/src/attributes_transformer.rb
|
362
363
|
- projects/type_declarations/src/caster.rb
|
363
364
|
- projects/type_declarations/src/desugarizer.rb
|
364
365
|
- projects/type_declarations/src/dsl/attributes.rb
|