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,254 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A MySQL database connection.
5
- #
6
- #
7
- # https://github.com/brianmario/mysql2
8
- # https://www.rubydoc.info/gems/mysql2/0.2.3/Mysql2/Client
9
- #
10
- # Connection Parameters
11
- # user = opts[:username]
12
- # pass = opts[:password]
13
- # host = opts[:host] || 'localhost'
14
- # port = opts[:port] || 3306
15
- # database = opts[:database]
16
- # socket = opts[:socket]
17
- # flags = opts[:flags] || 0
18
- #
19
- require 'mysql2'
20
-
21
- module Gloo
22
- module Objs
23
- class Mysql < Gloo::Core::Obj
24
-
25
- KEYWORD = 'mysql'.freeze
26
- KEYWORD_SHORT = 'mysql'.freeze
27
-
28
- HOST = 'host'.freeze
29
- DB = 'database'.freeze
30
- USER = 'username'.freeze
31
- PASSWD = 'password'.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 HOST, nil, self
68
- fac.create_string DB, nil, self
69
- fac.create_string USER, nil, self
70
- fac.create_string PASSWD, nil, self
71
- end
72
-
73
- # ---------------------------------------------------------------------
74
- # Messages
75
- # ---------------------------------------------------------------------
76
-
77
- #
78
- # Get a list of message names that this object receives.
79
- #
80
- def self.messages
81
- return super + [ 'verify' ]
82
- end
83
-
84
- #
85
- # SSH to the host and execute the command, then update result.
86
- #
87
- def msg_verify
88
- return unless connects?
89
-
90
- @engine.heap.it.set_to true
91
- end
92
-
93
-
94
- # ---------------------------------------------------------------------
95
- # DB functions (all database connections)
96
- # ---------------------------------------------------------------------
97
-
98
- #
99
- # Get the client object.
100
- # It might be cached, so check first.
101
- # If it is not cached, create a new one.
102
- #
103
- def get_client
104
- app = @engine.running_app
105
-
106
- client = app.db_client_for_obj( self ) if app
107
-
108
- if client && client.ping
109
- @engine.log.debug "Connection is established and active."
110
- return client
111
- elsif client
112
- @engine.log.debug "Connection is established but NOT active. Reconnecting."
113
- else
114
- @engine.log.debug "Opening a new Connection."
115
- end
116
-
117
- h = {
118
- host: host_value,
119
- database: db_value,
120
- username: user_value,
121
- password: passwd_value
122
- }
123
- client = Mysql2::Client.new( h )
124
-
125
- app.cache_db_client( self, client ) if app
126
-
127
- return client
128
- end
129
-
130
- #
131
- # Open a connection and execute the SQL statement.
132
- # Return the resulting data.
133
- #
134
- def query( sql, params = nil )
135
- client = get_client
136
-
137
- heads = []
138
- data = []
139
- begin
140
- if params
141
- pst = client.prepare( sql )
142
- rs = pst.execute( *params, :as => :array )
143
- if rs
144
- rs.each do |row|
145
- arr = []
146
- row.each do |o|
147
- arr << o
148
- end
149
- data << arr
150
- end
151
- end
152
- else
153
- rs = client.query( sql, :as => :array )
154
- if rs
155
- rs.each do |row|
156
- data << row
157
- end
158
- end
159
- end
160
-
161
- heads = rs.fields if rs
162
- rescue => e
163
- @engine.log_exception e
164
- end
165
-
166
- return [ heads, data ]
167
- end
168
-
169
- #
170
- # Based on the result set, build a QueryResult object.
171
- #
172
- def get_query_result( result )
173
- return QueryResult.new result[0], result[1], @engine
174
- end
175
-
176
-
177
- # ---------------------------------------------------------------------
178
- # Private functions
179
- # ---------------------------------------------------------------------
180
-
181
- private
182
-
183
- #
184
- # Get the host from the child object.
185
- # Returns nil if there is none.
186
- #
187
- def host_value
188
- o = find_child HOST
189
- return nil unless o
190
-
191
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
192
- return o.value
193
- end
194
-
195
- #
196
- # Get the Database name from the child object.
197
- # Returns nil if there is none.
198
- #
199
- def db_value
200
- o = find_child DB
201
- return nil unless o
202
-
203
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
204
- return o.value
205
- end
206
-
207
- #
208
- # Get the Username from the child object.
209
- # Returns nil if there is none.
210
- #
211
- def user_value
212
- o = find_child USER
213
- return nil unless o
214
-
215
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
216
- return o.value
217
- end
218
-
219
- #
220
- # Get the Password name from the child object.
221
- # Returns nil if there is none.
222
- #
223
- def passwd_value
224
- o = find_child PASSWD
225
- return nil unless o
226
-
227
- o = Gloo::Objs::Alias.resolve_alias( @engine, o )
228
- return o.value
229
- end
230
-
231
- #
232
- # Try the connection and make sure it works.
233
- # Returns true if we can establish a connection.
234
- #
235
- def connects?
236
- begin
237
- h = {
238
- host: host_value,
239
- database: db_value,
240
- username: user_value,
241
- password: passwd_value
242
- }
243
- Mysql2::Client.new( h )
244
- rescue => e
245
- @engine.log_exception e
246
- @engine.heap.it.set_to false
247
- return false
248
- end
249
- return true
250
- end
251
-
252
- end
253
- end
254
- end
@@ -1,216 +0,0 @@
1
- # # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # # Copyright:: Copyright (c) 2023 Eric Crane. All rights reserved.
3
- # #
4
- # # A Postgres database connection.
5
- # #
6
- # # https://rubygems.org/gems/pg/versions/0.18.4
7
- # # https://github.com/ged/ruby-pg
8
- # #
9
- # require 'pg'
10
-
11
- # module Gloo
12
- # module Objs
13
- # class Pg < Gloo::Core::Obj
14
-
15
- # KEYWORD = 'postgres'.freeze
16
- # KEYWORD_SHORT = 'pg'.freeze
17
-
18
- # HOST = 'host'.freeze
19
- # DB = 'database'.freeze
20
- # USER = 'username'.freeze
21
- # PASSWD = 'password'.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
- # # Children
39
- # # ---------------------------------------------------------------------
40
-
41
- # #
42
- # # Does this object have children to add when an object
43
- # # is created in interactive mode?
44
- # # This does not apply during obj load, etc.
45
- # #
46
- # def add_children_on_create?
47
- # return true
48
- # end
49
-
50
- # #
51
- # # Add children to this object.
52
- # # This is used by containers to add children needed
53
- # # for default configurations.
54
- # #
55
- # def add_default_children
56
- # fac = @engine.factory
57
- # fac.create_string HOST, nil, self
58
- # fac.create_string DB, nil, self
59
- # fac.create_string USER, nil, self
60
- # fac.create_string PASSWD, nil, self
61
- # end
62
-
63
- # # ---------------------------------------------------------------------
64
- # # Messages
65
- # # ---------------------------------------------------------------------
66
-
67
- # #
68
- # # Get a list of message names that this object receives.
69
- # #
70
- # def self.messages
71
- # return super + [ 'verify' ]
72
- # end
73
-
74
- # #
75
- # # SSH to the host and execute the command, then update result.
76
- # #
77
- # def msg_verify
78
- # return unless connects?
79
-
80
- # @engine.heap.it.set_to true
81
- # end
82
-
83
- # # ---------------------------------------------------------------------
84
- # # DB functions (all database connections)
85
- # # ---------------------------------------------------------------------
86
-
87
- # #
88
- # # Open a connection and execute the SQL statement.
89
- # # Return the resulting data.
90
- # #
91
- # def query( sql, params = nil )
92
- # heads = []
93
- # data = []
94
- # client = pg_conn
95
-
96
- # if params
97
- # param_arr = []
98
- # params.each do |p|
99
- # param_arr << { :value => p, :type => 0, :format => 0 }
100
- # end
101
- # rs = client.exec_params( sql, params )
102
- # else
103
- # rs = client.exec( sql )
104
- # end
105
-
106
- # if rs && ( rs.count > 0 )
107
- # rs[0].each do |name, val|
108
- # heads << name
109
- # end
110
- # rs.each_with_index do |row, index|
111
- # arr = []
112
- # row.each do |name, val|
113
- # arr << val
114
- # end
115
- # data << arr
116
- # end
117
- # end
118
-
119
- # return [ heads, data ]
120
- # end
121
-
122
- # #
123
- # # Based on the result set, build a QueryResult object.
124
- # #
125
- # def get_query_result( result )
126
- # return QueryResult.new result[0], result[1], @engine
127
- # end
128
-
129
-
130
- # # ---------------------------------------------------------------------
131
- # # Private functions
132
- # # ---------------------------------------------------------------------
133
-
134
- # private
135
-
136
- # #
137
- # # Get the host from the child object.
138
- # # Returns nil if there is none.
139
- # #
140
- # def host_value
141
- # o = find_child HOST
142
- # return nil unless o
143
-
144
- # o = Gloo::Objs::Alias.resolve_alias( @engine, o )
145
- # return o.value
146
- # end
147
-
148
- # #
149
- # # Get the Database name from the child object.
150
- # # Returns nil if there is none.
151
- # #
152
- # def db_value
153
- # o = find_child DB
154
- # return nil unless o
155
-
156
- # o = Gloo::Objs::Alias.resolve_alias( @engine, o )
157
- # return o.value
158
- # end
159
-
160
- # #
161
- # # Get the Username from the child object.
162
- # # Returns nil if there is none.
163
- # #
164
- # def user_value
165
- # o = find_child USER
166
- # return nil unless o
167
-
168
- # o = Gloo::Objs::Alias.resolve_alias( @engine, o )
169
- # return o.value
170
- # end
171
-
172
- # #
173
- # # Get the Password name from the child object.
174
- # # Returns nil if there is none.
175
- # #
176
- # def passwd_value
177
- # o = find_child PASSWD
178
- # return nil unless o
179
-
180
- # o = Gloo::Objs::Alias.resolve_alias( @engine, o )
181
- # return o.value
182
- # end
183
-
184
- # #
185
- # # Try the connection and make sure it works.
186
- # # Returns true if we can establish a connection.
187
- # #
188
- # def connects?
189
- # begin
190
- # result = pg_conn.exec( "SELECT NOW()" )
191
- # rescue => e
192
- # @engine.log_exception e
193
- # @engine.heap.it.set_to false
194
- # return false
195
- # end
196
- # return true
197
- # end
198
-
199
- # #
200
- # # Get the PG connection.
201
- # #
202
- # def pg_conn
203
- # if host_value
204
- # conn = PG.connect(
205
- # host_value, 5432, '', '',
206
- # db_value,
207
- # user_value,
208
- # passwd_value )
209
- # else
210
- # conn = PG.connect( dbname: db_value )
211
- # end
212
- # end
213
-
214
- # end
215
- # end
216
- # end