gloo 4.7.0 → 5.0.1

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 +11 -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 +74 -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,370 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A CLI menu.
5
- # The menu contains a collection of menu items, a prompt
6
- # and an option to loop until done.
7
- #
8
-
9
- module Gloo
10
- module Objs
11
- class Menu < Gloo::Core::Obj
12
-
13
- KEYWORD = 'menu'.freeze
14
- KEYWORD_SHORT = 'menu'.freeze
15
- PROMPT = 'prompt'.freeze
16
- ITEMS = 'items'.freeze
17
- LOOP = 'loop'.freeze
18
- HIDE_ITEMS = 'hide_items'.freeze
19
- BEFORE_MENU = 'before_menu'.freeze
20
- DEFAULT = 'default'.freeze
21
- TITLE = 'title'.freeze
22
- TITLE_COLOR = 'green'.freeze
23
- QUIT_ITEM_NAME = 'q'.freeze
24
-
25
- @@menu_stack = []
26
-
27
- #
28
- # The name of the object type.
29
- #
30
- def self.typename
31
- return KEYWORD
32
- end
33
-
34
- #
35
- # The short name of the object type.
36
- #
37
- def self.short_typename
38
- return KEYWORD_SHORT
39
- end
40
-
41
- #
42
- # Get the value of the prompt child object.
43
- # Returns nil if there is none.
44
- #
45
- def prompt_value
46
- o = find_child PROMPT
47
- return '' unless o
48
-
49
- return o.value
50
- end
51
-
52
- #
53
- # Get the value of the loop child object.
54
- # Should we keep looping or should we stop?
55
- #
56
- def loop?
57
- return false unless @engine.running
58
-
59
- o = find_child LOOP
60
- return false unless o
61
-
62
- return o.value
63
- end
64
-
65
- #
66
- # If there is no loop child, add it.
67
- #
68
- def add_loop_child
69
- o = find_child LOOP
70
- if o
71
- o.set_value true
72
- return
73
- end
74
-
75
- fac = @engine.factory
76
- fac.create_bool LOOP, true, self
77
- end
78
-
79
- #
80
- # Add a Quit menu item
81
- #
82
- def add_quit_item
83
- items = find_child ITEMS
84
- q = items.find_child QUIT_ITEM_NAME
85
- return if q
86
-
87
- fac = @engine.factory
88
- fac.create_bool LOOP, true, self
89
-
90
- params = { :name => QUIT_ITEM_NAME,
91
- :type => 'mitem',
92
- :value => 'Quit',
93
- :parent => items }
94
- mitem = fac.create params
95
- script = "put false into #{self.pn}.loop"
96
- fac.create_script 'do', script, mitem
97
- end
98
-
99
- #
100
- # Add any required children not specified in the source.
101
- #
102
- def lazy_add_children
103
- add_loop_child
104
- add_quit_item
105
- end
106
-
107
- #
108
- # Does the menu have a title?
109
- #
110
- def title?
111
- o = find_child TITLE
112
- return o ? true : false
113
- end
114
-
115
- #
116
- # Get the Menu's Title.
117
- #
118
- def title
119
- obj = find_child TITLE
120
- return obj.value
121
- end
122
-
123
- # ---------------------------------------------------------------------
124
- # Children
125
- # ---------------------------------------------------------------------
126
-
127
- #
128
- # Does this object have children to add when an object
129
- # is created in interactive mode?
130
- # This does not apply during obj load, etc.
131
- #
132
- def add_children_on_create?
133
- return true
134
- end
135
-
136
- #
137
- # Add children to this object.
138
- # This is used by containers to add children needed
139
- # for default configurations.
140
- #
141
- def add_default_children
142
- fac = @engine.factory
143
- fac.create_string PROMPT, '> ', self
144
- fac.create_can ITEMS, self
145
- fac.create_bool LOOP, true, self
146
- fac.create_script DEFAULT, '', self
147
- end
148
-
149
- # ---------------------------------------------------------------------
150
- # Menu Stack
151
- # ---------------------------------------------------------------------
152
-
153
- #
154
- # Show the bread-crumbs for the menu stack.
155
- #
156
- def show_menu_stack
157
- if @@menu_stack.count < 2
158
- puts '...'
159
- else
160
- msg = ''
161
- @@menu_stack[0..-2].each do |menu|
162
- msg << ' | ' unless msg.blank?
163
- msg << menu.title
164
- end
165
- msg << ' | ... '
166
- puts msg
167
- end
168
- end
169
-
170
- #
171
- # Add a menu to the stack.
172
- #
173
- def push_menu obj
174
- @@menu_stack << obj
175
- end
176
-
177
- #
178
- # Pop a menu from the stack.
179
- # If the last item isn't the given menu,
180
- # it won't be popped.
181
- #
182
- def pop_menu menu
183
- if @@menu_stack[-1] == menu
184
- @@menu_stack.pop
185
- end
186
- end
187
-
188
- #
189
- # Quit all menus and drop into gloo.
190
- #
191
- def pop_to_top_level_menu
192
- @engine.log.debug 'Quitting to top level menu'
193
- while @@menu_stack.count > 1
194
- menu = @@menu_stack.pop
195
- o = menu.find_child LOOP
196
- o.set_value( false ) if o
197
- end
198
- end
199
-
200
- #
201
- # Quit all menus and drop into gloo.
202
- #
203
- def quit_all_menus
204
- @engine.log.debug 'Dropping into Gloo'
205
- @@menu_stack.each do |menu|
206
- o = menu.find_child LOOP
207
- o.set_value( false ) if o
208
- end
209
- @engine.loop
210
- end
211
-
212
- # ---------------------------------------------------------------------
213
- # Messages
214
- # ---------------------------------------------------------------------
215
-
216
- #
217
- # Get a list of message names that this object receives.
218
- #
219
- def self.messages
220
- return super + [ 'run' ]
221
- end
222
-
223
- #
224
- # Show the menu options, and prompt for user input.
225
- #
226
- def msg_run
227
- lazy_add_children
228
- push_menu self
229
- run_default
230
- loop do
231
- begin_menu
232
- if prompt_value.empty?
233
- dt = DateTime.now
234
- d = dt.strftime( '%Y.%m.%d' )
235
- t = dt.strftime( '%I:%M:%S' )
236
- cmd = @engine.platform.prompt.ask( "#{d.yellow} #{t.white} >" )
237
- else
238
- cmd = @engine.platform.prompt.ask( prompt_value )
239
- end
240
- cmd ? run_command( cmd ) : run_default
241
- break unless loop?
242
- end
243
- pop_menu self
244
- end
245
-
246
- # ---------------------------------------------------------------------
247
- # Menu actions
248
- # ---------------------------------------------------------------------
249
-
250
- #
251
- # Begin the menu execution.
252
- # Run the before menu script if there is one,
253
- # then show options unless we are hiding them by default.
254
- #
255
- def begin_menu
256
- run_before_menu
257
-
258
- # Check to see if we should show items at all.
259
- o = find_child HIDE_ITEMS
260
- return if o && o.value == true
261
-
262
- show_options
263
- end
264
-
265
- #
266
- # If there is a before menu script, run it now.
267
- #
268
- def run_before_menu
269
- o = find_child BEFORE_MENU
270
- return unless o
271
-
272
- Gloo::Exec::Dispatch.message( @engine, 'run', o )
273
- end
274
-
275
- #
276
- # Show the list of menu options.
277
- #
278
- def show_options
279
- o = find_child ITEMS
280
- return unless o
281
-
282
- o.children.each do |mitem|
283
- mitem = Gloo::Objs::Alias.resolve_alias( @engine, mitem )
284
- puts " #{mitem.shortcut_value} - #{mitem.description_value}"
285
- end
286
- end
287
-
288
- #
289
- # Find the command matching user input.
290
- #
291
- def find_cmd( cmd )
292
- o = find_child ITEMS
293
- return nil unless o
294
-
295
- o.children.each do |mitem|
296
- mitem = Gloo::Objs::Alias.resolve_alias( @engine, mitem )
297
- return mitem if mitem.shortcut_value.downcase == cmd.downcase
298
- end
299
-
300
- return nil
301
- end
302
-
303
- #
304
- # Run the default option.
305
- #
306
- def run_default
307
- obj = find_child DEFAULT
308
- if obj
309
- s = Gloo::Exec::Script.new( @engine, obj )
310
- s.run
311
- elsif title?
312
- run_default_title
313
- end
314
- end
315
-
316
- #
317
- # There is a title, so show it.
318
- #
319
- def run_default_title
320
- @engine.platform&.clear_screen
321
- show_menu_stack
322
-
323
- title_text = @engine.platform.table.box( title )
324
- puts title_text.colorize( :color => :white, :background => :black )
325
- end
326
-
327
- #
328
- # Run the selected command.
329
- #
330
- def run_command( cmd )
331
- @engine.log.info "Menu Command: #{cmd}"
332
- obj = find_cmd cmd
333
-
334
- if obj
335
- script = obj.do_script
336
- return unless script
337
-
338
- s = Gloo::Exec::Script.new( @engine, script )
339
- s.run
340
- else
341
- if cmd == '?'
342
- @engine.log.debug 'Showing options'
343
- show_options
344
- elsif cmd == 'q!'
345
- @engine.log.debug 'Quitting Gloo'
346
- @engine.stop_running
347
- elsif cmd == 'qq'
348
- @engine.log.debug 'Quitting to top level menu'
349
- pop_to_top_level_menu
350
- elsif cmd.starts_with? ':'
351
- gloo_cmd = cmd[1..-1].strip
352
- if gloo_cmd.blank?
353
- @engine.log.debug 'Quitting all menus and dropping into Gloo'
354
- quit_all_menus
355
- else
356
- @engine.log.debug "Running Gloo command: #{gloo_cmd}"
357
- @engine.process_cmd gloo_cmd
358
- end
359
- else
360
- msg = "#{cmd} is not a valid option"
361
- @engine.log.warn msg
362
- end
363
- return
364
- end
365
-
366
- end
367
-
368
- end
369
- end
370
- end
@@ -1,95 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A CLI menu item. One element in a CLI menu.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class MenuItem < Gloo::Core::Obj
10
-
11
- KEYWORD = 'menu_item'.freeze
12
- KEYWORD_SHORT = 'mitem'.freeze
13
- SHORTCUT = 'shortcut'.freeze
14
- DESCRIPTION = 'description'.freeze
15
- DO = 'do'.freeze
16
-
17
- #
18
- # The name of the object type.
19
- #
20
- def self.typename
21
- return KEYWORD
22
- end
23
-
24
- #
25
- # The short name of the object type.
26
- #
27
- def self.short_typename
28
- return KEYWORD_SHORT
29
- end
30
-
31
- #
32
- # Get the value of the menu item shortcut.
33
- # Returns nil if there is none.
34
- #
35
- def shortcut_value
36
- o = find_child SHORTCUT
37
- return self.name unless o
38
-
39
- return o.value
40
- end
41
-
42
- #
43
- # Get the action's description.
44
- # Returns nil if there is none.
45
- #
46
- def description_value
47
- o = find_child DESCRIPTION
48
- return self.value unless o
49
-
50
- return o.value
51
- end
52
-
53
- #
54
- # Get the action's script.
55
- # Returns nil if there is none.
56
- #
57
- def do_script
58
- return find_child DO
59
- end
60
-
61
- # ---------------------------------------------------------------------
62
- # Children
63
- # ---------------------------------------------------------------------
64
-
65
- # Does this object have children to add when an object
66
- # is created in interactive mode?
67
- # This does not apply during obj load, etc.
68
- def add_children_on_create?
69
- return true
70
- end
71
-
72
- # Add children to this object.
73
- # This is used by containers to add children needed
74
- # for default configurations.
75
- def add_default_children
76
- fac = @engine.factory
77
- fac.create_string SHORTCUT, '', self
78
- fac.create_string DESCRIPTION, '', self
79
- fac.create_script DO, '', self
80
- end
81
-
82
- # ---------------------------------------------------------------------
83
- # Messages
84
- # ---------------------------------------------------------------------
85
-
86
- #
87
- # Get a list of message names that this object receives.
88
- #
89
- def self.messages
90
- return super
91
- end
92
-
93
- end
94
- end
95
- end
@@ -1,110 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Show a CLI prompt and collect user input.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Prompt < Gloo::Core::Obj
10
-
11
- KEYWORD = 'prompt'.freeze
12
- KEYWORD_SHORT = 'ask'.freeze
13
- PROMPT = 'prompt'.freeze
14
- RESULT = 'result'.freeze
15
-
16
- #
17
- # The name of the object type.
18
- #
19
- def self.typename
20
- return KEYWORD
21
- end
22
-
23
- #
24
- # The short name of the object type.
25
- #
26
- def self.short_typename
27
- return KEYWORD_SHORT
28
- end
29
-
30
- #
31
- # Get the prompt from the child object.
32
- # Returns nil if there is none.
33
- #
34
- def prompt_value
35
- o = find_child PROMPT
36
- return nil unless o
37
-
38
- return o.value
39
- end
40
-
41
- #
42
- # Set the result of the system call.
43
- #
44
- def set_result( data )
45
- r = find_child RESULT
46
- return nil unless r
47
-
48
- r.set_value data
49
- end
50
-
51
- # ---------------------------------------------------------------------
52
- # Children
53
- # ---------------------------------------------------------------------
54
-
55
- #
56
- # Does this object have children to add when an object
57
- # is created in interactive mode?
58
- # This does not apply during obj load, etc.
59
- #
60
- def add_children_on_create?
61
- return true
62
- end
63
-
64
- #
65
- # Add children to this object.
66
- # This is used by containers to add children needed
67
- # for default configurations.
68
- #
69
- def add_default_children
70
- fac = @engine.factory
71
- fac.create_string PROMPT, '>', self
72
- fac.create_string RESULT, nil, self
73
- end
74
-
75
- # ---------------------------------------------------------------------
76
- # Messages
77
- # ---------------------------------------------------------------------
78
-
79
- #
80
- # Get a list of message names that this object receives.
81
- #
82
- def self.messages
83
- return super + %w[run multiline]
84
- end
85
-
86
- #
87
- # Show a multiline prompt and get the user's input.
88
- #
89
- def msg_multiline
90
- prompt = prompt_value
91
- return unless prompt
92
-
93
- result = @engine.platform.prompt.multiline( prompt )
94
- set_result result.join
95
- end
96
-
97
- #
98
- # Show the prompt and get the user's input.
99
- #
100
- def msg_run
101
- prompt = prompt_value
102
- return unless prompt
103
-
104
- result = @engine.platform.prompt.ask( prompt )
105
- set_result result
106
- end
107
-
108
- end
109
- end
110
- end
@@ -1,127 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Show a CLI prompt and user selection from a list.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Select < Gloo::Core::Obj
10
-
11
- KEYWORD = 'select'.freeze
12
- KEYWORD_SHORT = 'sel'.freeze
13
- PROMPT = 'prompt'.freeze
14
- OPTIONS = 'options'.freeze
15
- RESULT = 'result'.freeze
16
-
17
- #
18
- # The name of the object type.
19
- #
20
- def self.typename
21
- return KEYWORD
22
- end
23
-
24
- #
25
- # The short name of the object type.
26
- #
27
- def self.short_typename
28
- return KEYWORD_SHORT
29
- end
30
-
31
- #
32
- # Get the prompt from the child object.
33
- # Returns nil if there is none.
34
- #
35
- def prompt_value
36
- o = find_child PROMPT
37
- return nil unless o
38
-
39
- return o.value
40
- end
41
-
42
- #
43
- # Get the list of options for selection.
44
- #
45
- def options
46
- o = find_child OPTIONS
47
- return [] unless o
48
-
49
- return o.children.map( &:name )
50
- end
51
-
52
- #
53
- # Get the value of the selected item.
54
- #
55
- def key_for_option( selected )
56
- o = find_child OPTIONS
57
- return nil unless o
58
-
59
- o.children.each do |c|
60
- return c.value if c.name == selected
61
- end
62
-
63
- return nil
64
- end
65
-
66
- #
67
- # Set the result of the system call.
68
- #
69
- def set_result( data )
70
- r = find_child RESULT
71
- return nil unless r
72
-
73
- r.set_value data
74
- end
75
-
76
- # ---------------------------------------------------------------------
77
- # Children
78
- # ---------------------------------------------------------------------
79
-
80
- #
81
- # Does this object have children to add when an object
82
- # is created in interactive mode?
83
- # This does not apply during obj load, etc.
84
- #
85
- def add_children_on_create?
86
- return true
87
- end
88
-
89
- #
90
- # Add children to this object.
91
- # This is used by containers to add children needed
92
- # for default configurations.
93
- #
94
- def add_default_children
95
- fac = @engine.factory
96
- fac.create_string PROMPT, '>', self
97
- fac.create_can OPTIONS, self
98
- fac.create_string RESULT, nil, self
99
- end
100
-
101
- # ---------------------------------------------------------------------
102
- # Messages
103
- # ---------------------------------------------------------------------
104
-
105
- #
106
- # Get a list of message names that this object receives.
107
- #
108
- def self.messages
109
- return super + %w[run]
110
- end
111
-
112
- #
113
- # Show the prompt and get the user's selection.
114
- #
115
- def msg_run
116
- prompt = prompt_value
117
- return unless prompt
118
-
119
- # Page size was part of the tty-prompt but not used now.
120
- # per = Gloo::App::Settings.page_size( @engine )
121
- result = @engine.platform.prompt.select( prompt, options )
122
- set_result self.key_for_option( result )
123
- end
124
-
125
- end
126
- end
127
- end