foobara-http-command-connector 1.1.0 → 1.1.2

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: 36ab57af0c0d65f450500790ed68ba268c1bd5862fbaec71cfb83f4a00fc514a
4
- data.tar.gz: 93cbb5d98e08155a605be8481a3dd9a092d051e4b7d642b0df13af65d9c5f489
3
+ metadata.gz: cd81c1b2d8756cb8c7327baec7f613f34ce83e32147116a26d738591483a56c0
4
+ data.tar.gz: 1ad4abff7f7e616f7bedb3b7aa75db79e8a015c665c4187c5f484a45ee7484aa
5
5
  SHA512:
6
- metadata.gz: '09d292eba68a1d214d65035c8df665b69aadfdfaf9aeb4964d9d9941e4b3aedc35bacf8a86b28ee5691b9578a853e65b7ee32fcfd1937a37063d976c3b87e541'
7
- data.tar.gz: 8ad52d666aefd12f21bc71f52f7a1639c4d7c63700e18f8c1a9f015f93d42bf1ebf73948f603d90f10afdca204e7f686a92bf99afb19a9368ddde5bec7b06e97
6
+ metadata.gz: 7b057ea5d61ff69bbf4518b74b5a7c44417eaf73a8864b05be914ea09a3daf560bf0f193aaec870b6beef8ea78dd043c4f8728ef5af7c09d2743220804d7b2dd
7
+ data.tar.gz: ea3b0c2694e1893d5b92dc288289f92d66e74f26d1d6c90901218edc9e9c41a9dd3e512ed1433dd6054ac4c9d2bebe6be18da7864cc082eb885ce02adc97cd07
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [1.1.2] - 2025-12-18
2
+
3
+ - Fix bug causing commands to cram together on help page
4
+ - Refactor help rendering
5
+ - Make strings frozen-string compatible
6
+
7
+ ## [1.1.1] - 2025-08-25
8
+
9
+ - Add support for including processors
10
+ - Make detached false by default instead of true
11
+
1
12
  ## [1.1.0] - 2025-08-22
2
13
 
3
14
  - Handle new Foobara 0.1.0 type declarations
@@ -6,30 +6,19 @@ module Foobara
6
6
  inputs do
7
7
  manifestable :duck
8
8
  request :duck
9
- detached :boolean, default: true
9
+ detached :boolean, default: false
10
+ include_processors :boolean, default: false
10
11
  end
11
12
 
12
13
  def stamp_request_metadata
13
14
  manifest[:metadata] = super.merge(url: request.url)
14
15
  end
15
16
 
16
- def in_detached_context(&)
17
- TypeDeclarations.with_manifest_context(detached: true, &)
18
- end
19
-
20
17
  def build_manifest
21
- if detached_context?
22
- in_detached_context do
23
- super
24
- end
25
- else
18
+ TypeDeclarations.with_manifest_context(detached:, include_processors:) do
26
19
  super
27
20
  end
28
21
  end
29
-
30
- def detached_context?
31
- detached
32
- end
33
22
  end
34
23
  end
35
24
  end
@@ -70,28 +70,28 @@ module Foobara
70
70
  self.manifest = manifest
71
71
  end
72
72
 
73
- def render_html_list(data, skip_wrapper: false)
74
- html = ""
73
+ def render_html_list(data)
74
+ html = +""
75
+
76
+ is_rendered_as_a_collection = rendered_as_collection?(data)
77
+
78
+ html << "<ul>" if is_rendered_as_a_collection
75
79
 
76
80
  case data
77
81
  when ::Hash
78
- html << "<ul>" unless skip_wrapper
79
82
  data.each do |key, value|
80
- html << "<li>#{key}"
81
- html << "<ul>"
82
- html << render_html_list(value, skip_wrapper: true)
83
- html << "</ul>"
84
- html << "</li>"
83
+ html << render_list_child(value, key)
85
84
  end
86
- html << "</ul>" unless skip_wrapper
87
85
  when ::Array
88
- html << "<ul>" unless skip_wrapper
89
- data.each do |item|
90
- html << render_html_list(item)
86
+ if is_rendered_as_a_collection
87
+ data.each do |item|
88
+ html << render_list_child(item)
89
+ end
90
+ else
91
+ data = data.map { |item| render_html_list(item) }
92
+ html << "[#{data.join(", ")}]"
91
93
  end
92
- html << "</ul>" unless skip_wrapper
93
94
  when Manifest::Attributes
