gloo 0.7.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/Gemfile.lock +46 -39
  4. data/LICENSE.txt +1 -1
  5. data/gloo.gemspec +12 -6
  6. data/lib/VERSION +1 -1
  7. data/lib/dependencies.rb +28 -0
  8. data/lib/gloo/app/info.rb +3 -1
  9. data/lib/gloo/app/log.rb +1 -29
  10. data/lib/gloo/app/platform.rb +142 -0
  11. data/lib/gloo/objs/cli/banner.rb +2 -2
  12. data/lib/gloo/objs/cli/bar.rb +4 -4
  13. data/lib/gloo/objs/cli/colorize.rb +3 -3
  14. data/lib/gloo/objs/cli/confirm.rb +3 -3
  15. data/lib/gloo/objs/cli/menu.rb +9 -9
  16. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  17. data/lib/gloo/objs/cli/pastel.rb +2 -2
  18. data/lib/gloo/objs/cli/prompt.rb +4 -4
  19. data/lib/gloo/objs/cli/select.rb +4 -4
  20. data/lib/gloo/objs/dev/git.rb +7 -7
  21. data/lib/gloo/objs/dev/stats.rb +8 -5
  22. data/lib/gloo/objs/snd/play.rb +1 -1
  23. data/lib/gloo/objs/snd/say.rb +2 -2
  24. data/lib/gloo/objs/system/file_handle.rb +9 -9
  25. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  26. data/lib/gloo/objs/system/system.rb +2 -2
  27. data/lib/gloo/verbs/alert.rb +7 -7
  28. data/lib/gloo/verbs/beep.rb +1 -1
  29. data/lib/gloo/verbs/cls.rb +2 -2
  30. data/lib/gloo.rb +7 -7
  31. data/lib/run.rb +7 -5
  32. metadata +42 -147
  33. data/lib/gloo/app/args.rb +0 -112
  34. data/lib/gloo/app/engine.rb +0 -230
  35. data/lib/gloo/app/help.rb +0 -156
  36. data/lib/gloo/app/mode.rb +0 -27
  37. data/lib/gloo/app/settings.rb +0 -186
  38. data/lib/gloo/convert/converter.rb +0 -35
  39. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  40. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  41. data/lib/gloo/convert/string_to_integer.rb +0 -20
  42. data/lib/gloo/core/baseo.rb +0 -28
  43. data/lib/gloo/core/dictionary.rb +0 -181
  44. data/lib/gloo/core/error.rb +0 -61
  45. data/lib/gloo/core/event_manager.rb +0 -44
  46. data/lib/gloo/core/factory.rb +0 -210
  47. data/lib/gloo/core/gloo_system.rb +0 -266
  48. data/lib/gloo/core/heap.rb +0 -52
  49. data/lib/gloo/core/here.rb +0 -36
  50. data/lib/gloo/core/it.rb +0 -36
  51. data/lib/gloo/core/literal.rb +0 -30
  52. data/lib/gloo/core/obj.rb +0 -305
  53. data/lib/gloo/core/obj_finder.rb +0 -30
  54. data/lib/gloo/core/op.rb +0 -40
  55. data/lib/gloo/core/parser.rb +0 -59
  56. data/lib/gloo/core/pn.rb +0 -188
  57. data/lib/gloo/core/tokens.rb +0 -165
  58. data/lib/gloo/core/verb.rb +0 -86
  59. data/lib/gloo/exec/action.rb +0 -48
  60. data/lib/gloo/exec/dispatch.rb +0 -40
  61. data/lib/gloo/exec/exec_env.rb +0 -74
  62. data/lib/gloo/exec/runner.rb +0 -45
  63. data/lib/gloo/exec/script.rb +0 -49
  64. data/lib/gloo/exec/stack.rb +0 -78
  65. data/lib/gloo/expr/expression.rb +0 -118
  66. data/lib/gloo/expr/l_boolean.rb +0 -36
  67. data/lib/gloo/expr/l_decimal.rb +0 -39
  68. data/lib/gloo/expr/l_integer.rb +0 -37
  69. data/lib/gloo/expr/l_string.rb +0 -58
  70. data/lib/gloo/expr/op_div.rb +0 -22
  71. data/lib/gloo/expr/op_minus.rb +0 -22
  72. data/lib/gloo/expr/op_mult.rb +0 -22
  73. data/lib/gloo/expr/op_plus.rb +0 -24
  74. data/lib/gloo/objs/basic/alias.rb +0 -78
  75. data/lib/gloo/objs/basic/boolean.rb +0 -120
  76. data/lib/gloo/objs/basic/container.rb +0 -76
  77. data/lib/gloo/objs/basic/decimal.rb +0 -76
  78. data/lib/gloo/objs/basic/integer.rb +0 -73
  79. data/lib/gloo/objs/basic/script.rb +0 -99
  80. data/lib/gloo/objs/basic/string.rb +0 -77
  81. data/lib/gloo/objs/basic/text.rb +0 -87
  82. data/lib/gloo/objs/basic/untyped.rb +0 -41
  83. data/lib/gloo/objs/ctrl/each.rb +0 -279
  84. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  85. data/lib/gloo/objs/data/markdown.rb +0 -84
  86. data/lib/gloo/objs/data/mysql.rb +0 -192
  87. data/lib/gloo/objs/data/query.rb +0 -176
  88. data/lib/gloo/objs/data/sqlite.rb +0 -159
  89. data/lib/gloo/objs/data/table.rb +0 -140
  90. data/lib/gloo/objs/dt/date.rb +0 -50
  91. data/lib/gloo/objs/dt/datetime.rb +0 -62
  92. data/lib/gloo/objs/dt/time.rb +0 -50
  93. data/lib/gloo/objs/ror/erb.rb +0 -116
  94. data/lib/gloo/objs/ror/eval.rb +0 -107
  95. data/lib/gloo/objs/web/http_get.rb +0 -159
  96. data/lib/gloo/objs/web/http_post.rb +0 -183
  97. data/lib/gloo/objs/web/json.rb +0 -135
  98. data/lib/gloo/objs/web/slack.rb +0 -130
  99. data/lib/gloo/objs/web/teams.rb +0 -117
  100. data/lib/gloo/objs/web/uri.rb +0 -148
  101. data/lib/gloo/persist/file_loader.rb +0 -191
  102. data/lib/gloo/persist/file_saver.rb +0 -49
  103. data/lib/gloo/persist/file_storage.rb +0 -45
  104. data/lib/gloo/persist/line_splitter.rb +0 -81
  105. data/lib/gloo/persist/persist_man.rb +0 -120
  106. data/lib/gloo/utils/format.rb +0 -21
  107. data/lib/gloo/utils/stats.rb +0 -205
  108. data/lib/gloo/utils/words.rb +0 -19
  109. data/lib/gloo/verbs/context.rb +0 -62
  110. data/lib/gloo/verbs/create.rb +0 -68
  111. data/lib/gloo/verbs/execute.rb +0 -56
  112. data/lib/gloo/verbs/help.rb +0 -264
  113. data/lib/gloo/verbs/if.rb +0 -92
  114. data/lib/gloo/verbs/list.rb +0 -98
  115. data/lib/gloo/verbs/load.rb +0 -45
  116. data/lib/gloo/verbs/move.rb +0 -89
  117. data/lib/gloo/verbs/put.rb +0 -94
  118. data/lib/gloo/verbs/quit.rb +0 -40
  119. data/lib/gloo/verbs/run.rb +0 -75
  120. data/lib/gloo/verbs/save.rb +0 -39
  121. data/lib/gloo/verbs/show.rb +0 -64
  122. data/lib/gloo/verbs/tell.rb +0 -79
  123. data/lib/gloo/verbs/unless.rb +0 -92
  124. data/lib/gloo/verbs/version.rb +0 -37
  125. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,30 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # A Literal value.
