gloo 1.4.2 → 2.0.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/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/gloo.gemspec +0 -2
- data/lib/VERSION +1 -1
- data/lib/dependencies.rb +4 -4
- data/lib/gloo/app/args.rb +112 -0
- data/lib/gloo/app/engine.rb +247 -0
- data/lib/gloo/app/engine_context.rb +25 -0
- data/lib/gloo/app/info.rb +20 -3
- data/lib/gloo/app/log.rb +73 -1
- data/lib/gloo/app/mode.rb +27 -0
- data/lib/gloo/app/platform.rb +8 -1
- data/lib/gloo/app/settings.rb +202 -0
- data/lib/gloo/convert/converter.rb +42 -0
- data/lib/gloo/convert/string_to_date.rb +21 -0
- data/lib/gloo/convert/string_to_datetime.rb +21 -0
- data/lib/gloo/convert/string_to_decimal.rb +20 -0
- data/lib/gloo/convert/string_to_integer.rb +20 -0
- data/lib/gloo/convert/string_to_time.rb +21 -0
- data/lib/gloo/core/baseo.rb +31 -0
- data/lib/gloo/core/dictionary.rb +245 -0
- data/lib/gloo/core/error.rb +61 -0
- data/lib/gloo/core/event_manager.rb +45 -0
- data/lib/gloo/core/factory.rb +211 -0
- data/lib/gloo/core/gloo_system.rb +267 -0
- data/lib/gloo/core/heap.rb +53 -0
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +36 -0
- data/lib/gloo/core/literal.rb +30 -0
- data/lib/gloo/core/obj.rb +318 -0
- data/lib/gloo/core/obj_finder.rb +30 -0
- data/lib/gloo/core/op.rb +40 -0
- data/lib/gloo/core/parser.rb +60 -0
- data/lib/gloo/core/pn.rb +212 -0
- data/lib/gloo/core/tokens.rb +165 -0
- data/lib/gloo/core/verb.rb +87 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +40 -0
- data/lib/gloo/exec/exec_env.rb +75 -0
- data/lib/gloo/exec/runner.rb +45 -0
- data/lib/gloo/exec/script.rb +50 -0
- data/lib/gloo/exec/stack.rb +79 -0
- data/lib/gloo/expr/expression.rb +119 -0
- data/lib/gloo/expr/l_boolean.rb +36 -0
- data/lib/gloo/expr/l_decimal.rb +39 -0
- data/lib/gloo/expr/l_integer.rb +37 -0
- data/lib/gloo/expr/l_string.rb +58 -0
- data/lib/gloo/expr/op_div.rb +22 -0
- data/lib/gloo/expr/op_minus.rb +22 -0
- data/lib/gloo/expr/op_mult.rb +22 -0
- data/lib/gloo/expr/op_plus.rb +24 -0
- data/lib/gloo/objs/basic/alias.rb +78 -0
- data/lib/gloo/objs/basic/boolean.rb +120 -0
- data/lib/gloo/objs/basic/container.rb +65 -0
- data/lib/gloo/objs/basic/decimal.rb +76 -0
- data/lib/gloo/objs/basic/integer.rb +73 -0
- data/lib/gloo/objs/basic/script.rb +99 -0
- data/lib/gloo/objs/basic/string.rb +77 -0
- data/lib/gloo/objs/basic/text.rb +79 -0
- data/lib/gloo/objs/basic/untyped.rb +41 -0
- data/lib/gloo/objs/cli/banner.rb +1 -1
- data/lib/gloo/objs/cli/bar.rb +3 -3
- data/lib/gloo/objs/cli/colorize.rb +1 -1
- data/lib/gloo/objs/cli/confirm.rb +1 -1
- data/lib/gloo/objs/cli/menu.rb +6 -6
- data/lib/gloo/objs/cli/menu_item.rb +1 -1
- data/lib/gloo/objs/cli/pastel.rb +1 -1
- data/lib/gloo/objs/cli/prompt.rb +1 -1
- data/lib/gloo/objs/cli/select.rb +2 -2
- data/lib/gloo/objs/ctrl/each.rb +279 -0
- data/lib/gloo/objs/ctrl/repeat.rb +108 -0
- data/lib/gloo/objs/data/markdown.rb +79 -0
- data/lib/gloo/objs/data/mysql.rb +5 -5
- data/lib/gloo/objs/data/query.rb +4 -4
- data/lib/gloo/objs/data/sqlite.rb +1 -1
- data/lib/gloo/objs/data/table.rb +112 -0
- data/lib/gloo/objs/dev/git.rb +2 -2
- data/lib/gloo/objs/dev/stats.rb +4 -4
- data/lib/gloo/objs/dt/date.rb +65 -0
- data/lib/gloo/objs/dt/datetime.rb +120 -0
- data/lib/gloo/objs/dt/dt_tools.rb +100 -0
- data/lib/gloo/objs/dt/time.rb +65 -0
- data/lib/gloo/objs/ror/erb.rb +116 -0
- data/lib/gloo/objs/ror/eval.rb +107 -0
- data/lib/gloo/objs/snd/play.rb +1 -1
- data/lib/gloo/objs/snd/say.rb +1 -1
- data/lib/gloo/objs/system/file_handle.rb +4 -4
- data/lib/gloo/objs/system/ssh_exec.rb +1 -1
- data/lib/gloo/objs/system/system.rb +1 -1
- data/lib/gloo/objs/web/http_get.rb +159 -0
- data/lib/gloo/objs/web/http_post.rb +183 -0
- data/lib/gloo/objs/web/json.rb +135 -0
- data/lib/gloo/objs/web/slack.rb +130 -0
- data/lib/gloo/objs/web/teams.rb +117 -0
- data/lib/gloo/objs/web/uri.rb +148 -0
- data/lib/gloo/persist/disc_mech.rb +87 -0
- data/lib/gloo/persist/file_loader.rb +193 -0
- data/lib/gloo/persist/file_saver.rb +51 -0
- data/lib/gloo/persist/file_storage.rb +46 -0
- data/lib/gloo/persist/line_splitter.rb +81 -0
- data/lib/gloo/persist/persist_man.rb +153 -0
- data/lib/gloo/utils/format.rb +21 -0
- data/lib/gloo/utils/stats.rb +206 -0
- data/lib/gloo/utils/words.rb +19 -0
- data/lib/gloo/verbs/alert.rb +2 -2
- data/lib/gloo/verbs/beep.rb +1 -1
- data/lib/gloo/verbs/cls.rb +1 -1
- data/lib/gloo/verbs/context.rb +62 -0
- data/lib/gloo/verbs/create.rb +68 -0
- data/lib/gloo/verbs/execute.rb +56 -0
- data/lib/gloo/verbs/files.rb +49 -0
- data/lib/gloo/verbs/help.rb +1 -1
- data/lib/gloo/verbs/if.rb +92 -0
- data/lib/gloo/verbs/list.rb +98 -0
- data/lib/gloo/verbs/load.rb +45 -0
- data/lib/gloo/verbs/move.rb +89 -0
- data/lib/gloo/verbs/put.rb +94 -0
- data/lib/gloo/verbs/quit.rb +40 -0
- data/lib/gloo/verbs/reload.rb +43 -0
- data/lib/gloo/verbs/run.rb +75 -0
- data/lib/gloo/verbs/save.rb +39 -0
- data/lib/gloo/verbs/show.rb +63 -0
- data/lib/gloo/verbs/tell.rb +80 -0
- data/lib/gloo/verbs/unless.rb +92 -0
- data/lib/gloo/verbs/unload.rb +46 -0
- data/lib/gloo/verbs/version.rb +3 -3
- data/lib/gloo/verbs/wait.rb +42 -0
- data/lib/gloo.rb +2 -2
- data/lib/run.rb +2 -2
- metadata +97 -22
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A looping construct...do something for each whatever in something.
|
|
5
|
+
# This object has several possible uses:
|
|
6
|
+
# - each word in a string
|
|
7
|
+
# - each line in a string
|
|
8
|
+
# - each file in a directory
|
|
9
|
+
# - each git repo in a directory
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
module Gloo
|
|
13
|
+
module Objs
|
|
14
|
+
class Each < Gloo::Core::Obj
|
|
15
|
+
|
|
16
|
+
KEYWORD = 'each'.freeze
|
|
17
|
+
KEYWORD_SHORT = 'each'.freeze
|
|
18
|
+
CHILD = 'child'.freeze
|
|
19
|
+
WORD = 'word'.freeze
|
|
20
|
+
LINE = 'line'.freeze
|
|
21
|
+
FILE = 'file'.freeze
|
|
22
|
+
REPO = 'repo'.freeze
|
|
23
|
+
IN = 'IN'.freeze
|
|
24
|
+
DO = 'do'.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 in_value
|
|
45
|
+
o = find_child IN
|
|
46
|
+
return o ? o.value : nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Run the do script once.
|
|
51
|
+
#
|
|
52
|
+
def run_do
|
|
53
|
+
o = find_child DO
|
|
54
|
+
return unless o
|
|
55
|
+
|
|
56
|
+
Gloo::Exec::Dispatch.message( @engine, 'run', o )
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# ---------------------------------------------------------------------
|
|
60
|
+
# Children
|
|
61
|
+
# ---------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# Does this object have children to add when an object
|
|
65
|
+
# is created in interactive mode?
|
|
66
|
+
# This does not apply during obj load, etc.
|
|
67
|
+
#
|
|
68
|
+
def add_children_on_create?
|
|
69
|
+
return true
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# Add children to this object.
|
|
74
|
+
# This is used by containers to add children needed
|
|
75
|
+
# for default configurations.
|
|
76
|
+
#
|
|
77
|
+
def add_default_children
|
|
78
|
+
fac = @engine.factory
|
|
79
|
+
fac.create_string WORD, '', self
|
|
80
|
+
fac.create_string IN, '', self
|
|
81
|
+
fac.create_script DO, '', self
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# ---------------------------------------------------------------------
|
|
85
|
+
# Messages
|
|
86
|
+
# ---------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# Get a list of message names that this object receives.
|
|
90
|
+
#
|
|
91
|
+
def self.messages
|
|
92
|
+
return super + [ 'run' ]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Run the system command.
|
|
96
|
+
def msg_run
|
|
97
|
+
if each_child?
|
|
98
|
+
run_each_child
|
|
99
|
+
elsif each_word?
|
|
100
|
+
run_each_word
|
|
101
|
+
elsif each_line?
|
|
102
|
+
run_each_line
|
|
103
|
+
elsif each_repo?
|
|
104
|
+
run_each_repo
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# ---------------------------------------------------------------------
|
|
109
|
+
# Child Object
|
|
110
|
+
# ---------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
#
|
|
113
|
+
# Is it set up to run for each word?
|
|
114
|
+
# If there is a child object by the name "word"
|
|
115
|
+
# then we will loop for each word in the string.
|
|
116
|
+
#
|
|
117
|
+
def each_child?
|
|
118
|
+
return true if contains_child? CHILD
|
|
119
|
+
|
|
120
|
+
return false
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# Run for each word.
|
|
125
|
+
#
|
|
126
|
+
def run_each_child
|
|
127
|
+
o = find_child IN
|
|
128
|
+
return unless o
|
|
129
|
+
|
|
130
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
131
|
+
o.children.each do |child|
|
|
132
|
+
set_child child
|
|
133
|
+
run_do
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
#
|
|
138
|
+
# Set the child alias.
|
|
139
|
+
#
|
|
140
|
+
def set_child( obj )
|
|
141
|
+
o = find_child CHILD
|
|
142
|
+
return unless o
|
|
143
|
+
|
|
144
|
+
o.set_value obj.pn
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# ---------------------------------------------------------------------
|
|
148
|
+
# Word
|
|
149
|
+
# ---------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
#
|
|
152
|
+
# Is it set up to run for each word?
|
|
153
|
+
# If there is a child object by the name "word"
|
|
154
|
+
# then we will loop for each word in the string.
|
|
155
|
+
#
|
|
156
|
+
def each_word?
|
|
157
|
+
return true if find_child WORD
|
|
158
|
+
|
|
159
|
+
return false
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
#
|
|
163
|
+
# Run for each word.
|
|
164
|
+
#
|
|
165
|
+
def run_each_word
|
|
166
|
+
str = in_value
|
|
167
|
+
return unless str
|
|
168
|
+
|
|
169
|
+
str.split( ' ' ).each do |word|
|
|
170
|
+
set_word word
|
|
171
|
+
run_do
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
#
|
|
176
|
+
# Set the value of the word.
|
|
177
|
+
#
|
|
178
|
+
def set_word( word )
|
|
179
|
+
o = find_child WORD
|
|
180
|
+
return unless o
|
|
181
|
+
|
|
182
|
+
o.set_value word
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# ---------------------------------------------------------------------
|
|
186
|
+
# Line
|
|
187
|
+
# ---------------------------------------------------------------------
|
|
188
|
+
|
|
189
|
+
#
|
|
190
|
+
# Is it set up to run for each line?
|
|
191
|
+
# If there is a child object by the name "line"
|
|
192
|
+
# then we will loop for each line in the string.
|
|
193
|
+
#
|
|
194
|
+
def each_line?
|
|
195
|
+
return true if find_child LINE
|
|
196
|
+
|
|
197
|
+
return false
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
#
|
|
201
|
+
# Run for each line.
|
|
202
|
+
#
|
|
203
|
+
def run_each_line
|
|
204
|
+
str = in_value
|
|
205
|
+
return unless str
|
|
206
|
+
|
|
207
|
+
str.each_line do |line|
|
|
208
|
+
set_line line
|
|
209
|
+
run_do
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
#
|
|
214
|
+
# Set the value of the word.
|
|
215
|
+
#
|
|
216
|
+
def set_line( line )
|
|
217
|
+
o = find_child LINE
|
|
218
|
+
return unless o
|
|
219
|
+
|
|
220
|
+
o.set_value line
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# ---------------------------------------------------------------------
|
|
224
|
+
# Git Repo
|
|
225
|
+
# ---------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
#
|
|
228
|
+
# Is it set up to run for each git repo?
|
|
229
|
+
# If there is a child object by the name "repo"
|
|
230
|
+
# then we will loop for each repo in the directory.
|
|
231
|
+
#
|
|
232
|
+
def each_repo?
|
|
233
|
+
return true if find_child REPO
|
|
234
|
+
|
|
235
|
+
return false
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
#
|
|
239
|
+
# Find all git projects in a path.
|
|
240
|
+
#
|
|
241
|
+
def find_all_git_projects( path )
|
|
242
|
+
path.children.collect do |f|
|
|
243
|
+
if f.directory? && ( File.basename( f ) == '.git' )
|
|
244
|
+
File.dirname( f )
|
|
245
|
+
elsif f.directory?
|
|
246
|
+
find_all_git_projects( f )
|
|
247
|
+
end
|
|
248
|
+
end.flatten.compact
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
#
|
|
252
|
+
# Run for each line.
|
|
253
|
+
#
|
|
254
|
+
def run_each_repo
|
|
255
|
+
path = in_value
|
|
256
|
+
return unless path
|
|
257
|
+
|
|
258
|
+
path = Pathname.new( path )
|
|
259
|
+
repos = find_all_git_projects( path )
|
|
260
|
+
repos.each do |o|
|
|
261
|
+
set_repo o
|
|
262
|
+
run_do
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
#
|
|
267
|
+
# Set the value of the repo.
|
|
268
|
+
# This is a path to the repo.
|
|
269
|
+
#
|
|
270
|
+
def set_repo( path )
|
|
271
|
+
o = find_child REPO
|
|
272
|
+
return unless o
|
|
273
|
+
|
|
274
|
+
o.set_value path
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A looping construct...do something x times.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Objs
|
|
9
|
+
class Repeat < Gloo::Core::Obj
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'repeat'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'repeat'.freeze
|
|
13
|
+
TIMES = 'times'.freeze
|
|
14
|
+
INDEX = 'index'.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 URI from the child object.
|
|
33
|
+
# Returns nil if there is none.
|
|
34
|
+
#
|
|
35
|
+
def times
|
|
36
|
+
o = find_child TIMES
|
|
37
|
+
return o ? o.value : 0
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Run the do script once.
|
|
42
|
+
#
|
|
43
|
+
def run_do
|
|
44
|
+
o = find_child DO
|
|
45
|
+
return unless o
|
|
46
|
+
|
|
47
|
+
Gloo::Exec::Dispatch.message( @engine, 'run', o )
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# Set the index of the current iteration.
|
|
52
|
+
#
|
|
53
|
+
def set_index( index )
|
|
54
|
+
o = find_child INDEX
|
|
55
|
+
return unless o
|
|
56
|
+
|
|
57
|
+
o.set_value index
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# ---------------------------------------------------------------------
|
|
61
|
+
# Children
|
|
62
|
+
# ---------------------------------------------------------------------
|
|
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
|
+
#
|
|
69
|
+
def add_children_on_create?
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Add children to this object.
|
|
75
|
+
# This is used by containers to add children needed
|
|
76
|
+
# for default configurations.
|
|
77
|
+
#
|
|
78
|
+
def add_default_children
|
|
79
|
+
fac = @engine.factory
|
|
80
|
+
fac.create_int TIMES, 0, self
|
|
81
|
+
fac.create_int INDEX, 0, self
|
|
82
|
+
fac.create_script DO, '', self
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# ---------------------------------------------------------------------
|
|
86
|
+
# Messages
|
|
87
|
+
# ---------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# Get a list of message names that this object receives.
|
|
91
|
+
#
|
|
92
|
+
def self.messages
|
|
93
|
+
return super + [ 'run' ]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Run the repeat loop.
|
|
98
|
+
#
|
|
99
|
+
def msg_run
|
|
100
|
+
times.times do |index|
|
|
101
|
+
set_index index
|
|
102
|
+
run_do
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Markdown data.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Objs
|
|
9
|
+
class Markdown < Gloo::Core::Obj
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'markdown'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'md'.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
|
+
# Set the value with any necessary type conversions.
|
|
30
|
+
#
|
|
31
|
+
def set_value( new_value )
|
|
32
|
+
self.value = new_value.to_s
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# Does this object support multi-line values?
|
|
37
|
+
# Initially only true for scripts.
|
|
38
|
+
#
|
|
39
|
+
def multiline_value?
|
|
40
|
+
return false
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Get the number of lines of text.
|
|
45
|
+
#
|
|
46
|
+
def line_count
|
|
47
|
+
return value.split( "\n" ).count
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------------
|
|
51
|
+
# Messages
|
|
52
|
+
# ---------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Get a list of message names that this object receives.
|
|
56
|
+
#
|
|
57
|
+
def self.messages
|
|
58
|
+
return super + %w[show page]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Show the markdown data in the terminal.
|
|
63
|
+
#
|
|
64
|
+
def msg_show
|
|
65
|
+
@engine.platform.show( self.value, true, false )
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
#
|
|
69
|
+
# Show the markdown data in the terminal, paginated.
|
|
70
|
+
#
|
|
71
|
+
def msg_page
|
|
72
|
+
return unless self.value
|
|
73
|
+
|
|
74
|
+
@engine.platform.show( md, true, true )
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
data/lib/gloo/objs/data/mysql.rb
CHANGED
|
@@ -20,7 +20,7 @@ require 'mysql2'
|
|
|
20
20
|
|
|
21
21
|
module Gloo
|
|
22
22
|
module Objs
|
|
23
|
-
class Mysql <
|
|
23
|
+
class Mysql < Gloo::Core::Obj
|
|
24
24
|
|
|
25
25
|
KEYWORD = 'mysql'.freeze
|
|
26
26
|
KEYWORD_SHORT = 'mysql'.freeze
|
|
@@ -148,7 +148,7 @@ module Gloo
|
|
|
148
148
|
o = find_child HOST
|
|
149
149
|
return nil unless o
|
|
150
150
|
|
|
151
|
-
o =
|
|
151
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
152
152
|
return o.value
|
|
153
153
|
end
|
|
154
154
|
|
|
@@ -160,7 +160,7 @@ module Gloo
|
|
|
160
160
|
o = find_child DB
|
|
161
161
|
return nil unless o
|
|
162
162
|
|
|
163
|
-
o =
|
|
163
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
164
164
|
return o.value
|
|
165
165
|
end
|
|
166
166
|
|
|
@@ -172,7 +172,7 @@ module Gloo
|
|
|
172
172
|
o = find_child USER
|
|
173
173
|
return nil unless o
|
|
174
174
|
|
|
175
|
-
o =
|
|
175
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
176
176
|
return o.value
|
|
177
177
|
end
|
|
178
178
|
|
|
@@ -184,7 +184,7 @@ module Gloo
|
|
|
184
184
|
o = find_child PASSWD
|
|
185
185
|
return nil unless o
|
|
186
186
|
|
|
187
|
-
o =
|
|
187
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
188
188
|
return o.value
|
|
189
189
|
end
|
|
190
190
|
|
data/lib/gloo/objs/data/query.rb
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
module Gloo
|
|
9
9
|
module Objs
|
|
10
|
-
class Query <
|
|
10
|
+
class Query < Gloo::Core::Obj
|
|
11
11
|
|
|
12
12
|
KEYWORD = 'query'.freeze
|
|
13
13
|
KEYWORD_SHORT = 'sql'.freeze
|
|
@@ -99,7 +99,7 @@ module Gloo
|
|
|
99
99
|
#
|
|
100
100
|
def db_obj
|
|
101
101
|
o = find_child DB
|
|
102
|
-
return
|
|
102
|
+
return Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
#
|
|
@@ -127,7 +127,7 @@ module Gloo
|
|
|
127
127
|
return unless qr.has_data_to_show?
|
|
128
128
|
|
|
129
129
|
result_can = find_child RESULT
|
|
130
|
-
result_can =
|
|
130
|
+
result_can = Gloo::Objs::Alias.resolve_alias( @engine, result_can )
|
|
131
131
|
|
|
132
132
|
if result_can
|
|
133
133
|
qr.update_result_container result_can
|
|
@@ -149,7 +149,7 @@ module Gloo
|
|
|
149
149
|
|
|
150
150
|
params = []
|
|
151
151
|
o.children.each do |p|
|
|
152
|
-
p =
|
|
152
|
+
p = Gloo::Objs::Alias.resolve_alias( @engine, p )
|
|
153
153
|
params << p.value
|
|
154
154
|
end
|
|
155
155
|
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
|
|
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 list of headers.
|
|
33
|
+
# Returns nil if there is none.
|
|
34
|
+
#
|
|
35
|
+
def headers
|
|
36
|
+
o = find_child HEADERS
|
|
37
|
+
return [] unless o
|
|
38
|
+
|
|
39
|
+
return o.children.map( &:value )
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# Get the list of column names.
|
|
44
|
+
# Returns nil if there is none.
|
|
45
|
+
#
|
|
46
|
+
def columns
|
|
47
|
+
o = find_child HEADERS
|
|
48
|
+
return [] unless o
|
|
49
|
+
|
|
50
|
+
return o.children.map( &:name )
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# Get the list of data elements.
|
|
55
|
+
#
|
|
56
|
+
def data
|
|
57
|
+
o = find_child DATA
|
|
58
|
+
return [] unless o
|
|
59
|
+
|
|
60
|
+
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
|
61
|
+
cols = self.columns
|
|
62
|
+
return o.children.map do |e|
|
|
63
|
+
cols.map { |h| e.find_child( h ).value }
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# ---------------------------------------------------------------------
|
|
68
|
+
# Children
|
|
69
|
+
# ---------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Does this object have children to add when an object
|
|
73
|
+
# is created in interactive mode?
|
|
74
|
+
# This does not apply during obj load, etc.
|
|
75
|
+
#
|
|
76
|
+
def add_children_on_create?
|
|
77
|
+
return true
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Add children to this object.
|
|
82
|
+
# This is used by containers to add children needed
|
|
83
|
+
# for default configurations.
|
|
84
|
+
#
|
|
85
|
+
def add_default_children
|
|
86
|
+
fac = @engine.factory
|
|
87
|
+
fac.create_can HEADERS, self
|
|
88
|
+
fac.create_can DATA, self
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------------
|
|
92
|
+
# Messages
|
|
93
|
+
# ---------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
#
|
|
96
|
+
# Get a list of message names that this object receives.
|
|
97
|
+
#
|
|
98
|
+
def self.messages
|
|
99
|
+
return super + %w[show]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
# Show the table in the CLI.
|
|
104
|
+
#
|
|
105
|
+
def msg_show
|
|
106
|
+
title = self.value
|
|
107
|
+
@engine.platform.show_table headers, data, title
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
data/lib/gloo/objs/dev/git.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
module Gloo
|
|
8
8
|
module Objs
|
|
9
|
-
class Git <
|
|
9
|
+
class Git < Gloo::Core::Obj
|
|
10
10
|
|
|
11
11
|
KEYWORD = 'git_repo'.freeze
|
|
12
12
|
KEYWORD_SHORT = 'git'.freeze
|
|
@@ -77,7 +77,7 @@ module Gloo
|
|
|
77
77
|
path = path_value
|
|
78
78
|
if path_is_dir?( path )
|
|
79
79
|
if @params&.token_count&.positive?
|
|
80
|
-
expr =
|
|
80
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
|
81
81
|
msg = expr.evaluate
|
|
82
82
|
end
|
|
83
83
|
branch = `cd #{path}; git rev-parse --abbrev-ref HEAD`
|