gloo 4.7.0 → 5.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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/gloo.gemspec +22 -11
  4. data/lib/VERSION +1 -1
  5. data/lib/VERSION_NOTES +7 -0
  6. data/lib/gloo/app/engine.rb +3 -2
  7. data/lib/gloo/app/running_app.rb +13 -0
  8. data/lib/gloo/core/dictionary.rb +13 -2
  9. data/lib/gloo/objs/ctrl/each.rb +2 -2
  10. data/lib/gloo/{ext → plugin}/base.rb +1 -1
  11. data/lib/gloo/{ext → plugin}/callback.rb +2 -3
  12. data/lib/gloo/{ext/manager.rb → plugin/ext_manager.rb} +2 -2
  13. data/lib/gloo/plugin/lib_manager.rb +97 -0
  14. data/lib/gloo/verbs/exists.rb +75 -0
  15. data/lib/gloo/verbs/help.rb +28 -0
  16. data/lib/gloo/verbs/load.rb +8 -2
  17. data/lib/gloo/verbs/redirect.rb +2 -1
  18. metadata +38 -164
  19. data/lib/gloo/objs/cli/colorize.rb +0 -73
  20. data/lib/gloo/objs/cli/confirm.rb +0 -96
  21. data/lib/gloo/objs/cli/menu.rb +0 -370
  22. data/lib/gloo/objs/cli/menu_item.rb +0 -95
  23. data/lib/gloo/objs/cli/prompt.rb +0 -110
  24. data/lib/gloo/objs/cli/select.rb +0 -127
  25. data/lib/gloo/objs/ctrl/each_repo.rb +0 -84
  26. data/lib/gloo/objs/data/markdown.rb +0 -133
  27. data/lib/gloo/objs/data/markdown_ext.rb +0 -260
  28. data/lib/gloo/objs/data/mysql.rb +0 -254
  29. data/lib/gloo/objs/data/query.rb +0 -269
  30. data/lib/gloo/objs/data/query_result.rb +0 -158
  31. data/lib/gloo/objs/data/sqlite.rb +0 -174
  32. data/lib/gloo/objs/data/table.rb +0 -267
  33. data/lib/gloo/objs/dev/git.rb +0 -140
  34. data/lib/gloo/objs/dev/stats.rb +0 -123
  35. data/lib/gloo/objs/system/ssh_exec.rb +0 -126
  36. data/lib/gloo/objs/web_svr/element.rb +0 -254
  37. data/lib/gloo/objs/web_svr/field.rb +0 -429
  38. data/lib/gloo/objs/web_svr/form.rb +0 -271
  39. data/lib/gloo/objs/web_svr/page.rb +0 -562
  40. data/lib/gloo/objs/web_svr/partial.rb +0 -210
  41. data/lib/gloo/objs/web_svr/svr.rb +0 -713
  42. data/lib/gloo/utils/stats.rb +0 -206
  43. data/lib/gloo/web_svr/asset.rb +0 -407
  44. data/lib/gloo/web_svr/asset_info.rb +0 -116
  45. data/lib/gloo/web_svr/config.rb +0 -56
  46. data/lib/gloo/web_svr/embedded_renderer.rb +0 -154
  47. data/lib/gloo/web_svr/handler.rb +0 -154
  48. data/lib/gloo/web_svr/request.rb +0 -143
  49. data/lib/gloo/web_svr/request_params.rb +0 -181
  50. data/lib/gloo/web_svr/response.rb +0 -177
  51. data/lib/gloo/web_svr/response_code.rb +0 -69
  52. data/lib/gloo/web_svr/routing/resource_router.rb +0 -47
  53. data/lib/gloo/web_svr/routing/router.rb +0 -232
  54. data/lib/gloo/web_svr/routing/show_routes.rb +0 -94
  55. data/lib/gloo/web_svr/server.rb +0 -105
  56. data/lib/gloo/web_svr/session.rb +0 -215
  57. data/lib/gloo/web_svr/table_renderer.rb +0 -151
  58. data/lib/gloo/web_svr/web_method.rb +0 -54
  59. /data/lib/gloo/objs/{security → str_utils}/cipher.rb +0 -0
  60. /data/lib/gloo/objs/{security → str_utils}/csrf_token.rb +0 -0
  61. /data/lib/gloo/objs/{security → str_utils}/password.rb +0 -0
  62. /data/lib/gloo/objs/{ror → system}/erb.rb +0 -0
  63. /data/lib/gloo/objs/{ror → system}/eval.rb +0 -0
