foobara 0.0.124 → 0.0.125
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 +4 -0
- data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -0
- data/projects/command_connectors/src/desugarizers/attributes/inputs_from_yaml.rb +23 -0
- data/projects/command_connectors/src/desugarizers/attributes.rb +5 -1
- data/projects/type_declarations/src/attributes_transformers/from_yaml.rb +67 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff16e115901fed01d02a1d3a82cb136672b4f2a903f4d982311a38ea03f711d3
|
4
|
+
data.tar.gz: 206a0ea46c89ca30e036b9400870a237574cfac44783f3931e03eba1918bb06a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ca391c67892c58ac22452c084a4f7ce8f0de5b7fbfff756f57faa0ce822df2ef2786d3818c44871267203a9b323e5a89b810404d26508b29e9eb7ac6dc3b38
|
7
|
+
data.tar.gz: 1dfc1aa32f61a7b832dd29cb0d3a966fc38bd2908a146ca208dcb9aadaab9880beb07efd4256cb57b820e3b2982aff37f98c4ecea6bb5a31bd1a3fcfaa217e0d
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.3
|
data/CHANGELOG.md
CHANGED
@@ -19,6 +19,7 @@ module Foobara
|
|
19
19
|
CommandConnector.add_desugarizer Desugarizers::Attributes::RejectInputs
|
20
20
|
CommandConnector.add_desugarizer Desugarizers::Attributes::OnlyResult
|
21
21
|
CommandConnector.add_desugarizer Desugarizers::Attributes::RejectResult
|
22
|
+
CommandConnector.add_desugarizer Desugarizers::Attributes::InputsFromYaml
|
22
23
|
CommandConnector.add_desugarizer Desugarizers::Auth
|
23
24
|
end
|
24
25
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "../attributes"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module CommandConnectors
|
5
|
+
module Desugarizers
|
6
|
+
class Attributes < Desugarizer
|
7
|
+
class InputsFromYaml < Attributes
|
8
|
+
def desugarizer_symbol
|
9
|
+
:yaml
|
10
|
+
end
|
11
|
+
|
12
|
+
def transformer_method
|
13
|
+
:from_yaml
|
14
|
+
end
|
15
|
+
|
16
|
+
def opts_key
|
17
|
+
:inputs_transformers
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -40,7 +40,7 @@ module Foobara
|
|
40
40
|
transformers = transformers.map do |transformer|
|
41
41
|
if transformer.is_a?(::Hash) && transformer.key?(desugarizer_symbol)
|
42
42
|
params = transformer[desugarizer_symbol]
|
43
|
-
AttributesTransformers.send(
|
43
|
+
AttributesTransformers.send(transformer_method, *params)
|
44
44
|
else
|
45
45
|
transformer
|
46
46
|
end
|
@@ -52,6 +52,10 @@ module Foobara
|
|
52
52
|
|
53
53
|
[args, opts]
|
54
54
|
end
|
55
|
+
|
56
|
+
def transformer_method
|
57
|
+
desugarizer_symbol
|
58
|
+
end
|
55
59
|
end
|
56
60
|
end
|
57
61
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Foobara
|
2
|
+
class AttributesTransformers < TypeDeclarations::TypedTransformer
|
3
|
+
class << self
|
4
|
+
# TODO: dry this up with a .subclass method in AttributesTransformers?
|
5
|
+
def from_yaml(*attribute_names)
|
6
|
+
symbol = symbol_for_attribute_names(attribute_names)
|
7
|
+
existing = FromYaml.foobara_lookup(symbol, mode: Namespace::LookupMode::DIRECT)
|
8
|
+
|
9
|
+
return existing if existing
|
10
|
+
|
11
|
+
transformer_class = Class.new(FromYaml)
|
12
|
+
transformer_class.from_yaml_attributes = attribute_names
|
13
|
+
|
14
|
+
Namespace::NamespaceHelpers.foobara_autoset_scoped_path(transformer_class, set_namespace: true)
|
15
|
+
transformer_class.foobara_parent_namespace = transformer_class.scoped_namespace
|
16
|
+
transformer_class.scoped_namespace.foobara_register(transformer_class)
|
17
|
+
|
18
|
+
transformer_class
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class FromYaml < AttributesTransformers
|
23
|
+
class << self
|
24
|
+
attr_accessor :from_yaml_attributes
|
25
|
+
|
26
|
+
def symbol
|
27
|
+
if from_yaml_attributes
|
28
|
+
symbol_for_attribute_names(from_yaml_attributes)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def will_set_scoped_path?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def from_type_declaration
|
38
|
+
# TODO: verify the expected from_yaml keys are present
|
39
|
+
declaration = to_type.declaration_data
|
40
|
+
element_type_declarations = {}
|
41
|
+
from_yaml = self.class.from_yaml_attributes
|
42
|
+
|
43
|
+
declaration[:element_type_declarations].each_pair do |attribute_name, declaration_data|
|
44
|
+
element_type_declarations[attribute_name] = if from_yaml.include?(attribute_name)
|
45
|
+
{ type: :string }
|
46
|
+
else
|
47
|
+
declaration_data
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
declaration.merge(element_type_declarations:)
|
52
|
+
end
|
53
|
+
|
54
|
+
def transform(inputs)
|
55
|
+
inputs = Util.symbolize_keys(inputs)
|
56
|
+
|
57
|
+
self.class.from_yaml_attributes.each do |attribute_name|
|
58
|
+
if inputs.key?(attribute_name)
|
59
|
+
inputs[attribute_name] = YAML.load(inputs[attribute_name])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
inputs
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
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.125
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- projects/command_connectors/src/command_registry/exposed_organization.rb
|
207
207
|
- projects/command_connectors/src/desugarizer.rb
|
208
208
|
- projects/command_connectors/src/desugarizers/attributes.rb
|
209
|
+
- projects/command_connectors/src/desugarizers/attributes/inputs_from_yaml.rb
|
209
210
|
- projects/command_connectors/src/desugarizers/attributes/only_inputs.rb
|
210
211
|
- projects/command_connectors/src/desugarizers/attributes/only_result.rb
|
211
212
|
- projects/command_connectors/src/desugarizers/attributes/reject_inputs.rb
|
@@ -407,6 +408,7 @@ files:
|
|
407
408
|
- projects/type_declarations/lib/foobara/type_declarations.rb
|
408
409
|
- projects/type_declarations/src/attributes.rb
|
409
410
|
- projects/type_declarations/src/attributes_transformers.rb
|
411
|
+
- projects/type_declarations/src/attributes_transformers/from_yaml.rb
|
410
412
|
- projects/type_declarations/src/attributes_transformers/only.rb
|
411
413
|
- projects/type_declarations/src/attributes_transformers/reject.rb
|
412
414
|
- projects/type_declarations/src/caster.rb
|
@@ -526,7 +528,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
526
528
|
- !ruby/object:Gem::Version
|
527
529
|
version: '0'
|
528
530
|
requirements: []
|
529
|
-
rubygems_version: 3.6.
|
531
|
+
rubygems_version: 3.6.7
|
530
532
|
specification_version: 4
|
531
533
|
summary: A command-centric and discoverable software framework with a focus on domain
|
532
534
|
concepts and abstracting away integration code
|