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,267 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A data table.
5
- # The table container headers and data.
6
- #
7
-
8
- module Gloo
9
- module Objs
10
- class Table < Gloo::Core::Obj
11
-
12
- KEYWORD = 'table'.freeze
13
- KEYWORD_SHORT = 'tbl'.freeze
14
- HEADERS = 'headers'.freeze
15
- DATA = 'data'.freeze
16
- CELLS = 'cells'.freeze
17
- STYLES = 'styles'.freeze
18
- ALWAYS_ROWS = 'always_rows'.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
- # Get the list of headers.
36
- # Returns nil if there is none.
37
- #
38
- def headers
39
- o = find_child HEADERS
40
- return [] unless o
41
-
42
- return o.children.map( &:value )
43
- end
44
-
45
- #
46
- # Always show rows, even if only 1 row is found.
47
- #
48
- def always_rows
49
- o = find_child ALWAYS_ROWS
50
-
51
- return false unless o
52
- return o.value
53
- end
54
-
55
- #
56
- # Get the list of column names.
57
- # Returns nil if there is none.
58
- #
59
- def columns
60
- o = find_child HEADERS
61
- return [] unless o
62
-
63
- return o.children.map( &:name )
64
- end
65
-
66
- #
67
- # Get the list of data elements.
68
- #
69
- def data
70
- o = find_child DATA
71
- return [] unless o
72
-
73
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
74
- return [] unless o
75
-
76
- if o.is_a? Gloo::Objs::Query
77
- @engine.log.debug "Table getting data from query."
78
- begin
79
- result = o.run_query
80
- return result
81
- rescue => e
82
- @engine.log_exception e
83
- return nil
84
- end
85
- else
86
- cols = self.columns
87
-
88
- if o.children&.first.children.empty?
89
- # It is a simgle row table.
90
- rows = [ cols.map { |h| o.find_child( h )&.value } ]
91
- else
92
- rows = o.children.map do |e|
93
- cols.map { |h| e.find_child( h )&.value }
94
- end
95
- end
96
-
97
- return [ cols, rows ]
98
- end
99
- end
100
-
101
- #
102
- # Get the styles for the table, if any.
103
- #
104
- def styles
105
- style_h = {}
106
- o = find_child STYLES
107
- return style_h unless o
108
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
109
-
110
- o.children.each do |c|
111
- style_h[ c.name ] = c.value
112
- end
113
-
114
- return style_h
115
- end
116
-
117
- #
118
- # Get cell renderer hash keyed by column name.
119
- #
120
- def cell_renderers
121
- h = {}
122
- o = find_child CELLS
123
- return h unless o
124
-
125
- o.children.each do |c|
126
- h[ c.name ] = c.value
127
- end
128
-
129
- return h
130
- end
131
-
132
-
133
- # ---------------------------------------------------------------------
134
- # Children
135
- # ---------------------------------------------------------------------
136
-
137
- #
138
- # Does this object have children to add when an object
139
- # is created in interactive mode?
140
- # This does not apply during obj load, etc.
141
- #
142
- def add_children_on_create?
143
- return true
144
- end
145
-
146
- #
147
- # Add children to this object.
148
- # This is used by containers to add children needed
149
- # for default configurations.
150
- #
151
- def add_default_children
152
- fac = @engine.factory
153
- fac.create_can HEADERS, self
154
- fac.create_can DATA, self
155
- end
156
-
157
-
158
- # ---------------------------------------------------------------------
159
- # Messages
160
- # ---------------------------------------------------------------------
161
-
162
- #
163
- # Get a list of message names that this object receives.
164
- #
165
- def self.messages
166
- return super + %w[show render]
167
- end
168
-
169
- #
170
- # Show the table in the CLI.
171
- #
172
- def msg_show
173
- title = self.value
174
- @engine.platform.table.show headers, data[1], title
175
- end
176
-
177
- def msg_render
178
- return render
179
- end
180
-
181
-
182
- # ---------------------------------------------------------------------
183
- # Render
184
- # ---------------------------------------------------------------------
185
-
186
- #
187
- # Render the table.
188
- # The render_ƒ is 'render_html', 'render_text', 'render_json', etc.
189
- #
190
- def render render_ƒ
191
- begin
192
- result = self.data
193
- head = self.headers
194
- head = result[0] if head.empty?
195
- rows = result[1]
196
-
197
- columns = build_columns result[0]
198
-
199
- params = {
200
- head: head,
201
- cols: result[0],
202
- columns: columns,
203
- rows: rows,
204
- styles: self.styles,
205
- cell_renderers: self.cell_renderers
206
- }
207
-
208
- if self.always_rows
209
- params[ :always_rows ] = true
210
- end
211
-
212
- helper = Gloo::WebSvr::TableRenderer.new( @engine )
213
- return helper.data_to_table params
214
- rescue => e
215
- @engine.log_exception e
216
- return nil
217
- end
218
- end
219
-
220
- #
221
- # Build the column list based on the result data and
222
- # the headers defined in the table object.
223
- #
224
- def build_columns result_data
225
- head_children = find_child HEADERS
226
- cell_renderers = find_child CELLS
227
-
228
- columns = []
229
- return columns unless result_data
230
-
231
- result_data.each_with_index do |c,index|
232
- visible = true
233
- name = c
234
- title = c
235
- display_index = index
236
-
237
- if head_children
238
- child = head_children.find_child c
239
- if child
240
- title = child.value
241
- display_index = head_children.child_index( c )
242
- else
243
- visible = false
244
- end
245
- end
246
-
247
- cell_renderer = nil
248
- if cell_renderers
249
- this_cr = cell_renderers.find_child( c )
250
- cell_renderer = this_cr.value if this_cr
251
- end
252
-
253
- columns << {
254
- name: name,
255
- title: title,
256
- visible: visible,
257
- data_index: index,
258
- display_index: display_index,
259
- cell_renderer: cell_renderer
260
- }
261
- end
262
- return columns.sort_by { |hsh| hsh[ :display_index ] }
263
- end
264
-
265
- end
266
- end
267
- end
@@ -1,140 +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 interacts with a git repository
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Git < Gloo::Core::Obj
10
-
11
- KEYWORD = 'git_repo'.freeze
12
- KEYWORD_SHORT = 'git'.freeze
13
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- #
29
- # Get the path to the git repo (locally).
30
- #
31
- def path_value
32
- return value
33
- end
34
-
35
- # ---------------------------------------------------------------------
36
- # Messages
37
- # ---------------------------------------------------------------------
38
-
39
- #
40
- # Get a list of message names that this object receives.
41
- #
42
- def self.messages
43
- actions = %w[validate commit get_branch review]
44
- changes = %w[check_changes get_changes]
45
- return super + changes + actions
46
- end
47
-
48
- #
49
- # Get the current working branch.
50
- #
51
- def msg_get_branch
52
- branch = ''
53
- path = path_value
54
- if path_is_dir?( path )
55
- branch = `cd #{path}; git rev-parse --abbrev-ref HEAD`
56
- branch = branch.strip
57
- end
58
-
59
- @engine.heap.it.set_to branch
60
- end
61
-
62
- #
63
- # Review pending changes.
64
- #
65
- def msg_review
66
- @engine.log.debug 'Reviewing pending changes'
67
- cmd = "cd #{path_value}; git diff"
68
- @engine.log.debug cmd
69
- system cmd
70
- end
71
-
72
- #
73
- # Commit pending changes.
74
- #
75
- def msg_commit
76
- msg = 'Commit'
77
- path = path_value
78
- if path_is_dir?( path )
79
- if @params&.token_count&.positive?
80
- expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
81
- msg = expr.evaluate
82
- end
83
- branch = `cd #{path}; git rev-parse --abbrev-ref HEAD`
84
- branch = branch.strip
85
- add = 'git add .'
86
- cmt = 'git commit -m '
87
- psh = 'git push origin '
88
- `cd #{path};#{add};#{cmt}"#{msg}";#{psh}#{branch}`
89
- end
90
- @engine.heap.it.set_to msg
91
- end
92
-
93
- #
94
- # Get the pending changes.
95
- #
96
- def msg_get_changes
97
- path = path_value
98
- result = `cd #{path}; git status -s` if path_is_dir?( path )
99
- result ||= ''
100
- @engine.heap.it.set_to result
101
- end
102
-
103
- #
104
- # Is the given path non nil and is it a directory?
105
- #
106
- def path_is_dir?( path )
107
- return path && File.directory?( path )
108
- end
109
-
110
- #
111
- # Check to see if the repo has changes.
112
- #
113
- def msg_check_changes
114
- result = false
115
- path = path_value
116
- if path_is_dir?( path )
117
- data = `cd #{path}; git status -s`
118
- result = true unless data.strip.empty?
119
- end
120
-
121
- @engine.heap.it.set_to result
122
- end
123
-
124
- #
125
- # Check to make sure this is a valide git repo.
126
- #
127
- def msg_validate
128
- result = false
129
- path = path_value
130
- if path_is_dir?( path )
131
- pn = File.join( path, '.git' )
132
- result = File.exist? pn
133
- end
134
-
135
- @engine.heap.it.set_to result
136
- end
137
-
138
- end
139
- end
140
- end
@@ -1,123 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Get statistics about a development project.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Stats < Gloo::Core::Obj
10
-
11
- KEYWORD = 'stats'.freeze
12
- KEYWORD_SHORT = 'stat'.freeze
13
- FOLDER = 'folder'.freeze
14
- TYPES = 'types'.freeze
15
- SKIP = 'skip'.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 path to the git repo (locally).
33
- #
34
- def path_value
35
- o = find_child FOLDER
36
- return o ? o.value : nil
37
- end
38
-
39
- #
40
- # The code file types to count.
41
- #
42
- def types_value
43
- o = find_child TYPES
44
- return o ? o.value : ''
45
- end
46
-
47
- #
48
- # Get the list of files and folders to skip.
49
- #
50
- def skip_list
51
- o = find_child SKIP
52
- val = o ? o.value : ''
53
- return val.split ' '
54
- end
55
-
56
- # ---------------------------------------------------------------------
57
- # Children
58
- # ---------------------------------------------------------------------
59
-
60
- #
61
- # Does this object have children to add when an object
62
- # is created in interactive mode?
63
- # This does not apply during obj load, etc.
64
- #
65
- def add_children_on_create?
66
- return true
67
- end
68
-
69
- #
70
- # Add children to this object.
71
- # This is used by containers to add children needed
72
- # for default configurations.
73
- #
74
- def add_default_children
75
- fac = @engine.factory
76
- fac.create_file FOLDER, '', self
77
- fac.create_string TYPES, '', self
78
- fac.create_can SKIP, self
79
- end
80
-
81
- # ---------------------------------------------------------------------
82
- # Messages
83
- # ---------------------------------------------------------------------
84
-
85
- #
86
- # Get a list of message names that this object receives.
87
- #
88
- def self.messages
89
- all = %w[show_all]
90
- more = %w[show_busy_folders show_types]
91
- return super + all + more
92
- end
93
-
94
- #
95
- # Show all project stats.
96
- #
97
- def msg_show_all
98
- o = Gloo::Utils::Stats.new(
99
- @engine, path_value, types_value, skip_list )
100
- o.show_all
101
- end
102
-
103
- #
104
- # Show file types.
105
- #
106
- def msg_show_types
107
- o = Gloo::Utils::Stats.new(
108
- @engine, path_value, types_value, skip_list )
109
- o.file_types
110
- end
111
-
112
- #
113
- # Show busy folders: those with the most files.
114
- #
115
- def msg_show_busy_folders
116
- o = Gloo::Utils::Stats.new(
117
- @engine, path_value, types_value, skip_list )
118
- o.busy_folders
119
- end
120
-
121
- end
122
- end
123
- end
@@ -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