foobara-http-command-connector 0.0.15 → 0.0.17

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: 4a6e931ec6770cb9d080f7881905dfac20b5246a0ca5726e14ce37151edff543
4
- data.tar.gz: b11048224ade66b0fda7dc73b33ce49f522402e283e8ac10bd776e5548c9b6bd
3
+ metadata.gz: 867605b13dfdbb6e3735a376abee65a62af60597a1158946928295823f901980
4
+ data.tar.gz: 2ef5837bd5fed7c4ad21a952faee5b4b51a7af1e94acf4e2cfc7b037bd7dc75d
5
5
  SHA512:
6
- metadata.gz: 3b4386dd8cbcdccd2b4fe4bc02dde29cae04704fa56e5458dd77d712515518c9e91af64664255679f81539c6b33346b3c8aa91e33cdac95ba98073a5d74359d1
7
- data.tar.gz: 5fbb2a89db7b9605e0509eaac865feea185dd13ac6067c2ce8166cac87970bcf09ab3e2ba31f02c6cfb4328e86b2bbb304cc32ada10193411bd1f0948e001e15
6
+ metadata.gz: f5e4f2ddec2597b5f5b42e900420bea28d9f1f770ca063793afd18938e33a03405c8020d8b2d03e7a214c4b8fc67fe97e75b9b16638641816534e61b927c3593
7
+ data.tar.gz: ab961b1861b1b6ba002b71c46c566cf6eb157148f17ec02f3ca67eec2a8dcc388873b0d6058ef113523d4c97199ed50b687dda98d5b06ebd1dfbd40909c8edaa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.17] - 2025-03-29
2
+
3
+ - Implement SetInputsFromCookie request mutator
4
+
1
5
  ## [0.0.15] - 2025-03-28
2
6
 
3
7
  - Implement MoveAttributeToCookie response mutator
@@ -0,0 +1,42 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ class Http < CommandConnector
4
+ class SetInputFromCookie < RequestMutator
5
+ class << self
6
+ attr_accessor :attribute_name, :cookie_name
7
+
8
+ def for(attribute_name, cookie_name = attribute_name)
9
+ subclass = Class.new(self)
10
+
11
+ cookie_name = cookie_name.to_s if cookie_name.is_a?(::Symbol)
12
+
13
+ subclass.attribute_name = attribute_name
14
+ subclass.cookie_name = cookie_name
15
+
16
+ subclass
17
+ end
18
+ end
19
+
20
+ attr_writer :attribute_name, :cookie_name
21
+
22
+ def inputs_type_from(inputs_type)
23
+ new_declaration = TypeDeclarations::Attributes.reject(inputs_type.declaration_data, attribute_name)
24
+ Domain.current.foobara_type_from_declaration(new_declaration)
25
+ end
26
+
27
+ def mutate(request)
28
+ cookie_value = request.cookies[cookie_name]
29
+ request.inputs[attribute_name] = cookie_value
30
+ end
31
+
32
+ def attribute_name
33
+ @attribute_name ||= self.class.attribute_name
34
+ end
35
+
36
+ def cookie_name
37
+ @cookie_name ||= self.class.cookie_name
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -19,15 +19,16 @@ module Foobara
19
19
  attr_writer :attribute_name, :cookie_name, :cookie_opts
20
20
 
21
21
  def result_type_from(result_type)
22
- AttributesTransformers.reject(result_type.declaration_data)
23
22
  new_declaration = TypeDeclarations::Attributes.reject(result_type.declaration_data, attribute_name)
24
23
 
25
24
  Domain.current.foobara_type_from_declaration(new_declaration)
26
25
  end
27
26
 
28
27
  def mutate(response)
29
- cookie_value = response.body.delete(attribute_name)
30
- response.add_cookie(cookie_name, cookie_value, cookie_opts)
28
+ if response.command.success?
29
+ cookie_value = response.body.delete(attribute_name)
30
+ response.add_cookie(cookie_name, cookie_value, cookie_opts)
31
+ end
31
32
  end
32
33
 
33
34
  def attribute_name
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-http-command-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-28 00:00:00.000000000 Z
10
+ date: 2025-03-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
@@ -65,6 +65,7 @@ files:
65
65
  - src/http/commands/help/templates/type.html.erb
66
66
  - src/http/cookie.rb
67
67
  - src/http/request.rb
68
+ - src/http/request_mutators/set_input_from_cookie.rb
68
69
  - src/http/response.rb
69
70
  - src/http/response_mutators/move_attribute_to_cookie.rb
70
71
  homepage: https://github.com/foobara/http-command-connector