94
- html << "<ul>" unless skip_wrapper
95
95
  data.relevant_manifest.each_pair do |key, value|
96
96
  if key.to_s == "type"
97
97
  next
@@ -101,59 +101,77 @@ module Foobara
101
101
  key = :attributes
102
102
  value = data.attribute_declarations
103
103
  end
104
- html << "<li>#{key}"
105
- html << "<ul>"
106
- html << render_html_list(value, skip_wrapper: true)
107
- html << "</ul>"
108
- html << "</li>"
104
+
105
+ html << render_list_child(value, key)
109
106
  end
110
- html << "</ul>" unless skip_wrapper
111
107
  when Manifest::Array
112
- html << "<ul>" unless skip_wrapper
113
108
  data.relevant_manifest.each_pair do |key, value|
114
109
  next if key == :element_type_declaration
115
110
 
116
111
  if key.to_s == "type"
117
112
  value = root_manifest.lookup_path(key, value)
118
113
  end
119
- html << "<li>#{key}"
120
- html << "<ul>"
121
- html << render_html_list(value, skip_wrapper: true)
122
- html << "</ul>"
123
- html << "</li>"
114
+ html << render_list_child(value, key)
124
115
  end
125
- html << render_html_list({ element_type: data.element_type }, skip_wrapper: true)
126
- html << "</ul>" unless skip_wrapper
116
+
117
+ html << render_html_list({ element_type: data.element_type })
127
118
  when Manifest::TypeDeclaration
128
119
  manifest = data.relevant_manifest
129
120
 
130
121
  if manifest.is_a?(::Symbol)
131
122
  html << foobara_reference_link(data.to_type)
132
123
  else
133
- html << "<ul>" unless skip_wrapper
134
124
  data.relevant_manifest.each_pair do |key, value|
135
125
  if key.to_s == "type"
136
126
  value = root_manifest.lookup_path(key, value)
137
127
  end
138
- html << "<li>#{key}"
139
- html << "<ul>"
140
- html << render_html_list(value, skip_wrapper: true)
141
- html << "</ul>"
142
- html << "</li>"
128
+
129
+ html << render_list_child(value, key)
143
130
  end
144
- html << "</ul>" unless skip_wrapper
145
131
  end
146
132
  when Manifest::Type, Manifest::Command, Manifest::Error
147
133
  html << foobara_reference_link(data)
148
134
  when Manifest::PossibleError
149
135
  html << render_html_list(data.error)
150
136
  else
151
- html << "<li>#{data}</li>"
137
+ html << case data
138
+ when Numeric, TrueClass, FalseClass, NilClass
139
+ data.inspect
140
+ when ::String
141
+ data
142
+ when ::Symbol, ::Time
143
+ data.to_s
144
+ else
145
+ # :nocov:
146
+ raise "Not sure how to render #{data.class}"
147
+ # :nocov:
148
+ end
152
149
  end
153
150
 
151
+ html << "</ul>" if is_rendered_as_a_collection
152
+
154
153
  html
155
154
  end
156
155
 
156
+ def rendered_as_collection?(data)
157
+ if data.is_a?(::Array)
158
+ data.size > 5 || data.any? { |element| rendered_as_collection?(element) }
159
+ elsif data.is_a?(Manifest::TypeDeclaration)
160
+ !data.relevant_manifest.is_a?(::Symbol)
161
+ else
162
+ [
163
+ ::Hash,
164
+ Manifest::Attributes,
165
+ Manifest::Array
166
+ ].any? { |klass| data.is_a?(klass) }
167
+ end
168
+ end
169
+
170
+ def render_list_child(child, label = nil)
171
+ label = "#{label}:" if label
172
+ "<li>#{label}\n#{render_html_list(child)}\n</li>"
173
+ end
174
+
157
175
  def foobara_reference_link(manifest)
158
176
  path = "/help/#{manifest.reference}"
159
177
 
@@ -19,7 +19,9 @@ module Foobara
19
19
  attr_accessor :raw_manifest, :root_manifest, :object_to_help_with, :manifest_to_help_with
20
20
 
21
21
  def load_manifest
22
- self.raw_manifest = command_connector.foobara_manifest
22
+ self.raw_manifest = TypeDeclarations.with_manifest_context(include_processors: true) do
23
+ command_connector.foobara_manifest
24
+ end
23
25
  self.root_manifest = Manifest::RootManifest.new(raw_manifest)
24
26
  end
25
27
 
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.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi