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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fcb411acfca3b92a2e62c37e03307ae4928eb6d0ec3403669eaccfede0a5bdc
4
- data.tar.gz: 3bcb94c31ceb931ec20307afea22e73b9cea58124f6e6ebc1547ac55ce54224d
3
+ metadata.gz: ff16e115901fed01d02a1d3a82cb136672b4f2a903f4d982311a38ea03f711d3
4
+ data.tar.gz: 206a0ea46c89ca30e036b9400870a237574cfac44783f3931e03eba1918bb06a
5
5
  SHA512:
6
- metadata.gz: 43d30d0278cb5bbc66b88ff429af8dfb4cda0294f3657d60146aa7ddd5fdaf461124f4dca90710e1880327026f4b519c127ffaa4fe0f68cdb1b8804225713e2b
7
- data.tar.gz: 5b02922fcb530fea310c83d566ffcb89fab58dc003a8985c9ca67ea48ca9c3ffb9839964ffbef77f99b2c29e8b23e2db6a16cec8feacd514044d44d7ed274b23
6
+ metadata.gz: d0ca391c67892c58ac22452c084a4f7ce8f0de5b7fbfff756f57faa0ce822df2ef2786d3818c44871267203a9b323e5a89b810404d26508b29e9eb7ac6dc3b38
7
+ data.tar.gz: 1dfc1aa32f61a7b832dd29cb0d3a966fc38bd2908a146ca208dcb9aadaab9880beb07efd4256cb57b820e3b2982aff37f98c4ecea6bb5a31bd1a3fcfaa217e0d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.4.2
1
+ 3.4.3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # [0.0.125] - 2025-05-15
2
+
3
+ - Create a yaml inputs sugar
4
+
1
5
  # [0.0.124] - 2025-05-14
2
6
 
3
7
  - Fix bug creating multiple exposed domains instead of just one
@@ -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(desugarizer_symbol, *params)
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.124
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: 2025-05-14 00:00:00.000000000 Z
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.2
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