foobara-http-command-connector 1.1.2 → 1.1.3

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: cd81c1b2d8756cb8c7327baec7f613f34ce83e32147116a26d738591483a56c0
4
- data.tar.gz: 1ad4abff7f7e616f7bedb3b7aa75db79e8a015c665c4187c5f484a45ee7484aa
3
+ metadata.gz: 1715bfa9cb8f787d96db3b2f527b314e9a21bc61cdb493e80db1c716c101a73d
4
+ data.tar.gz: 751386e288a082a533560620176b612ea8752c6fdf98ee985072e917fd45f253
5
5
  SHA512:
6
- metadata.gz: 7b057ea5d61ff69bbf4518b74b5a7c44417eaf73a8864b05be914ea09a3daf560bf0f193aaec870b6beef8ea78dd043c4f8728ef5af7c09d2743220804d7b2dd
7
- data.tar.gz: ea3b0c2694e1893d5b92dc288289f92d66e74f26d1d6c90901218edc9e9c41a9dd3e512ed1433dd6054ac4c9d2bebe6be18da7864cc082eb885ce02adc97cd07
6
+ metadata.gz: a1e22c9dec299e223eeb6ff2e79fef4b01f1f83687b213cadf42196a5887a9cdce3941030e35945216c6a5f70931fb6418c3011fea507fe0bcfbbbac561d0486
7
+ data.tar.gz: 2714a1040ea6857c0cdf818524b5ce0b67496a43dc421b4bd41c8cb1c0294b9762fb6cd35adfa9f6900e23b784ae2efb85b2d0d48b0c4db53781c9e5778759ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.1.3] - 2026-01-21
2
+
3
+ - Add `set:` request mutator sugar
4
+
1
5
  ## [1.1.2] - 2025-12-18
2
6
 
3
7
  - Fix bug causing commands to cram together on help page
@@ -2,3 +2,15 @@ require "foobara/all"
2
2
  require "foobara/command_connectors"
3
3
 
4
4
  Foobara::Util.require_directory "#{__dir__}/../../src"
5
+
6
+ module Foobara
7
+ module HttpCommandConnector
8
+ class << self
9
+ def install!
10
+ CommandConnector.add_desugarizer CommandConnectors::Http::Desugarizers::SetInputToProcResult
11
+ end
12
+ end
13
+ end
14
+
15
+ project "http_command_connector", project_path: "#{__dir__}/../../"
16
+ end
@@ -0,0 +1,51 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ class Http < CommandConnector
4
+ module Desugarizers
5
+ class SetInputToProcResult < Desugarizer
6
+ def applicable?(args_and_opts)
7
+ _args, opts = args_and_opts
8
+
9
+ return false unless opts.key?(:request_mutators)
10
+
11
+ mutators = opts[:request_mutators]
12
+ mutators = Util.array(mutators)
13
+
14
+ mutators.any? do |mutator|
15
+ mutator.is_a?(::Hash) && mutator.key?(:set)
16
+ end
17
+ end
18
+
19
+ def desugarize(args_and_opts)
20
+ args, opts = args_and_opts
21
+
22
+ mutators = opts[:request_mutators]
23
+ resulting_mutators = []
24
+
25
+ Util.array(mutators).map do |mutator|
26
+ if mutator.is_a?(::Hash) && mutator.key?(:set)
27
+ if mutator.size > 1
28
+ # TODO: add test for this
29
+ # :nocov:
30
+ resulting_mutators << mutator.except(:set)
31
+ # :nocov:
32
+ end
33
+
34
+ mutator[:set].each_pair do |input_name, proc|
35
+ resulting_mutators << Http::SetInputToProcResult.for(input_name, &proc)
36
+ end
37
+ else
38
+ # TODO: add a test for this
39
+ # :nocov:
40
+ resulting_mutators << mutator
41
+ # :nocov:
42
+ end
43
+ end
44
+
45
+ [args, opts.merge(request_mutators: resulting_mutators)]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -3,6 +3,7 @@ module Foobara
3
3
  class Http < CommandConnector
4
4
  # TODO: We don't really want to mutate the request. We just need access to the authenticated user.
5
5
  # consider changing inputs transformer to have access to the command/request somehow
6
+ # TODO: what does this have to do with HTTP? Shouldn't this be a generic mutator for all connectors?
6
7
  class SetInputToProcResult < RequestMutator
7
8
  class << self
8
9
  attr_accessor :attribute_name, :input_value_proc
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-http-command-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -70,6 +70,7 @@ files:
70
70
  - src/http/commands/help/templates/root.html.erb
71
71
  - src/http/commands/help/templates/type.html.erb
72
72
  - src/http/cookie.rb
73
+ - src/http/desugarizers/set_input_to_proc_result.rb
73
74
  - src/http/request.rb
74
75
  - src/http/request_mutators/set_input_from_cookie.rb
75
76
  - src/http/request_mutators/set_input_from_header.rb