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,174 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A Sqlite3 database connection.
5
- #
6
- # https://www.rubydoc.info/gems/sqlite3/1.3.11
7
- # https://www.devdungeon.com/content/ruby-sqlite-tutorial
8
- #
9
- # db.results_as_hash = true
10
- # Set results to return as Hash object.
11
- # This is slower but offers a huge convenience.
12
- # Consider turning it off for high performance situations.
13
- # Each row will have the column name as the hash key.
14
- #
15
- # # Alternatively, to only get one row and discard the rest,
16
- # replace `db.query()` with `db.get_first_value()`.
17
- #
18
- require 'sqlite3'
19
-
20
- module Gloo
21
- module Objs
22
- class Sqlite < Gloo::Core::Obj
23
-
24
- KEYWORD = 'sqlite'.freeze
25
- KEYWORD_SHORT = 'sqlite'.freeze
26
-
27
- DB = 'database'.freeze
28
- DEFAULT_DB = 'test.db'.freeze
29
-
30
- DB_REQUIRED_ERR = 'The database name is required!'.freeze
31
- DB_NOT_FOUND_ERR = 'The database file was not found!'.freeze
32
-
33
- #
34
- # The name of the object type.
35
- #
36
- def self.typename
37
- return KEYWORD
38
- end
39
-
40
- #
41
- # The short name of the object type.
42
- #
43
- def self.short_typename
44
- return KEYWORD_SHORT
45
- end
46
-
47
- # ---------------------------------------------------------------------
48
- # Children
49
- # ---------------------------------------------------------------------
50
-
51
- #
52
- # Does this object have children to add when an object
53
- # is created in interactive mode?
54
- # This does not apply during obj load, etc.
55
- #
56
- def add_children_on_create?
57
- return true
58
- end
59
-
60
- #
61
- # Add children to this object.
62
- # This is used by containers to add children needed
63
- # for default configurations.
64
- #
65
- def add_default_children
66
- fac = @engine.factory
67
- fac.create_string DB, DEFAULT_DB, self
68
- end
69
-
70
- # ---------------------------------------------------------------------
71
- # Messages
72
- # ---------------------------------------------------------------------
73
-
74
- #
75
- # Get a list of message names that this object receives.
76
- #
77
- def self.messages
78
- return super + [ 'verify' ]
79
- end
80
-
81
- #
82
- # Verify access to the Sqlite database specified.
83
- #
84
- def msg_verify
85
- name = db_value
86
- if name.empty?
87
- @engine.err DB_REQUIRED_ERR
88
- @engine.heap.it.set_to false
89
- return
90
- end
91
-
92
- unless File.exist? name
93
- @engine.err DB_NOT_FOUND_ERR
94
- @engine.heap.it.set_to false
95
- return
96
- end
97
-
98
- return unless connects?
99
-
100
- @engine.heap.it.set_to true
101
- end
102
-
103
- # ---------------------------------------------------------------------
104
- # DB functions (all database connections)
105
- # ---------------------------------------------------------------------
106
-
107
- #
108
- # Open a connection and execute the SQL statement.
109
- # Return the resulting data.
110
- #
111
- def query( sql, params = nil )
112
- name = db_value
113
- unless name
114
- @engine.err DB_REQUIRED_ERR
115
- return
116
- end
117
-
118
- db = SQLite3::Database.open name
119
- # db.results_as_hash = true
120
- results = db.query( sql, params )
121
-
122
- return results
123
- end
124
-
125
- #
126
- # Based on the result set, build a QueryResult object.
127
- #
128
- def get_query_result( result )
129
- rows = []
130
- while ( row = result.next ) do
131
- rows << row
132
- end
133
-
134
- return QueryResult.new( result.columns, rows )
135
- end
136
-
137
-
138
- # ---------------------------------------------------------------------
139
- # Private functions
140
- # ---------------------------------------------------------------------
141
-
142
- private
143
-
144
- #
145
- # Get the Database file from the child object.
146
- # Returns nil if there is none.
147
- #
148
- def db_value
149
- o = find_child DB
150
- return nil unless o
151
-
152
- return o.value
153
- end
154
-
155
- #
156
- # Try the connection and make sure it works.
157
- # Returns true if we can connect and do a query.
158
- #
159
- def connects?
160
- begin
161
- db = SQLite3::Database.open db_value
162
- sql = "SELECT COUNT(name) FROM sqlite_master WHERE type='table'"
163
- db.get_first_value sql
164
- rescue => e
165
- @engine.log_exception e
166
- @engine.heap.it.set_to false
167
- return false
168
- end
169
- return true
170
- end
171
-
172
- end
173
- end
174
- end
@@ -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