Class: Foobara::CommandConnectors::Http::Commands::Help::Presenter
- Inherits:
-
Object
- Object
- Foobara::CommandConnectors::Http::Commands::Help::Presenter
show all
- Defined in:
- foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/root.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/type.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/error.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/model.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/domain.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/entity.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/command.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/organization.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/request_failed.rb,
foobara-http-command-connector-0.0.23/src/http/commands/help/presenter/processor_class.rb
Direct Known Subclasses
Command, Domain, Entity, Error, Model, Organization, Processor, ProcessorClass, RequestFailed, Root, Type
Defined Under Namespace
Classes: Command, Domain, Entity, Error, Model, Organization, Processor, ProcessorClass, RequestFailed, Root, Type
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(manifest) ⇒ Presenter
Returns a new instance of Presenter.
69
70
71
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 69
def initialize(manifest)
self.manifest = manifest
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
165
166
167
168
169
170
171
172
173
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 165
def method_missing(method_name, *, &)
if manifest.respond_to?(method_name)
manifest.send(method_name, *, &)
else
super
end
end
|
Instance Attribute Details
#manifest ⇒ Object
Returns the value of attribute manifest.
67
68
69
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 67
def manifest
@manifest
end
|
Class Method Details
.template_path ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 57
def template_path
template_path = File.join(
__dir__,
"templates",
"#{template_symbol}.html.erb"
)
Pathname.new(template_path).cleanpath.to_s
end
|
.template_symbol ⇒ Object
53
54
55
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 53
def template_symbol
Util.underscore(Util.non_full_name(self))
end
|
Instance Method Details
#foobara_reference_link(manifest) ⇒ Object
151
152
153
154
155
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 151
def foobara_reference_link(manifest)
path = "/help/#{manifest.reference}"
"<a href=\"#{path}\">#{manifest.reference.split("::").last}</a>"
end
|
#render_html_list(data, skip_wrapper: false) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 73
def render_html_list(data, skip_wrapper: false)
html = ""
case data
when ::Hash
html << "<ul>" unless skip_wrapper
data.each do |key, value|
html << "<li>#{key}"
html << "<ul>"
html << render_html_list(value, skip_wrapper: true)
html << "</ul>"
html << "</li>"
end
html << "</ul>" unless skip_wrapper
when ::Array
html << "<ul>" unless skip_wrapper
data.each do |item|
html << render_html_list(item)
end
html << "</ul>" unless skip_wrapper
when Manifest::Attributes
html << "<ul>" unless skip_wrapper
data.relevant_manifest.each_pair do |key, value|
if key.to_s == "type"
next
end
if key.to_s == "element_type_declarations"
key = :attributes
value = data.attribute_declarations
end
html << "<li>#{key}"
html << "<ul>"
html << render_html_list(value, skip_wrapper: true)
html << "</ul>"
html << "</li>"
end
html << "</ul>" unless skip_wrapper
when Manifest::Array
html << "<ul>" unless skip_wrapper
data.relevant_manifest.each_pair do |key, value|
next if key == :element_type_declaration
if key.to_s == "type"
value = root_manifest.lookup_path(key, value)
end
html << "<li>#{key}"
html << "<ul>"
html << render_html_list(value, skip_wrapper: true)
html << "</ul>"
html << "</li>"
end
html << render_html_list({ element_type: data.element_type }, skip_wrapper: true)
html << "</ul>" unless skip_wrapper
when Manifest::TypeDeclaration
html << "<ul>" unless skip_wrapper
data.relevant_manifest.each_pair do |key, value|
if key.to_s == "type"
value = root_manifest.lookup_path(key, value)
end
html << "<li>#{key}"
html << "<ul>"
html << render_html_list(value, skip_wrapper: true)
html << "</ul>"
html << "</li>"
end
html << "</ul>" unless skip_wrapper
when Manifest::Type, Manifest::Command, Manifest::Error
html << foobara_reference_link(data)
when Manifest::PossibleError
html << render_html_list(data.error)
else
html << "<li>#{data}</li>"
end
html
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
175
176
177
178
179
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 175
def respond_to_missing?(method_name, include_private = false)
manifest.respond_to?(method_name, include_private)
end
|
#root_manifest ⇒ Object
157
158
159
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 157
def root_manifest
@root_manifest ||= Manifest::RootManifest.new(manifest.root_manifest)
end
|
#template_path ⇒ Object
161
162
163
|
# File 'foobara-http-command-connector-0.0.23/src/http/commands/help/presenter.rb', line 161
def template_path
self.class.template_path
end
|