5
- # Base class for all literal values.
6
- #
7
-
8
- module Gloo
9
- module Core
10
- class Literal
11
-
12
- attr_reader :value
13
-
14
- #
15
- # Create the expression from a list of tokens.
16
- #
17
- def initialize( value )
18
- set_value( value )
19
- end
20
-
21
- #
22
- # Set the literal value.
23
- #
24
- def set_value( value )
25
- @value = value
26
- end
27
-
28
- end
29
- end
30
- end
data/lib/gloo/core/obj.rb DELETED
@@ -1,305 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An data/value object.
5
- # Derives from the Baseo object. Is not a verb.
6
- #
7
-
8
- module Gloo
9
- module Core
10
- class Obj < Baseo
11
-
12
- attr_accessor :value
13
- attr_reader :children, :parent
14
-
15
- NOT_IMPLEMENTED_ERR = 'Not implemented yet!'.freeze
16
-
17
- #
18
- # Set up the object.
19
- #
20
- def initialize
21
- @value = ''
22
- @children = []
23
- @parent = nil
24
- end
25
-
26
- #
27
- # Register object types when they are loaded.
28
- #
29
- def self.inherited( subclass )
30
- Dictionary.instance.register_obj( subclass )
31
- end
32
-
33
- #
34
- # The name of the object type.
35
- #
36
- def self.typename
37
- raise 'this method should be overriden'
38
- end
39
-
40
- #
41
- # The object type, suitable for display.
42
- #
43
- def type_display
44
- return self.class.typename
45
- end
46
-
47
- #
48
- # Set the parent for the object.
49
- #
50
- def set_parent( obj )
51
- @parent = obj
52
- end
53
-
54
- #
55
- # Is this the root object?
56
- #
57
- def root?
58
- return false if @parent
59
- return false unless name.downcase == 'root'
60
-
61
- return true
62
- end
63
-
64
- # Can this object be created?
65
- # This is true by default and only false for some special cases
66
- # such as the System object.
67
- def self.can_create?
68
- true
69
- end
70
-
71
- #
72
- # Get the path and name to this object.
73
- #
74
- def pn
75
- str = self.name
76
- p = self.parent
77
- while p && !p.root?
78
- str = "#{p.name}.#{str}"
79
- p = p.parent
80
- end
81
- return str
82
- end
83
-
84
- #
85
- # Generic function to get display value.
86
- # Can be used for debugging, etc.
87
- #
88
- def display_value
89
- return self.pn
90
- end
91
-
92
- # ---------------------------------------------------------------------
93
- # Value
94
- # ---------------------------------------------------------------------
95
-
96
- #
97
- # Set the value with any necessary type conversions.
98
- #
99
- def set_value( new_value )
100
- self.value = new_value
101
- end
102
-
103
- #
104
- # Get the value for display purposes.
105
- #
106
- def value_display
107
- return self.value.to_s
108
- end
109
-
110
- #
111
- # Does this object support multi-line values?
112
- # Initially only true for scripts.
113
- #
114
- def multiline_value?
115
- return false
116
- end
117
-
118
- #
119
- # Is the value a String?
120
- #
121
- def value_string?
122
- return self.value.is_a? String
123
- end
124
-
125
- #
126
- # Is the value an Array?
127
- #
128
- def value_is_array?
129
- return self.value.is_a? Array
130
- end
131
-
132
- #
133
- # Is the value a blank string?
134
- #
135
- def value_is_blank?
136
- return true if value.nil?
137
-
138
- return self.value.to_s.strip.empty?
139
- end
140
-
141
- # ---------------------------------------------------------------------
142
- # Children
143
- # ---------------------------------------------------------------------
144
-
145
- #
146
- # Find a child of the given name.
147
- # If found, return it. If not found create it.
148
- #
149
- def find_add_child( name, type )
150
- child = self.find_child( name )
151
- return child if child
152
-
153
- params = { :name => name,
154
- :type => type,
155
- :value => nil,
156
- :parent => self }
157
- return $engine.factory.create params
158
- end
159
-
160
- #
161
- # Add a child object to the container.
162
- #
163
- def add_child( obj )
164
- @children << obj
165
- obj.set_parent self
166
- end
167
-
168
- #
169
- # Get the number of children.
170
- #
171
- def child_count
172
- return @children.count
173
- end
174
-
175
- #
176
- # Does this object contain an object with the given name?
177
- #
178
- def contains_child?( name )
179
- @children.each do |o|
180
- return true if name.downcase == o.name.downcase
181
- end
182
- return false
183
- end
184
-
185
- #
186
- # Find a child object with the given name.
187
- #
188
- def find_child( name )
189
- if name.end_with?( Gloo::Objs::Alias::ALIAS_REFERENCE )
190
- name = name[ 0..-2 ]
191
- end
192
-
193
- @children.each do |o|
194
- return o if name.downcase == o.name.downcase
195
- end
196
-
197
- if self.type_display == Gloo::Objs::Alias.typename
198
- ln = Gloo::Core::Pn.new( self.value )
199
- redirect = ln.resolve
200
- return redirect.find_child( name )
201
- end
202
- return nil
203
- end
204
-
205
- #
206
- # Delete all children from the container.
207
- #
208
- def delete_children
209
- @children.reverse.each do |o|
210
- self.remove_child o
211
- end
212
- end
213
-
214
- #
215
- # Remove the object from the children collection.
216
- #
217
- def remove_child( obj )
218
- @children.delete obj
219
- end
220
-
221
- # Does this object have children to add when an object
222
- # is created in interactive mode?
223
- # This does not apply during obj load, etc.
224
- def add_children_on_create?
225
- return false
226
- end
227
-
228
- # Add children to this object.
229
- # This is used by containers to add children needed
230
- # for default configurations.
231
- def add_default_children
232
- # Override this.
233
- end
234
-
235
- # ---------------------------------------------------------------------
236
- # Messages
237
- # ---------------------------------------------------------------------
238
-
239
- #
240
- # Get a list of message names that this object receives.
241
- #
242
- def self.messages
243
- return %w[unload]
244
- end
245
-
246
- #
247
- # Can this object receive a message?
248
- #
249
- def can_receive_message?( msg )
250
- msgs = self.class.messages
251
- return msgs.include?( msg.strip.downcase )
252
- end
253
-
254
- #
255
- # Sent this object the given message.
256
- #
257
- def send_message( msg, params = nil )
258
- @params = params
259
- return self.dispatch msg if self.can_receive_message? msg
260
-
261
- $log.error "Object #{self.name} cannot receive message #{msg}"
262
- return false
263
- end
264
-
265
- #
266
- # Dispatch the message to the object.
267
- #
268
- def dispatch( msg )
269
- o = "msg_#{msg}"
270
- if self.respond_to? o
271
- self.public_send( o )
272
- return true
273
- else
274
- $log.error "Message #{msg} not implemented"
275
- return false
276
- end
277
- end
278
-
279
- #
280
- # Send the object the unload message.
281
- #
282
- def msg_unload
283
- if self.root?
284
- $log.error 'Cannot unload the root object.'
285
- return
286
- end
287
-
288
- $engine.event_manager.on_unload self
289
- $engine.heap.unload self
290
- end
291
-
292
- # ---------------------------------------------------------------------
293
- # Help
294
- # ---------------------------------------------------------------------
295
-
296
- #
297
- # Get help for this object.
298
- #
299
- def self.help
300
- return 'No help found.'
301
- end
302
-
303
- end
304
- end
305
- end
@@ -1,30 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Utility used to find objects.
5
- #
6
-
7
- module Gloo
8
- module Core
9
- class ObjFinder
10
-
11
- #
12
- # Find all objects in the given container that have
13
- # the given name.
14
- # If the container isn't provided, root will be used.
15
- #
16
- def self.by_name( name, container = nil )
17
- container = $engine.heap.root if container.nil?
18
- arr = []
19
-
20
- container.children.each do |o|
21
- arr << o if o.name == name
22
- arr += by_name( name, o ) if o.child_count.positive?
23
- end
24
-
25
- return arr
26
- end
27
-
28
- end
29
- end
30
- end
data/lib/gloo/core/op.rb DELETED
@@ -1,40 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An Operator; part of an expression.
5
- # A static helper class.
6
- #
7
-
8
- module Gloo
9
- module Core
10
- class Op
11
-
12
- #
13
- # Is the token an operator?
14
- #
15
- def self.op?( token )
16
- return [ '+', '-', '*', '/' ].include?( token.strip )
17
- end
18
-
19
- #
20
- # Create the operator for the given token.
21
- #
22
- def self.create_op( token )
23
- return Gloo::Expr::OpMinus.new if token == '-'
24
- return Gloo::Expr::OpMult.new if token == '*'
25
- return Gloo::Expr::OpDiv.new if token == '/'
26
- return Gloo::Expr::OpPlus.new if token == '+'
27
-
28
- return default_op
29
- end
30
-
31
- #
32
- # Get the default operator (+).
33
- #
34
- def self.default_op
35
- return Gloo::Expr::OpPlus.new
36
- end
37
-
38
- end
39
- end
40
- end
@@ -1,59 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # The Parser.
5
- # Can parse single line commands or files.
6
- #
7
-
8
- module Gloo
9
- module Core
10
- class Parser
11
-
12
- #
13
- # Set up the parser.
14
- #
15
- def initialize
16
- $log.debug 'parser intialized...'
17
- end
18
-
19
- #
20
- # Parse a command from the immediate execution context.
21
- #
22
- def parse_immediate( cmd )
23
- cmd, params = split_params cmd
24
- params = Gloo::Core::Tokens.new( params ) if params
25
- tokens = Gloo::Core::Tokens.new( cmd )
26
- dic = Gloo::Core::Dictionary.instance
27
- verb = dic.find_verb( tokens.verb )
28
- return verb.new( tokens, params ) if verb
29
-
30
- $log.error "Verb '#{tokens.verb}' was not found."
31
- return nil
32
- end
33
-
34
- #
35
- # If additional params were provided, split them out
36
- # from the token list.
37
- #
38
- def split_params( cmd )
39
- params = nil
40
- i = cmd.rindex( '(' )
41
- if i && cmd.strip.end_with?( ')' )
42
- pstr = cmd[ i + 1..-1 ]
43
- params = pstr.strip[ 0..-2 ] if pstr
44
- cmd = cmd[ 0, i - 1 ]
45
- end
46
- return cmd, params
47
- end
48
-
49
- #
50
- # Parse a command and then run it if it parsed correctly.
51
- #
52
- def run( cmd )
53
- v = parse_immediate( cmd )
54
- Gloo::Exec::Runner.go( v ) if v
55
- end
56
-
57
- end
58
- end
59
- end
data/lib/gloo/core/pn.rb DELETED
@@ -1,188 +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 path name.
5
- # Path and name elements are separated by periods.
6
- #
7
-
8
- module Gloo
9
- module Core
10
- class Pn < Baseo
11
-
12
- ROOT = 'root'.freeze
13
- IT = 'it'.freeze
14
- ERROR = 'error'.freeze
15
-
16
- attr_reader :src, :elements
17
-
18
- #
19
- # Set up the object given a source string,
20
- # ie: the full path and name.
21
- #
22
- def initialize( src )
23
- set_to src
24
- end
25
-
26
- #
27
- # Reference to the root object path.
28
- #
29
- def self.root
30
- return Pn.new( ROOT )
31
- end
32
-
33
- #
34
- # Reference to it.
35
- #
36
- def self.it
37
- return Pn.new( IT )
38
- end
39
-
40
- #
41
- # Reference to the error message.
42
- #
43
- def self.error
44
- return Pn.new( ERROR )
45
- end
46
-
47
- #
48
- # Does the pathname reference refer to the root?
49
- #
50
- def root?
51
- return @src.downcase == ROOT
52
- end
53
-
54
- #
55
- # Does the pathname reference refer to it?
56
- #
57
- def it?
58
- return @src.downcase == IT
59
- end
60
-
61
- #
62
- # Does the pathname reference refer to error?
63
- #
64
- def error?
65
- return @src.downcase == ERROR
66
- end
67
-
68
- #
69
- # Does the pathname reference refer to the gloo system object?
70
- #
71
- def gloo_sys?
72
- return false unless @elements&.count&.positive?
73
-
74
- o = @elements.first.downcase
75
- return true if o == Gloo::Core::GlooSystem.typename
76
- return true if o == Gloo::Core::GlooSystem.short_typename
77
-
78
- return false
79
- end
80
-
81
- #
82
- # Get the string representation of the pathname.
83
- #
84
- def to_s
85
- return @src
86
- end
87
-
88
- #
89
- # Set the object pathname to the given value.
90
- #
91
- def set_to( value )
92
- @src = value.nil? ? nil : value.strip
93
- @elements = @src.nil? ? [] : @src.split( '.' )
94
- end
95
-
96
- #
97
- # Convert the raw string to a list of segments.
98
- #
99
- def segments
100
- return @elements
101
- end
102
-
103
- #
104
- # Get the name element.
105
- #
106
- def name
107
- return '' unless self.named?
108
-
109
- return @elements.last
110
- end
111
-
112
- #
113
- # Does the value include path elements?
114
- #
115
- def named?
116
- return @elements.count.positive?
117
- end
118
-
119
- #
120
- # Does the value include a name?
121
- #
122
- def includes_path?
123
- return @elements.count > 1
124
- end
125
-
126
- #
127
- # Get the parent that contains the object referenced.
128
- #
129
- def get_parent
130
- o = $engine.heap.root
131
-
132
- if self.includes_path?
133
- @elements[ 0..-2 ].each do |e|
134
- o = o.find_child( e )
135
- if o.nil?
136
- $log.error "Object '#{e}' was not found."
137
- return nil
138
- end
139
- end
140
- end
141
-
142
- return o
143
- end
144
-
145
- #
146
- # Does the object at the path exist?
147
- #
148
- def exists?
149
- return true if self.root?
150
- return true if self.it?
151
- return true if self.error?
152
-
153
- parent = self.get_parent
154
- return false unless parent
155
-
156
- return parent.contains_child? name
157
- end
158
-
159
- #
160
- # Is the reference to a color?
161
- #
162
- def named_color?
163
- colors = %w[red blue green white black yellow]
164
- return true if colors.include?( @src.downcase )
165
- end
166
-
167
- #
168
- # Resolve the pathname reference.
169
- # Find the object referenced or return nil if it is not found.
170
- #
171
- def resolve
172
- return $engine.heap.root if self.root?
173
- return $engine.heap.it if self.it?
174
- return $engine.heap.error if self.error?
175
- return Gloo::Core::GlooSystem.new( self ) if self.gloo_sys?
176
-
177
- Here.expand_here( self ) if Here.includes_here_ref?( @elements )
178
-
179
- parent = self.get_parent
180
- return nil unless parent
181
-
182
- obj = parent.find_child( self.name )
183
- return Gloo::Objs::Alias.resolve_alias( obj, self.src )
184
- end
185
-
186
- end
187
- end
188
- end