gloo 4.6.1 → 4.7.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.
- checksums.yaml +4 -4
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +5 -0
- data/lib/gloo/app/engine.rb +7 -1
- data/lib/gloo/app/settings.rb +5 -1
- data/lib/gloo/core/dictionary.rb +2 -0
- data/lib/gloo/ext/base.rb +19 -0
- data/lib/gloo/ext/callback.rb +34 -0
- data/lib/gloo/ext/manager.rb +90 -0
- data/lib/gloo/verbs/help.rb +30 -1
- data/lib/gloo/verbs/load.rb +43 -5
- metadata +5 -7
- data/lib/gloo/objs/data/pg.rb +0 -216
- data/lib/gloo/objs/web/slack.rb +0 -130
- data/lib/gloo/objs/web/teams.rb +0 -117
- data/lib/gloo/verbs/alert.rb +0 -79
- data/lib/gloo/verbs/beep.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce59cd8b3b1d064619f053e725f84531a53587ff1ded7c96d34ef6c7970b4790
|
|
4
|
+
data.tar.gz: 592bb098d11801db860648841f30718b7ef1ede6929ddd230fbae82221b3e97d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b72b4200ad1115f0f74e7df0532370f9c33621d70dd20e50a912da03a86a26c63a57d1911baf110754305af0ce92cf770434bb72c8edcee6f6dcd6b6ad395bcb
|
|
7
|
+
data.tar.gz: fcf2d0e68d0b5eddbcfafae93c99686ed11dac85e8f5e1277dc31cbfdf575a7190fb3a726c320bce6cb3606a717b12bb0fb4c04b0931efd6a57a36524ee12fb4
|
data/lib/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.7.0
|
data/lib/VERSION_NOTES
CHANGED
data/lib/gloo/app/engine.rb
CHANGED
|
@@ -13,7 +13,8 @@ module Gloo
|
|
|
13
13
|
|
|
14
14
|
attr_reader :settings, :log, :running_app
|
|
15
15
|
attr_reader :args, :mode, :running, :platform,
|
|
16
|
-
:dictionary, :parser, :heap, :factory
|
|
16
|
+
:dictionary, :parser, :heap, :factory,
|
|
17
|
+
:ext_manager
|
|
17
18
|
attr_accessor :last_cmd, :persist_man, :event_manager,
|
|
18
19
|
:exec_env, :converter
|
|
19
20
|
|
|
@@ -50,6 +51,7 @@ module Gloo
|
|
|
50
51
|
@factory = Gloo::Core::Factory.new( self )
|
|
51
52
|
@persist_man = Gloo::Persist::PersistMan.new( self )
|
|
52
53
|
@event_manager = Gloo::Core::EventManager.new( self )
|
|
54
|
+
@ext_manager = Gloo::Ext::Manager.new( self )
|
|
53
55
|
|
|
54
56
|
@exec_env = Gloo::Exec::ExecEnv.new( self )
|
|
55
57
|
@converter = Gloo::Convert::Converter.new( self )
|
|
@@ -58,6 +60,7 @@ module Gloo
|
|
|
58
60
|
run_mode
|
|
59
61
|
end
|
|
60
62
|
|
|
63
|
+
|
|
61
64
|
# ---------------------------------------------------------------------
|
|
62
65
|
# Serialization
|
|
63
66
|
# ---------------------------------------------------------------------
|
|
@@ -94,6 +97,7 @@ module Gloo
|
|
|
94
97
|
@log.restore_after_deserialization
|
|
95
98
|
end
|
|
96
99
|
|
|
100
|
+
|
|
97
101
|
# ---------------------------------------------------------------------
|
|
98
102
|
# Run
|
|
99
103
|
# ---------------------------------------------------------------------
|
|
@@ -227,6 +231,7 @@ module Gloo
|
|
|
227
231
|
@log.info 'Gloo engine is quitting...'
|
|
228
232
|
end
|
|
229
233
|
|
|
234
|
+
|
|
230
235
|
# ---------------------------------------------------------------------
|
|
231
236
|
# Running app within gloo
|
|
232
237
|
# ---------------------------------------------------------------------
|
|
@@ -267,6 +272,7 @@ module Gloo
|
|
|
267
272
|
quit
|
|
268
273
|
end
|
|
269
274
|
|
|
275
|
+
|
|
270
276
|
# ---------------------------------------------------------------------
|
|
271
277
|
# Error Handling
|
|
272
278
|
# ---------------------------------------------------------------------
|
data/lib/gloo/app/settings.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Gloo
|
|
|
11
11
|
class Settings
|
|
12
12
|
|
|
13
13
|
attr_reader :user_root, :log_path,
|
|
14
|
-
:config_path, :project_path,
|
|
14
|
+
:config_path, :project_path, :ext_path,
|
|
15
15
|
:start_with, :list_indent, :list_levels, :tmp_path,
|
|
16
16
|
:debug_path, :debug
|
|
17
17
|
|
|
@@ -50,6 +50,7 @@ module Gloo
|
|
|
50
50
|
puts "\n Application Paths:".blue
|
|
51
51
|
puts ' User Root Path is here: '.yellow + @user_root.white
|
|
52
52
|
puts ' Projects Path: '.yellow + @project_path.white
|
|
53
|
+
puts ' Extensions Path: '.yellow + @ext_path.white
|
|
53
54
|
puts ' Tmp Path: '.yellow + @tmp_path.white
|
|
54
55
|
puts ' Debug Path: '.yellow + @debug_path.white
|
|
55
56
|
puts "\n"
|
|
@@ -131,6 +132,9 @@ module Gloo
|
|
|
131
132
|
@config_path = File.join( @user_root, 'config' )
|
|
132
133
|
Dir.mkdir( @config_path ) unless File.exist?( @config_path )
|
|
133
134
|
|
|
135
|
+
@ext_path = File.join( @user_root, 'extensions' )
|
|
136
|
+
Dir.mkdir( @ext_path ) unless File.exist?( @ext_path )
|
|
137
|
+
|
|
134
138
|
@tmp_path = File.join( @user_root, 'tmp' )
|
|
135
139
|
Dir.mkdir( @tmp_path ) unless File.exist?( @tmp_path )
|
|
136
140
|
|
data/lib/gloo/core/dictionary.rb
CHANGED
|
@@ -138,6 +138,7 @@ module Gloo
|
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
|
|
141
142
|
# ---------------------------------------------------------------------
|
|
142
143
|
# Register after start up
|
|
143
144
|
# ---------------------------------------------------------------------
|
|
@@ -178,6 +179,7 @@ module Gloo
|
|
|
178
179
|
@keywords.delete( obj_class.short_typename )
|
|
179
180
|
end
|
|
180
181
|
|
|
182
|
+
|
|
181
183
|
# ---------------------------------------------------------------------
|
|
182
184
|
# Private
|
|
183
185
|
# ---------------------------------------------------------------------
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A Base class for extensions.
|
|
3
|
+
# Used by extensions to register verbs and objects.
|
|
4
|
+
#
|
|
5
|
+
module Gloo
|
|
6
|
+
module Ext
|
|
7
|
+
class Base
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# Register verbs and objects.
|
|
11
|
+
#
|
|
12
|
+
def register( callback )
|
|
13
|
+
raise NotImplementedError, "Extensions must implement register method"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#
|
|
2
|
+
# A mechanism for registering extension components.
|
|
3
|
+
#
|
|
4
|
+
module Gloo
|
|
5
|
+
module Ext
|
|
6
|
+
class Callback
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Initialize the callback.
|
|
10
|
+
#
|
|
11
|
+
def initialize( engine )
|
|
12
|
+
@engine = engine
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Register a verb.
|
|
17
|
+
#
|
|
18
|
+
def register_verb( verb_class )
|
|
19
|
+
@engine.log.debug "Registering verb: #{verb_class} from callbackup helper"
|
|
20
|
+
@engine.dictionary.register_verb_post_start( verb_class )
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Register an object.
|
|
25
|
+
#
|
|
26
|
+
def register_obj( object_class )
|
|
27
|
+
@engine.log.debug "Registering object: #{object_class} from callback helper"
|
|
28
|
+
@engine.dictionary.register_obj_post_start( object_class )
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2026 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# The Extension Manager.
|
|
5
|
+
# Load extensions as needed and register their verbs and objects.
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
module Gloo
|
|
9
|
+
module Ext
|
|
10
|
+
class Manager
|
|
11
|
+
|
|
12
|
+
# Constants for extension management
|
|
13
|
+
EXT_FILE = '_ext.rb'
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Set up the extension manager.
|
|
17
|
+
#
|
|
18
|
+
def initialize( engine )
|
|
19
|
+
@engine = engine
|
|
20
|
+
@extensions = {}
|
|
21
|
+
@engine.log.debug 'extension manager intialized...'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Get the loaded extensions.
|
|
26
|
+
#
|
|
27
|
+
def loaded_extensions
|
|
28
|
+
return @extensions
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Get the start file for the extension.
|
|
33
|
+
#
|
|
34
|
+
def ext_start_file name
|
|
35
|
+
root = @engine.settings.ext_path
|
|
36
|
+
|
|
37
|
+
unless File.exist?( root )
|
|
38
|
+
@engine.log.error "Extension directory does not exist: #{root}"
|
|
39
|
+
return nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
f = File.join( root, name, name + EXT_FILE )
|
|
43
|
+
unless File.exist?( f )
|
|
44
|
+
@engine.log.error "Extension start file does not exist: #{f}"
|
|
45
|
+
return nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
return f
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Load the extension of the given name.
|
|
53
|
+
# The name will correspond with the name of a directory
|
|
54
|
+
# within the gloo extensions directory.
|
|
55
|
+
#
|
|
56
|
+
def load_ext( name )
|
|
57
|
+
@engine.log.debug "Loading extension: #{name}"
|
|
58
|
+
fn = ext_start_file name
|
|
59
|
+
|
|
60
|
+
unless fn
|
|
61
|
+
@engine.log.error "Extension start file not found for: #{name}"
|
|
62
|
+
return
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@extensions[name] = fn
|
|
66
|
+
register_extension name, fn
|
|
67
|
+
@engine.log.debug "Extension loaded: #{name}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# Give the extension a chance to register its verbs and objects.
|
|
72
|
+
#
|
|
73
|
+
def register_extension( name, full_path )
|
|
74
|
+
require full_path
|
|
75
|
+
|
|
76
|
+
class_name = name.capitalize + "Ext"
|
|
77
|
+
@engine.log.debug "Looking for extension to register: #{class_name}"
|
|
78
|
+
begin
|
|
79
|
+
plugin_class = Object.const_get( class_name )
|
|
80
|
+
inst = plugin_class.new
|
|
81
|
+
ext_cb = Callback.new( @engine )
|
|
82
|
+
inst.register( ext_cb )
|
|
83
|
+
rescue NameError
|
|
84
|
+
@engine.log.error "Warning: Could not find class #{class_name} in file #{full_path}"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
data/lib/gloo/verbs/help.rb
CHANGED
|
@@ -22,7 +22,11 @@ module Gloo
|
|
|
22
22
|
o: 'show_objs',
|
|
23
23
|
obj: 'show_objs',
|
|
24
24
|
object: 'show_objs',
|
|
25
|
-
objects: 'show_objs'
|
|
25
|
+
objects: 'show_objs',
|
|
26
|
+
e: 'show_ext',
|
|
27
|
+
ext: 'show_ext',
|
|
28
|
+
extension: 'show_ext',
|
|
29
|
+
extensions: 'show_ext'
|
|
26
30
|
}.freeze
|
|
27
31
|
|
|
28
32
|
#
|
|
@@ -91,6 +95,7 @@ module Gloo
|
|
|
91
95
|
data << " Help Options:\n"
|
|
92
96
|
data << " ? objects (obj, o) \n"
|
|
93
97
|
data << " ? verbs (v) \n"
|
|
98
|
+
data << " ? ext (e) \n"
|
|
94
99
|
data << " ? settings (s) \n"
|
|
95
100
|
data << "\n For detailed documentation use the gloo website. \n"
|
|
96
101
|
data << "\n https://gloo.ecrane.us/doc/. \n\n"
|
|
@@ -181,6 +186,30 @@ module Gloo
|
|
|
181
186
|
return str
|
|
182
187
|
end
|
|
183
188
|
|
|
189
|
+
#
|
|
190
|
+
# List the extensions
|
|
191
|
+
#
|
|
192
|
+
def show_ext
|
|
193
|
+
data = "\n"
|
|
194
|
+
data << " Extensions\n".blue
|
|
195
|
+
data << "#{get_extensions}\n\n"
|
|
196
|
+
@engine.log.show data
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
#
|
|
200
|
+
# Get the text for the list of extensions.
|
|
201
|
+
#
|
|
202
|
+
def get_extensions
|
|
203
|
+
str = ''
|
|
204
|
+
exts = @engine.ext_manager.loaded_extensions.sort
|
|
205
|
+
exts.each do |name, ext|
|
|
206
|
+
str << " #{name.white} \n"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
return str
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
|
|
184
213
|
end
|
|
185
214
|
end
|
|
186
215
|
end
|
data/lib/gloo/verbs/load.rb
CHANGED
|
@@ -11,18 +11,40 @@ module Gloo
|
|
|
11
11
|
KEYWORD = 'load'.freeze
|
|
12
12
|
KEYWORD_SHORT = 'ld'.freeze
|
|
13
13
|
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
|
14
|
+
UNKNOWN_OPT_ERR = 'Unknown load option!'.freeze
|
|
15
|
+
WRONG_NUM_ARGS_ERR = 'Wrong number of arguments! 2 or 3 expected.'.freeze
|
|
16
|
+
FEATURE_NOT_IMPLEMENTED_ERR = 'Feature not implemented yet!'.freeze
|
|
17
|
+
|
|
18
|
+
FILE_OPT = 'file'.freeze
|
|
19
|
+
EXT_OPT = 'ext'.freeze
|
|
20
|
+
LIB_OPT = 'lib'.freeze
|
|
14
21
|
|
|
15
22
|
#
|
|
16
23
|
# Run the verb.
|
|
17
24
|
#
|
|
18
25
|
def run
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@
|
|
26
|
+
if @tokens.token_count == 2
|
|
27
|
+
opt = FILE_OPT
|
|
28
|
+
fn = @tokens.second
|
|
29
|
+
elsif @tokens.token_count == 3
|
|
30
|
+
opt = @tokens.second.strip.downcase
|
|
31
|
+
fn = @tokens.last
|
|
24
32
|
else
|
|
33
|
+
@engine.err WRONG_NUM_ARGS_ERR
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if fn.blank?
|
|
25
38
|
@engine.err MISSING_EXPR_ERR
|
|
39
|
+
elsif opt == FILE_OPT
|
|
40
|
+
load_gloo_file fn
|
|
41
|
+
elsif opt == EXT_OPT
|
|
42
|
+
load_extension fn
|
|
43
|
+
elsif opt == LIB_OPT
|
|
44
|
+
# TODO: implement library loading
|
|
45
|
+
@engine.err FEATURE_NOT_IMPLEMENTED_ERR
|
|
46
|
+
else
|
|
47
|
+
@engine.err UNKNOWN_OPT_ERR
|
|
26
48
|
end
|
|
27
49
|
end
|
|
28
50
|
|
|
@@ -40,6 +62,22 @@ module Gloo
|
|
|
40
62
|
return KEYWORD_SHORT
|
|
41
63
|
end
|
|
42
64
|
|
|
65
|
+
#
|
|
66
|
+
# Load a gloo file
|
|
67
|
+
#
|
|
68
|
+
def load_gloo_file( fn )
|
|
69
|
+
@engine.log.debug "Getting ready to load gloo file: #{fn}"
|
|
70
|
+
@engine.persist_man.load fn
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Load an extension
|
|
75
|
+
#
|
|
76
|
+
def load_extension( name )
|
|
77
|
+
@engine.log.debug "Getting ready to load extension: #{name}"
|
|
78
|
+
@engine.ext_manager.load_ext name
|
|
79
|
+
end
|
|
80
|
+
|
|
43
81
|
end
|
|
44
82
|
end
|
|
45
83
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gloo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Crane
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -428,6 +428,9 @@ files:
|
|
|
428
428
|
- lib/gloo/expr/op_minus.rb
|
|
429
429
|
- lib/gloo/expr/op_mult.rb
|
|
430
430
|
- lib/gloo/expr/op_plus.rb
|
|
431
|
+
- lib/gloo/ext/base.rb
|
|
432
|
+
- lib/gloo/ext/callback.rb
|
|
433
|
+
- lib/gloo/ext/manager.rb
|
|
431
434
|
- lib/gloo/objs/basic/alias.rb
|
|
432
435
|
- lib/gloo/objs/basic/boolean.rb
|
|
433
436
|
- lib/gloo/objs/basic/container.rb
|
|
@@ -455,7 +458,6 @@ files:
|
|
|
455
458
|
- lib/gloo/objs/data/markdown.rb
|
|
456
459
|
- lib/gloo/objs/data/markdown_ext.rb
|
|
457
460
|
- lib/gloo/objs/data/mysql.rb
|
|
458
|
-
- lib/gloo/objs/data/pg.rb
|
|
459
461
|
- lib/gloo/objs/data/query.rb
|
|
460
462
|
- lib/gloo/objs/data/query_result.rb
|
|
461
463
|
- lib/gloo/objs/data/sqlite.rb
|
|
@@ -478,8 +480,6 @@ files:
|
|
|
478
480
|
- lib/gloo/objs/web/http_get.rb
|
|
479
481
|
- lib/gloo/objs/web/http_post.rb
|
|
480
482
|
- lib/gloo/objs/web/json.rb
|
|
481
|
-
- lib/gloo/objs/web/slack.rb
|
|
482
|
-
- lib/gloo/objs/web/teams.rb
|
|
483
483
|
- lib/gloo/objs/web/uri.rb
|
|
484
484
|
- lib/gloo/objs/web_svr/element.rb
|
|
485
485
|
- lib/gloo/objs/web_svr/field.rb
|
|
@@ -496,8 +496,6 @@ files:
|
|
|
496
496
|
- lib/gloo/utils/format.rb
|
|
497
497
|
- lib/gloo/utils/stats.rb
|
|
498
498
|
- lib/gloo/utils/words.rb
|
|
499
|
-
- lib/gloo/verbs/alert.rb
|
|
500
|
-
- lib/gloo/verbs/beep.rb
|
|
501
499
|
- lib/gloo/verbs/break.rb
|
|
502
500
|
- lib/gloo/verbs/check.rb
|
|
503
501
|
- lib/gloo/verbs/cls.rb
|
data/lib/gloo/objs/data/pg.rb
DELETED
|
@@ -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
|
data/lib/gloo/objs/web/slack.rb
DELETED
|
@@ -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
|
data/lib/gloo/objs/web/teams.rb
DELETED
|
@@ -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
|
data/lib/gloo/verbs/alert.rb
DELETED
|
@@ -1,79 +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 system notification.
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
module Gloo
|
|
8
|
-
module Verbs
|
|
9
|
-
class Alert < Gloo::Core::Verb
|
|
10
|
-
|
|
11
|
-
KEYWORD = 'alert'.freeze
|
|
12
|
-
KEYWORD_SHORT = '!'.freeze
|
|
13
|
-
|
|
14
|
-
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
|
15
|
-
NO_RESULT_ERR = 'Expression evaluated with no result!'.freeze
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
# Run the verb.
|
|
19
|
-
#
|
|
20
|
-
def run
|
|
21
|
-
unless @tokens.token_count > 1
|
|
22
|
-
@engine.err MISSING_EXPR_ERR
|
|
23
|
-
return
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
expr = Gloo::Expr::Expression.new( @engine, @tokens.params )
|
|
27
|
-
result = expr.evaluate
|
|
28
|
-
|
|
29
|
-
if result
|
|
30
|
-
@engine.heap.it.set_to result
|
|
31
|
-
post_alert result
|
|
32
|
-
else
|
|
33
|
-
@engine.err NO_RESULT_ERR
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
# Get the Verb's keyword.
|
|
39
|
-
#
|
|
40
|
-
def self.keyword
|
|
41
|
-
return KEYWORD
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
# Get the Verb's keyword shortcut.
|
|
46
|
-
#
|
|
47
|
-
def self.keyword_shortcut
|
|
48
|
-
return KEYWORD_SHORT
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# ---------------------------------------------------------------------
|
|
52
|
-
# Private functions
|
|
53
|
-
# ---------------------------------------------------------------------
|
|
54
|
-
|
|
55
|
-
private
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
# Post the alert for the specific platform.
|
|
59
|
-
# Notice is not posted if we're in quiet mode.
|
|
60
|
-
#
|
|
61
|
-
def post_alert( msg )
|
|
62
|
-
@engine.log.info msg
|
|
63
|
-
return if @engine.args.quiet?
|
|
64
|
-
|
|
65
|
-
post_osx msg
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
#
|
|
69
|
-
# Post the alert on the Mac OSX.
|
|
70
|
-
#
|
|
71
|
-
def post_osx( msg )
|
|
72
|
-
cmd1 = '/usr/bin/osascript -e "display notification \"'
|
|
73
|
-
cmd2 = '\" with title \"Gloo\" "'
|
|
74
|
-
system( cmd1 + msg.to_s + cmd2 )
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
data/lib/gloo/verbs/beep.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
-
#
|
|
4
|
-
# Play a standard system beep sound.
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
module Gloo
|
|
8
|
-
module Verbs
|
|
9
|
-
class Beep < Gloo::Core::Verb
|
|
10
|
-
|
|
11
|
-
KEYWORD = 'beep'.freeze
|
|
12
|
-
KEYWORD_SHORT = 'b'.freeze
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
# Run the verb.
|
|
16
|
-
#
|
|
17
|
-
# We'll mark the application as not running and let the
|
|
18
|
-
# engine stop gracefully next time through the loop.
|
|
19
|
-
#
|
|
20
|
-
def run
|
|
21
|
-
print 7.chr
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
# Get the Verb's keyword.
|
|
26
|
-
#
|
|
27
|
-
def self.keyword
|
|
28
|
-
return KEYWORD
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
# Get the Verb's keyword shortcut.
|
|
33
|
-
#
|
|
34
|
-
def self.keyword_shortcut
|
|
35
|
-
return KEYWORD_SHORT
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|