gloo 4.6.1 → 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 (69) 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 +12 -0
  6. data/lib/gloo/app/engine.rb +8 -1
  7. data/lib/gloo/app/running_app.rb +13 -0
  8. data/lib/gloo/app/settings.rb +5 -1
  9. data/lib/gloo/core/dictionary.rb +15 -2
  10. data/lib/gloo/objs/ctrl/each.rb +2 -2
  11. data/lib/gloo/plugin/base.rb +19 -0
  12. data/lib/gloo/plugin/callback.rb +33 -0
  13. data/lib/gloo/plugin/ext_manager.rb +90 -0
  14. data/lib/gloo/plugin/lib_manager.rb +97 -0
  15. data/lib/gloo/verbs/exists.rb +75 -0
  16. data/lib/gloo/verbs/help.rb +58 -1
  17. data/lib/gloo/verbs/load.rb +49 -5
  18. data/lib/gloo/verbs/redirect.rb +2 -1
  19. metadata +38 -166
  20. data/lib/gloo/objs/cli/colorize.rb +0 -73
  21. data/lib/gloo/objs/cli/confirm.rb +0 -96
  22. data/lib/gloo/objs/cli/menu.rb +0 -370
  23. data/lib/gloo/objs/cli/menu_item.rb +0 -95
  24. data/lib/gloo/objs/cli/prompt.rb +0 -110
  25. data/lib/gloo/objs/cli/select.rb +0 -127
  26. data/lib/gloo/objs/ctrl/each_repo.rb +0 -84
  27. data/lib/gloo/objs/data/markdown.rb +0 -133
  28. data/lib/gloo/objs/data/markdown_ext.rb +0 -260
  29. data/lib/gloo/objs/data/mysql.rb +0 -254
  30. data/lib/gloo/objs/data/pg.rb +0 -216
  31. data/lib/gloo/objs/data/query.rb +0 -269
  32. data/lib/gloo/objs/data/query_result.rb +0 -158
  33. data/lib/gloo/objs/data/sqlite.rb +0 -174
  34. data/lib/gloo/objs/data/table.rb +0 -267
  35. data/lib/gloo/objs/dev/git.rb +0 -140
  36. data/lib/gloo/objs/dev/stats.rb +0 -123
  37. data/lib/gloo/objs/system/ssh_exec.rb +0 -126
  38. data/lib/gloo/objs/web/slack.rb +0 -130
  39. data/lib/gloo/objs/web/teams.rb +0 -117
  40. data/lib/gloo/objs/web_svr/element.rb +0 -254
  41. data/lib/gloo/objs/web_svr/field.rb +0 -429
  42. data/lib/gloo/objs/web_svr/form.rb +0 -271
  43. data/lib/gloo/objs/web_svr/page.rb +0 -562
  44. data/lib/gloo/objs/web_svr/partial.rb +0 -210
  45. data/lib/gloo/objs/web_svr/svr.rb +0 -713
  46. data/lib/gloo/utils/stats.rb +0 -206
  47. data/lib/gloo/verbs/alert.rb +0 -79
  48. data/lib/gloo/verbs/beep.rb +0 -40
  49. data/lib/gloo/web_svr/asset.rb +0 -407
  50. data/lib/gloo/web_svr/asset_info.rb +0 -116
  51. data/lib/gloo/web_svr/config.rb +0 -56
  52. data/lib/gloo/web_svr/embedded_renderer.rb +0 -154
  53. data/lib/gloo/web_svr/handler.rb +0 -154
  54. data/lib/gloo/web_svr/request.rb +0 -143
  55. data/lib/gloo/web_svr/request_params.rb +0 -181
  56. data/lib/gloo/web_svr/response.rb +0 -177
  57. data/lib/gloo/web_svr/response_code.rb +0 -69
  58. data/lib/gloo/web_svr/routing/resource_router.rb +0 -47
  59. data/lib/gloo/web_svr/routing/router.rb +0 -232
  60. data/lib/gloo/web_svr/routing/show_routes.rb +0 -94
  61. data/lib/gloo/web_svr/server.rb +0 -105
  62. data/lib/gloo/web_svr/session.rb +0 -215
  63. data/lib/gloo/web_svr/table_renderer.rb +0 -151
  64. data/lib/gloo/web_svr/web_method.rb +0 -54
  65. /data/lib/gloo/objs/{security → str_utils}/cipher.rb +0 -0
  66. /data/lib/gloo/objs/{security → str_utils}/csrf_token.rb +0 -0
  67. /data/lib/gloo/objs/{security → str_utils}/password.rb +0 -0
  68. /data/lib/gloo/objs/{ror → system}/erb.rb +0 -0
  69. /data/lib/gloo/objs/{ror → system}/eval.rb +0 -0