@@ -1,126 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # An object that can post JSON to a URI.
5
- #
6
- require 'net/ssh'
7
-
8
- module Gloo
9
- module Objs
10
- class SshExec < Gloo::Core::Obj
11
-
12
- KEYWORD = 'ssh_exec'.freeze
13
- KEYWORD_SHORT = 'ssh'.freeze
14
- HOST = 'host'.freeze
15
- DEFAULT_HOST = 'localhost'.freeze
16
- CMD = 'cmd'.freeze
17
- RESULT = 'result'.freeze
18
- HOST_REQUIRED_ERR = 'The host is required!'.freeze
19
-
20
- #
21
- # The name of the object type.
22
- #
23
- def self.typename
24
- return KEYWORD
25
- end
26
-
27
- #
28
- # The short name of the object type.
29
- #
30
- def self.short_typename
31
- return KEYWORD_SHORT
32
- end
33
-
34
- # ---------------------------------------------------------------------
35
- # Children
36
- # ---------------------------------------------------------------------
37
-
38
- #
39
- # Does this object have children to add when an object
40
- # is created in interactive mode?
41
- # This does not apply during obj load, etc.
42
- #
43
- def add_children_on_create?
44
- return true
45
- end
46
-
47
- #
48
- # Add children to this object.
49
- # This is used by containers to add children needed
50
- # for default configurations.
51
- #
52
- def add_default_children
53
- fac = @engine.factory
54
- fac.create_string HOST, DEFAULT_HOST, self
55
- fac.create_string CMD, nil, self
56
- fac.create_string RESULT, nil, self
57
- end
58
-
59
- # ---------------------------------------------------------------------
60
- # Messages
61
- # ---------------------------------------------------------------------
62
-
63
- #
64
- # Get a list of message names that this object receives.
65
- #
66
- def self.messages
67
- return super + [ 'run' ]
68
- end
69
-
70
- #
71
- # SSH to the host and execute the command, then update result.
72
- #
73
- def msg_run
74
- h = host_value
75
- unless h
76
- @engine.err HOST_REQUIRED_ERR
77
- return
78
- end
79
-
80
- Net::SSH.start( h ) do |ssh|
81
- result = ssh.exec!( cmd_value )
82
- update_result result
83
- end
84
- end
85
-
86
- # ---------------------------------------------------------------------
87
- # Private functions
88
- # ---------------------------------------------------------------------
89
-
90
- private
91
-
92
- #
93
- # Get the host from the child object.
94
- # Returns nil if there is none.
95
- #
96
- def host_value
97
- o = find_child HOST
98
- return nil unless o
99
-
100
- return o.value
101
- end
102
-
103
- #
104
- # Get the command from the child object.
105
- # Returns nil if there is none.
106
- #
107
- def cmd_value
108
- o = find_child CMD
109
- return nil unless o
110
-
111
- return o.value
112
- end
113
-
114
- #
115
- # Set the result of the API call.
116
- #
117
- def update_result( data )
118
- r = find_child RESULT
119
- return nil unless r
120
-
121
- r.set_value data
122
- end
123
-
124
- end
125
- end
126
- end
@@ -1,254 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
- #
4
- # An HTML Element.
5
- # Note that the object name is the tag!
6
- #
7
- # An Element's content can be in a container of that nane,
8
- # or it can be the simple value of the obj. If there is no
9
- # content child, the simple value will be used.
10
- #
11
- # Attibutes is a container with all attributes of the tag.
12
- # ID and CLASSES attributes can be called out more simply
13
- # as children of the element obj.
14
- #
15
-
16
- module Gloo
17
- module Objs
18
- class Element < Gloo::Core::Obj
19
-
20
- KEYWORD = 'element'.freeze
21
- KEYWORD_SHORT = 'e'.freeze
22
-
23
- # Element
24
- ID = 'id'.freeze
25
- CLASSES = 'classes'.freeze
26
- ATTRIBUTES = 'attributes'.freeze
27
- CONTENT = 'content'.freeze
28
-
29
-
30
- #
31
- # The name of the object type.
32
- #
33
- def self.typename
34
- return KEYWORD
35
- end
36
-
37
- #
38
- # The short name of the object type.
39
- #
40
- def self.short_typename
41
- return KEYWORD_SHORT
42
- end
43
-
44
- #
45
- # Set the value with any necessary type conversions.
46
- #
47
- def set_value( new_value )
48
- self.value = new_value.to_s
49
- end
50
-
51
- #
52
- # Does this object support multi-line values?
53
- # Initially only true for scripts.
54
- #
55
- def multiline_value?
56
- return false
57
- end
58
-
59
- #
60
- # Return the array of attributes if there are any.
61
- #
62
- def attributes_hash
63
- attr_can = find_child ATTRIBUTES
64
-
65
- if attr_can && attr_can.children.size > 0
66
- h = {}
67
- attr_can.children.each do |o|
68
- h[ o.name ] = o.value
69
- end
70
- return h
71
- end
72
-
73
- return {}
74
- end
75
-
76
- #
77
- # Get all attributes of the tag.
78
- #
79
- def tag_attributes
80
- attr_h = attributes_hash
81
- return nil unless attr_h && attr_h.size > 0
82
-
83
- attr_str = ''
84
- attr_h.each do |k,v|
85
- unless v.blank?
86
- attr_str << " #{k}=\"#{v}\""
87
- end
88
- end
89
-
90
- return attr_str
91
- end
92
-
93
- #
94
- # Get the tag.
95
- # This is the name, up until an '_' char.
96
- # Because name must be unique in the parent, and with HTML
97
- # we need a way to have multiple of the same tag at the
98
- # same level.
99
- #
100
- def tag
101
- i = self.name.index( '_' )
102
- return i ? self.name[ 0..(i-1) ] : self.name
103
- end
104
-
105
- #
106
- # Get the opening tag.
107
- #
108
- def tag_open
109
- tag_attributes = self.tag_attributes
110
- if tag_attributes
111
- return "<#{tag}#{tag_attributes}>"
112
- else
113
- return "<#{tag}>"
114
- end
115
- end
116
-
117
- #
118
- # Get the closing tag.
119
- #
120
- def tag_close
121
- return "</#{tag}>"
122
- end
123
-
124
- #
125
- # Get all the children elements of the content.
126
- #
127
- def content_child
128
- return find_child CONTENT
129
- end
130
-
131
- # ---------------------------------------------------------------------
132
- # Children
133
- # ---------------------------------------------------------------------
134
-
135
- #
136
- # Does this object have children to add when an object
137
- # is created in interactive mode?
138
- # This does not apply during obj load, etc.
139
- #
140
- def add_children_on_create?
141
- return true
142
- end
143
-
144
- #
145
- # Add children to this object.
146
- # This is used by containers to add children needed
147
- # for default configurations.
148
- #
149
- def add_default_children
150
- fac = @engine.factory
151
-
152
- # Create attributes with ID and Classes
153
- attr = fac.create_can ATTRIBUTES, self
154
- fac.create_string ID, '', attr
155
- fac.create_string CLASSES, '', attr
156
-
157
- fac.create_can CONTENT, self
158
- end
159
-
160
-
161
- # ---------------------------------------------------------------------
162
- # Messages
163
- # ---------------------------------------------------------------------
164
-
165
- #
166
- # Get a list of message names that this object receives.
167
- #
168
- def self.messages
169
- return super + [ 'render' ]
170
- end
171
-
172
- #
173
- # Get the expiration date for the certificate.
174
- #
175
- def msg_render
176
- content = self.render_html
177
- @engine.heap.it.set_to content
178
- return content
179
- end
180
-
181
-
182
- # ---------------------------------------------------------------------
183
- # Render
184
- # ---------------------------------------------------------------------
185
-
186
- #
187
- # Render the element as HTML.
188
- #
189
- def render_html
190
- content_text = render_content :render_html
191
-
192
- return "#{tag_open}#{content_text}#{tag_close}"
193
- end
194
-
195
- #
196
- # Render the element as text, without tags.
197
- #
198
- def render_text
199
- content_text = render_content :render_text
200
-
201
- return "#{content_text}"
202
- end
203
-
204
- #
205
- # Render the element content using the specified render function.
206
- # This is a recursive function (through one of the other render functions).
207
- #
208
- def render_content render_ƒ
209
- obj = content_child
210
- obj = self if obj.nil?
211
-
212
- return Element.render_obj( obj, render_ƒ, @engine )
213
- end
214
-
215
- #
216
- # Render an object which might be an element,
217
- # a container of items, or something else.
218
- #
219
- def self.render_obj obj, render_ƒ, engine
220
- rendered_obj_content = ''
221
- return nil unless obj
222
-
223
- if obj.children.size > 0
224
- obj.children.each do |e|
225
-
226
- e = Gloo::Objs::Alias.resolve_alias( engine, e )
227
- if e.class == Element
228
- rendered_obj_content << e.send( render_ƒ )
229
- elsif e.class == Form
230
- rendered_obj_content << e.render
231
- elsif e
232
- data = render_thing e, render_ƒ, engine
233
- ( rendered_obj_content << data ) if data # e.render( render_ƒ )
234
- end
235
- end
236
- else
237
- rendered_obj_content << obj.value
238
- end
239
-
240
- return rendered_obj_content
241
- end
242
-
243
- def self.render_thing e, render_ƒ, engine
244
- begin
245
- return e.render( render_ƒ )
246
- rescue => e
247
- engine.log_exception e
248
- return ''
249
- end
250
- end
251
-
252
- end
253
- end
254
- end