gloo 1.4.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/gloo.gemspec +0 -2
  5. data/lib/VERSION +1 -1
  6. data/lib/dependencies.rb +4 -4
  7. data/lib/gloo/app/args.rb +112 -0
  8. data/lib/gloo/app/engine.rb +247 -0
  9. data/lib/gloo/app/engine_context.rb +25 -0
  10. data/lib/gloo/app/info.rb +20 -3
  11. data/lib/gloo/app/log.rb +73 -1
  12. data/lib/gloo/app/mode.rb +27 -0
  13. data/lib/gloo/app/platform.rb +8 -1
  14. data/lib/gloo/app/settings.rb +202 -0
  15. data/lib/gloo/convert/converter.rb +42 -0
  16. data/lib/gloo/convert/string_to_date.rb +21 -0
  17. data/lib/gloo/convert/string_to_datetime.rb +21 -0
  18. data/lib/gloo/convert/string_to_decimal.rb +20 -0
  19. data/lib/gloo/convert/string_to_integer.rb +20 -0
  20. data/lib/gloo/convert/string_to_time.rb +21 -0
  21. data/lib/gloo/core/baseo.rb +31 -0
  22. data/lib/gloo/core/dictionary.rb +245 -0
  23. data/lib/gloo/core/error.rb +61 -0
  24. data/lib/gloo/core/event_manager.rb +45 -0
  25. data/lib/gloo/core/factory.rb +211 -0
  26. data/lib/gloo/core/gloo_system.rb +267 -0
  27. data/lib/gloo/core/heap.rb +53 -0
  28. data/lib/gloo/core/here.rb +36 -0
  29. data/lib/gloo/core/it.rb +36 -0
  30. data/lib/gloo/core/literal.rb +30 -0
  31. data/lib/gloo/core/obj.rb +318 -0
  32. data/lib/gloo/core/obj_finder.rb +30 -0
  33. data/lib/gloo/core/op.rb +40 -0
  34. data/lib/gloo/core/parser.rb +60 -0
  35. data/lib/gloo/core/pn.rb +212 -0
  36. data/lib/gloo/core/tokens.rb +165 -0
  37. data/lib/gloo/core/verb.rb +87 -0
  38. data/lib/gloo/exec/action.rb +48 -0
  39. data/lib/gloo/exec/dispatch.rb +40 -0
  40. data/lib/gloo/exec/exec_env.rb +75 -0
  41. data/lib/gloo/exec/runner.rb +45 -0
  42. data/lib/gloo/exec/script.rb +50 -0
  43. data/lib/gloo/exec/stack.rb +79 -0
  44. data/lib/gloo/expr/expression.rb +119 -0
  45. data/lib/gloo/expr/l_boolean.rb +36 -0
  46. data/lib/gloo/expr/l_decimal.rb +39 -0
  47. data/lib/gloo/expr/l_integer.rb +37 -0
  48. data/lib/gloo/expr/l_string.rb +58 -0
  49. data/lib/gloo/expr/op_div.rb +22 -0
  50. data/lib/gloo/expr/op_minus.rb +22 -0
  51. data/lib/gloo/expr/op_mult.rb +22 -0
  52. data/lib/gloo/expr/op_plus.rb +24 -0
  53. data/lib/gloo/objs/basic/alias.rb +78 -0
  54. data/lib/gloo/objs/basic/boolean.rb +120 -0
  55. data/lib/gloo/objs/basic/container.rb +65 -0
  56. data/lib/gloo/objs/basic/decimal.rb +76 -0
  57. data/lib/gloo/objs/basic/integer.rb +73 -0
  58. data/lib/gloo/objs/basic/script.rb +99 -0
  59. data/lib/gloo/objs/basic/string.rb +77 -0
  60. data/lib/gloo/objs/basic/text.rb +79 -0
  61. data/lib/gloo/objs/basic/untyped.rb +41 -0
  62. data/lib/gloo/objs/cli/banner.rb +1 -1
  63. data/lib/gloo/objs/cli/bar.rb +3 -3
  64. data/lib/gloo/objs/cli/colorize.rb +1 -1
  65. data/lib/gloo/objs/cli/confirm.rb +1 -1
  66. data/lib/gloo/objs/cli/menu.rb +6 -6
  67. data/lib/gloo/objs/cli/menu_item.rb +1 -1
  68. data/lib/gloo/objs/cli/pastel.rb +1 -1
  69. data/lib/gloo/objs/cli/prompt.rb +1 -1
  70. data/lib/gloo/objs/cli/select.rb +2 -2
  71. data/lib/gloo/objs/ctrl/each.rb +279 -0
  72. data/lib/gloo/objs/ctrl/repeat.rb +108 -0
  73. data/lib/gloo/objs/data/markdown.rb +79 -0
  74. data/lib/gloo/objs/data/mysql.rb +5 -5
  75. data/lib/gloo/objs/data/query.rb +4 -4
  76. data/lib/gloo/objs/data/sqlite.rb +1 -1
  77. data/lib/gloo/objs/data/table.rb +112 -0
  78. data/lib/gloo/objs/dev/git.rb +2 -2
  79. data/lib/gloo/objs/dev/stats.rb +4 -4
  80. data/lib/gloo/objs/dt/date.rb +65 -0
  81. data/lib/gloo/objs/dt/datetime.rb +120 -0
  82. data/lib/gloo/objs/dt/dt_tools.rb +100 -0
  83. data/lib/gloo/objs/dt/time.rb +65 -0
  84. data/lib/gloo/objs/ror/erb.rb +116 -0
  85. data/lib/gloo/objs/ror/eval.rb +107 -0
  86. data/lib/gloo/objs/snd/play.rb +1 -1
  87. data/lib/gloo/objs/snd/say.rb +1 -1
  88. data/lib/gloo/objs/system/file_handle.rb +4 -4
  89. data/lib/gloo/objs/system/ssh_exec.rb +1 -1
  90. data/lib/gloo/objs/system/system.rb +1 -1
  91. data/lib/gloo/objs/web/http_get.rb +159 -0
  92. data/lib/gloo/objs/web/http_post.rb +183 -0
  93. data/lib/gloo/objs/web/json.rb +135 -0
  94. data/lib/gloo/objs/web/slack.rb +130 -0
  95. data/lib/gloo/objs/web/teams.rb +117 -0
  96. data/lib/gloo/objs/web/uri.rb +148 -0
  97. data/lib/gloo/persist/disc_mech.rb +87 -0
  98. data/lib/gloo/persist/file_loader.rb +193 -0
  99. data/lib/gloo/persist/file_saver.rb +51 -0
  100. data/lib/gloo/persist/file_storage.rb +46 -0
  101. data/lib/gloo/persist/line_splitter.rb +81 -0
  102. data/lib/gloo/persist/persist_man.rb +153 -0
  103. data/lib/gloo/utils/format.rb +21 -0
  104. data/lib/gloo/utils/stats.rb +206 -0
  105. data/lib/gloo/utils/words.rb +19 -0
  106. data/lib/gloo/verbs/alert.rb +2 -2
  107. data/lib/gloo/verbs/beep.rb +1 -1
  108. data/lib/gloo/verbs/cls.rb +1 -1
  109. data/lib/gloo/verbs/context.rb +62 -0
  110. data/lib/gloo/verbs/create.rb +68 -0
  111. data/lib/gloo/verbs/execute.rb +56 -0
  112. data/lib/gloo/verbs/files.rb +49 -0
  113. data/lib/gloo/verbs/help.rb +1 -1
  114. data/lib/gloo/verbs/if.rb +92 -0
  115. data/lib/gloo/verbs/list.rb +98 -0
  116. data/lib/gloo/verbs/load.rb +45 -0
  117. data/lib/gloo/verbs/move.rb +89 -0
  118. data/lib/gloo/verbs/put.rb +94 -0
  119. data/lib/gloo/verbs/quit.rb +40 -0
  120. data/lib/gloo/verbs/reload.rb +43 -0
  121. data/lib/gloo/verbs/run.rb +75 -0
  122. data/lib/gloo/verbs/save.rb +39 -0
  123. data/lib/gloo/verbs/show.rb +63 -0
  124. data/lib/gloo/verbs/tell.rb +80 -0
  125. data/lib/gloo/verbs/unless.rb +92 -0
  126. data/lib/gloo/verbs/unload.rb +46 -0
  127. data/lib/gloo/verbs/version.rb +3 -3
  128. data/lib/gloo/verbs/wait.rb +42 -0
  129. data/lib/gloo.rb +2 -2
  130. data/lib/run.rb +2 -2
  131. 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
@@ -20,7 +20,7 @@ require 'mysql2'
20
20
 
21
21
  module Gloo
22
22
  module Objs
23
- class Mysql < GlooLang::Core::Obj
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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, o )
187
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
188
188
  return o.value
189
189
  end
190
190
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class Query < GlooLang::Core::Obj
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 GlooLang::Objs::Alias.resolve_alias( @engine, o )
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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, p )
152
+ p = Gloo::Objs::Alias.resolve_alias( @engine, p )
153
153
  params << p.value
154
154
  end
155
155
 
@@ -19,7 +19,7 @@ require 'sqlite3'
19
19
 
20
20
  module Gloo
21
21
  module Objs
22
- class Sqlite < GlooLang::Core::Obj
22
+ class Sqlite < Gloo::Core::Obj
23
23
 
24
24
  KEYWORD = 'sqlite'.freeze
25
25
  KEYWORD_SHORT = 'sqlite'.freeze
@@ -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
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Git < GlooLang::Core::Obj
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 = GlooLang::Expr::Expression.new( @engine, @params.tokens )
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`