foobara-http-command-connector 1.1.1 → 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 +4 -4
- data/CHANGELOG.md +6 -0
- data/src/http/commands/help/presenter.rb +54 -36
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd81c1b2d8756cb8c7327baec7f613f34ce83e32147116a26d738591483a56c0
|
|
4
|
+
data.tar.gz: 1ad4abff7f7e616f7bedb3b7aa75db79e8a015c665c4187c5f484a45ee7484aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b057ea5d61ff69bbf4518b74b5a7c44417eaf73a8864b05be914ea09a3daf560bf0f193aaec870b6beef8ea78dd043c4f8728ef5af7c09d2743220804d7b2dd
|
|
7
|
+
data.tar.gz: ea3b0c2694e1893d5b92dc288289f92d66e74f26d1d6c90901218edc9e9c41a9dd3e512ed1433dd6054ac4c9d2bebe6be18da7864cc082eb885ce02adc97cd07
|
data/CHANGELOG.md
CHANGED
|
@@ -70,28 +70,28 @@ module Foobara
|
|
|
70
70
|
self.manifest = manifest
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
def render_html_list(data
|
|
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 <<
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
105
|
-
html <<
|
|
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 <<
|
|
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
|
-
|
|
126
|
-
html <<
|
|
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
|
-
|
|
139
|
-
html <<
|
|
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 <<
|
|
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
|
|