@@ -1,130 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An object that can send a message to a slack channel.
5
- #
6
- require 'net/http'
7
- require 'uri'
8
- require 'json'
9
-
10
- module Gloo
11
- module Objs
12
- class Slack < Gloo::Core::Obj
13
-
14
- KEYWORD = 'slack'.freeze
15
- KEYWORD_SHORT = 'slack'.freeze
16
- URL = 'uri'.freeze
17
- MSG = 'message'.freeze
18
- USER = 'username'.freeze
19
- CHANNEL = 'channel'.freeze
20
- ICON = 'icon_emoji'.freeze
21
-
22
- ATTACHMENT = 'attachment'.freeze
23
- TITLE = 'title'.freeze
24
- TEXT = 'text'.freeze
25
-
26
- #
27
- # The name of the object type.
28
- #
29
- def self.typename
30
- return KEYWORD
31
- end
32
-
33
- #
34
- # The short name of the object type.
35
- #
36
- def self.short_typename
37
- return KEYWORD_SHORT
38
- end
39
-
40
- #
41
- # Get the URI from the child object.
42
- # Returns nil if there is none.
43
- #
44
- def uri_value
45
- uri = find_child URL
46
- return nil unless uri
47
-
48
- return uri.value
49
- end
50
-
51
- #
52
- # Get the URI from the child object.
53
- # Returns nil if there is none.
54
- #
55
- def attachment_value
56
- o = find_child ATTACHMENT
57
- return nil unless o
58
-
59
- title = o.find_child TITLE
60
- text = o.find_child TEXT
61
- return [ { 'title' => title.value,
62
- 'text' => text.value } ]
63
- end
64
-
65
- #
66
- # Get all the children of the body container and
67
- # convert to JSON that will be sent in the HTTP body.
68
- #
69
- def body_as_json
70
- h = { 'text' => find_child( MSG ).value,
71
- 'username' => find_child( USER ).value,
72
- 'channel' => find_child( CHANNEL ).value,
73
- 'icon_emoji' => find_child( ICON ).value }
74
-
75
- o = attachment_value
76
- h[ 'attachments' ] = o if o
77
- return h.to_json
78
- end
79
-
80
- # ---------------------------------------------------------------------
81
- # Children
82
- # ---------------------------------------------------------------------
83
-
84
- #
85
- # Does this object have children to add when an object
86
- # is created in interactive mode?
87
- # This does not apply during obj load, etc.
88
- #
89
- def add_children_on_create?
90
- return true
91
- end
92
-
93
- #
94
- # Add children to this object.
95
- # This is used by containers to add children needed
96
- # for default configurations.
97
- #
98
- def add_default_children
99
- fac = @engine.factory
100
- fac.create_string URL, 'https://hooks.slack.com/services/...', self
101
- fac.create_string MSG, 'textual message', self
102
- fac.create_string USER, 'Slack Bot', self
103
- fac.create_string CHANNEL, 'general', self
104
- fac.create_string ICON, ':ghost:', self
105
- end
106
-
107
- # ---------------------------------------------------------------------
108
- # Messages
109
- # ---------------------------------------------------------------------
110
-
111
- #
112
- # Get a list of message names that this object receives.
113
- #
114
- def self.messages
115
- return super + [ 'run' ]
116
- end
117
-
118
- #
119
- # Post the content to the Slack channel.
120
- #
121
- def msg_run
122
- uri = uri_value
123
- return unless uri
124
-
125
- Gloo::Objs::HttpPost.post_json uri, body_as_json
126
- end
127
-
128
- end
129
- end
130
- end
@@ -1,117 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An object that can send a message to a Teams webhook.
5
- #
6
- require 'net/http'
7
- require 'uri'
8
- require 'json'
9
-
10
- module Gloo
11
- module Objs
12
- class Teams < Gloo::Core::Obj
13
-
14
- KEYWORD = 'teams'.freeze
15
- KEYWORD_SHORT = 'team'.freeze
16
- URL = 'uri'.freeze
17
- DEFAULT_URL = 'https://outlook.office.com/webhook/...'.freeze
18
- MSG = 'message'.freeze
19
- TITLE = 'title'.freeze
20
- COLOR = 'color'.freeze
21
- DEFAULT_COLOR = '008000'.freeze
22
-
23
- #
24
- # The name of the object type.
25
- #
26
- def self.typename
27
- return KEYWORD
28
- end
29
-
30
- #
31
- # The short name of the object type.
32
- #
33
- def self.short_typename
34
- return KEYWORD_SHORT
35
- end
36
-
37
- #
38
- # Get the URI from the child object.
39
- # Returns nil if there is none.
40
- #
41
- def uri_value
42
- uri = find_child URL
43
- return nil unless uri
44
-
45
- return uri.value
46
- end
47
-
48
- # Get the color value.
49
- def color_value
50
- c = find_child COLOR
51
- return nil unless c
52
-
53
- return c.value
54
- end
55
-
56
- #
57
- # Get all the children of the body container and
58
- # convert to JSON that will be sent in the HTTP body.
59
- #
60
- def body_as_json
61
- h = { 'title' => find_child( TITLE ).value,
62
- 'text' => find_child( MSG ).value }
63
- color = color_value
64
- h[ 'themeColor' ] = color if color
65
- return h.to_json
66
- end
67
-
68
- # ---------------------------------------------------------------------
69
- # Children
70
- # ---------------------------------------------------------------------
71
-
72
- #
73
- # Does this object have children to add when an object
74
- # is created in interactive mode?
75
- # This does not apply during obj load, etc.
76
- #
77
- def add_children_on_create?
78
- return true
79
- end
80
-
81
- #
82
- # Add children to this object.
83
- # This is used by containers to add children needed
84
- # for default configurations.
85
- #
86
- def add_default_children
87
- fac = @engine.factory
88
- fac.create_string URL, DEFAULT_URL, self
89
- fac.create_string TITLE, '', self
90
- fac.create_string COLOR, DEFAULT_COLOR, self
91
- fac.create_string MSG, '', self
92
- end
93
-
94
- # ---------------------------------------------------------------------
95
- # Messages
96
- # ---------------------------------------------------------------------
97
-
98
- #
99
- # Get a list of message names that this object receives.
100
- #
101
- def self.messages
102
- return super + [ 'run' ]
103
- end
104
-
105
- #
106
- # Post the content to Microsoft Teams.
107
- #
108
- def msg_run
109
- uri = uri_value
110
- return unless uri
111
-
112
- Gloo::Objs::HttpPost.post_json uri, body_as_json
113
- end
114
-
115
- end
116
- end
117
- 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