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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1715bfa9cb8f787d96db3b2f527b314e9a21bc61cdb493e80db1c716c101a73d
|
|
4
|
+
data.tar.gz: 751386e288a082a533560620176b612ea8752c6fdf98ee985072e917fd45f253
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1e22c9dec299e223eeb6ff2e79fef4b01f1f83687b213cadf42196a5887a9cdce3941030e35945216c6a5f70931fb6418c3011fea507fe0bcfbbbac561d0486
|
|
7
|
+
data.tar.gz: 2714a1040ea6857c0cdf818524b5ce0b67496a43dc421b4bd41c8cb1c0294b9762fb6cd35adfa9f6900e23b784ae2efb85b2d0d48b0c4db53781c9e5778759ce
|
data/CHANGELOG.md
CHANGED
|
@@ -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.
|
|
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
|