foobara-http-command-connector 0.0.25 → 1.1.0
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/CHANGELOG.md +8 -0
- data/src/http/commands/help/presenter.rb +16 -10
- data/src/http/commands/help.rb +6 -14
- data/src/http/cookie.rb +1 -1
- data/src/http/request.rb +0 -8
- data/src/http/request_mutators/set_input_to_proc_result.rb +4 -0
- data/src/http.rb +23 -15
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36ab57af0c0d65f450500790ed68ba268c1bd5862fbaec71cfb83f4a00fc514a
|
4
|
+
data.tar.gz: 93cbb5d98e08155a605be8481a3dd9a092d051e4b7d642b0df13af65d9c5f489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09d292eba68a1d214d65035c8df665b69aadfdfaf9aeb4964d9d9941e4b3aedc35bacf8a86b28ee5691b9578a853e65b7ee32fcfd1937a37063d976c3b87e541'
|
7
|
+
data.tar.gz: 8ad52d666aefd12f21bc71f52f7a1639c4d7c63700e18f8c1a9f015f93d42bf1ebf73948f603d90f10afdca204e7f686a92bf99afb19a9368ddde5bec7b06e97
|
data/CHANGELOG.md
CHANGED
@@ -125,18 +125,24 @@ module Foobara
|
|
125
125
|
html << render_html_list({ element_type: data.element_type }, skip_wrapper: true)
|
126
126
|
html << "</ul>" unless skip_wrapper
|
127
127
|
when Manifest::TypeDeclaration
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
manifest = data.relevant_manifest
|
129
|
+
|
130
|
+
if manifest.is_a?(::Symbol)
|
131
|
+
html << foobara_reference_link(data.to_type)
|
132
|
+
else
|
133
|
+
html << "<ul>" unless skip_wrapper
|
134
|
+
data.relevant_manifest.each_pair do |key, value|
|
135
|
+
if key.to_s == "type"
|
136
|
+
value = root_manifest.lookup_path(key, value)
|
137
|
+
end
|
138
|
+
html << "<li>#{key}"
|
139
|
+
html << "<ul>"
|
140
|
+
html << render_html_list(value, skip_wrapper: true)
|
141
|
+
html << "</ul>"
|
142
|
+
html << "</li>"
|
132
143
|
end
|
133
|
-
html << "
|
134
|
-
html << "<ul>"
|
135
|
-
html << render_html_list(value, skip_wrapper: true)
|
136
|
-
html << "</ul>"
|
137
|
-
html << "</li>"
|
144
|
+
html << "</ul>" unless skip_wrapper
|
138
145
|
end
|
139
|
-
html << "</ul>" unless skip_wrapper
|
140
146
|
when Manifest::Type, Manifest::Command, Manifest::Error
|
141
147
|
html << foobara_reference_link(data)
|
142
148
|
when Manifest::PossibleError
|
data/src/http/commands/help.rb
CHANGED
@@ -31,21 +31,13 @@ module Foobara
|
|
31
31
|
|
32
32
|
if result
|
33
33
|
self.object_to_help_with = result
|
34
|
+
elsif mode == Namespace::LookupMode::ABSOLUTE
|
35
|
+
determine_object_to_help_with(mode: Namespace::LookupMode::GENERAL)
|
36
|
+
elsif mode == Namespace::LookupMode::GENERAL
|
37
|
+
determine_object_to_help_with(mode: Namespace::LookupMode::RELAXED)
|
34
38
|
else
|
35
|
-
# TODO:
|
36
|
-
|
37
|
-
|
38
|
-
if result && root_manifest.contains?(result.foobara_manifest_reference,
|
39
|
-
result.scoped_category)
|
40
|
-
self.object_to_help_with = result
|
41
|
-
elsif mode == Namespace::LookupMode::ABSOLUTE
|
42
|
-
determine_object_to_help_with(mode: Namespace::LookupMode::GENERAL)
|
43
|
-
elsif mode == Namespace::LookupMode::GENERAL
|
44
|
-
determine_object_to_help_with(mode: Namespace::LookupMode::RELAXED)
|
45
|
-
else
|
46
|
-
# TODO: add an input error instead for missing record to trigger 404
|
47
|
-
add_runtime_error(CommandConnector::NotFoundError.for(arg))
|
48
|
-
end
|
39
|
+
# TODO: add an input error instead for missing record to trigger 404
|
40
|
+
add_runtime_error(CommandConnector::NotFoundError.for(arg))
|
49
41
|
end
|
50
42
|
else
|
51
43
|
self.object_to_help_with = root_manifest
|
data/src/http/cookie.rb
CHANGED
@@ -4,7 +4,7 @@ module Foobara
|
|
4
4
|
class Cookie
|
5
5
|
attr_accessor :name, :value, :opts
|
6
6
|
|
7
|
-
ALLOWED_OPTIONS =
|
7
|
+
ALLOWED_OPTIONS = [:path, :httponly, :secure, :same_site, :domain, :expires, :max_age].freeze
|
8
8
|
|
9
9
|
def initialize(name, value, **opts)
|
10
10
|
invalid_options = opts.keys - ALLOWED_OPTIONS
|
data/src/http/request.rb
CHANGED
@@ -113,14 +113,6 @@ module Foobara
|
|
113
113
|
path
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
117
|
-
def set_response_header(name, value)
|
118
|
-
name = name.to_s
|
119
|
-
name = name.downcase
|
120
|
-
|
121
|
-
self.response_headers ||= {}
|
122
|
-
self.response_headers = response_headers.merge(name => value)
|
123
|
-
end
|
124
116
|
end
|
125
117
|
end
|
126
118
|
end
|
data/src/http.rb
CHANGED
@@ -58,24 +58,28 @@ module Foobara
|
|
58
58
|
super(*, prefix:, **)
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def request_to_command_class(request)
|
62
62
|
if request.method == "OPTIONS"
|
63
|
-
|
63
|
+
Foobara::CommandConnectors::Http::Commands::GetOptions
|
64
|
+
else
|
65
|
+
super.tap do |command_class|
|
66
|
+
if request.action == "help"
|
67
|
+
command_class.serializers = [Commands::Help::ResultSerializer]
|
68
|
+
end
|
69
|
+
end
|
64
70
|
end
|
71
|
+
end
|
65
72
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
73
|
+
def request_to_command_inputs(request)
|
74
|
+
if request.method == "OPTIONS"
|
75
|
+
{ request: }
|
76
|
+
else
|
77
|
+
super
|
71
78
|
end
|
72
|
-
|
73
|
-
command
|
74
79
|
end
|
75
80
|
|
76
81
|
def set_response_status(response)
|
77
|
-
|
78
|
-
outcome = command.outcome
|
82
|
+
outcome = response.outcome
|
79
83
|
|
80
84
|
response.status = if outcome.success?
|
81
85
|
200
|
@@ -124,6 +128,10 @@ module Foobara
|
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
131
|
+
if request.action == "help"
|
132
|
+
response_headers = (response_headers || {}).merge("content-type" => "text/html")
|
133
|
+
end
|
134
|
+
|
127
135
|
if response_headers
|
128
136
|
static_headers.merge(response_headers)
|
129
137
|
else
|
@@ -135,10 +143,10 @@ module Foobara
|
|
135
143
|
|
136
144
|
def static_headers
|
137
145
|
@static_headers ||= ENV.each_with_object({}) do |(key, value), headers|
|
138
|
-
next if
|
139
|
-
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
|
140
|
-
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS
|
141
|
-
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE
|
146
|
+
next if [
|
147
|
+
"FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS",
|
148
|
+
"FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS",
|
149
|
+
"FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE"
|
142
150
|
].include?(key)
|
143
151
|
|
144
152
|
match = key.match(/\AFOOBARA_HTTP_RESPONSE_HEADER_(.*)\z/)
|
metadata
CHANGED
@@ -1,28 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-http-command-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
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: foobara
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.
|
18
|
+
version: 0.1.1
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
19
22
|
type: :runtime
|
20
23
|
prerelease: false
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
22
25
|
requirements:
|
23
|
-
- - "
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 0.1.1
|
29
|
+
- - "<"
|
24
30
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0
|
31
|
+
version: 2.0.0
|
26
32
|
email:
|
27
33
|
- azimux@gmail.com
|
28
34
|
executables: []
|
@@ -95,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '0'
|
97
103
|
requirements: []
|
98
|
-
rubygems_version: 3.6.
|
104
|
+
rubygems_version: 3.6.9
|
99
105
|
specification_version: 4
|
100
106
|
summary: No description. Add one.
|
101
107
|
test_files: []
|