gloo 0.3.0 → 0.5.3
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/.rubocop.yml +73 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +86 -83
- data/Rakefile +7 -6
- data/bin/console +4 -4
- data/gloo.gemspec +22 -18
- data/lib/gloo.rb +6 -6
- data/lib/gloo/app/args.rb +30 -31
- data/lib/gloo/app/engine.rb +80 -30
- data/lib/gloo/app/help.rb +17 -11
- data/lib/gloo/app/info.rb +3 -3
- data/lib/gloo/app/log.rb +17 -17
- data/lib/gloo/app/mode.rb +4 -4
- data/lib/gloo/app/settings.rb +51 -41
- 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/core/baseo.rb +7 -7
- data/lib/gloo/core/dictionary.rb +30 -27
- data/lib/gloo/core/error.rb +50 -0
- data/lib/gloo/core/event_manager.rb +17 -23
- data/lib/gloo/core/factory.rb +149 -39
- data/lib/gloo/core/gloo_system.rb +121 -54
- data/lib/gloo/core/heap.rb +15 -13
- data/lib/gloo/core/it.rb +5 -5
- data/lib/gloo/core/literal.rb +7 -7
- data/lib/gloo/core/obj.rb +138 -79
- data/lib/gloo/core/obj_finder.rb +9 -14
- data/lib/gloo/core/op.rb +8 -8
- data/lib/gloo/core/parser.rb +27 -26
- data/lib/gloo/core/pn.rb +68 -52
- data/lib/gloo/core/script.rb +7 -7
- data/lib/gloo/core/tokens.rb +39 -41
- data/lib/gloo/core/verb.rb +30 -19
- data/lib/gloo/exec/dispatch.rb +30 -0
- data/lib/gloo/exec/runner.rb +43 -0
- data/lib/gloo/expr/expression.rb +36 -43
- data/lib/gloo/expr/l_boolean.rb +7 -6
- data/lib/gloo/expr/l_decimal.rb +34 -0
- data/lib/gloo/expr/l_integer.rb +5 -4
- data/lib/gloo/expr/l_string.rb +13 -15
- data/lib/gloo/expr/op_div.rb +5 -5
- data/lib/gloo/expr/op_minus.rb +5 -5
- data/lib/gloo/expr/op_mult.rb +5 -5
- data/lib/gloo/expr/op_plus.rb +7 -7
- data/lib/gloo/objs/basic/alias.rb +111 -0
- data/lib/gloo/objs/basic/boolean.rb +63 -38
- data/lib/gloo/objs/basic/container.rb +71 -12
- data/lib/gloo/objs/basic/decimal.rb +96 -0
- data/lib/gloo/objs/basic/integer.rb +45 -16
- data/lib/gloo/objs/basic/script.rb +62 -38
- data/lib/gloo/objs/basic/string.rb +47 -15
- data/lib/gloo/objs/basic/text.rb +69 -21
- data/lib/gloo/objs/basic/untyped.rb +35 -10
- data/lib/gloo/objs/cli/banner.rb +137 -0
- data/lib/gloo/objs/cli/bar.rb +141 -0
- data/lib/gloo/objs/cli/colorize.rb +54 -24
- data/lib/gloo/objs/cli/confirm.rb +63 -29
- data/lib/gloo/objs/cli/menu.rb +236 -0
- data/lib/gloo/objs/cli/menu_item.rb +128 -0
- data/lib/gloo/objs/cli/pastel.rb +120 -0
- data/lib/gloo/objs/cli/prompt.rb +73 -31
- data/lib/gloo/objs/cli/select.rb +153 -0
- data/lib/gloo/objs/ctrl/each.rb +128 -61
- data/lib/gloo/objs/ctrl/repeat.rb +129 -0
- data/lib/gloo/objs/data/markdown.rb +109 -0
- data/lib/gloo/objs/data/table.rb +168 -0
- data/lib/gloo/objs/dev/git.rb +98 -64
- data/lib/gloo/objs/dt/date.rb +72 -0
- data/lib/gloo/objs/dt/datetime.rb +84 -0
- data/lib/gloo/objs/dt/time.rb +72 -0
- data/lib/gloo/objs/ror/erb.rb +82 -41
- data/lib/gloo/objs/ror/eval.rb +73 -31
- data/lib/gloo/objs/snd/play.rb +71 -0
- data/lib/gloo/objs/snd/say.rb +120 -0
- data/lib/gloo/objs/system/file_handle.rb +129 -48
- data/lib/gloo/objs/system/system.rb +84 -38
- data/lib/gloo/objs/web/http_get.rb +103 -46
- data/lib/gloo/objs/web/http_post.rb +70 -44
- data/lib/gloo/objs/web/json.rb +155 -0
- data/lib/gloo/objs/web/slack.rb +89 -58
- data/lib/gloo/objs/web/teams.rb +88 -53
- data/lib/gloo/objs/web/uri.rb +160 -0
- data/lib/gloo/persist/file_loader.rb +95 -85
- data/lib/gloo/persist/file_saver.rb +12 -12
- data/lib/gloo/persist/file_storage.rb +15 -15
- data/lib/gloo/persist/line_splitter.rb +79 -0
- data/lib/gloo/persist/persist_man.rb +63 -39
- data/lib/gloo/utils/words.rb +2 -2
- data/lib/gloo/verbs/alert.rb +67 -16
- data/lib/gloo/verbs/beep.rb +70 -0
- data/lib/gloo/verbs/cls.rb +67 -0
- data/lib/gloo/verbs/context.rb +61 -21
- data/lib/gloo/verbs/create.rb +52 -21
- data/lib/gloo/verbs/help.rb +186 -27
- data/lib/gloo/verbs/if.rb +55 -21
- data/lib/gloo/verbs/list.rb +55 -24
- data/lib/gloo/verbs/load.rb +47 -12
- data/lib/gloo/verbs/move.rb +128 -0
- data/lib/gloo/verbs/put.rb +90 -34
- data/lib/gloo/verbs/quit.rb +43 -12
- data/lib/gloo/verbs/run.rb +63 -18
- data/lib/gloo/verbs/save.rb +45 -10
- data/lib/gloo/verbs/show.rb +56 -22
- data/lib/gloo/verbs/tell.rb +45 -13
- data/lib/gloo/verbs/unless.rb +56 -21
- data/lib/gloo/verbs/version.rb +42 -12
- data/lib/gloo/verbs/wait.rb +73 -0
- data/lib/run.rb +5 -5
- metadata +90 -12
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A Date object (does not include a time).
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Objs
|
|
9
|
+
class Date < Gloo::Core::Obj
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'date'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'date'.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
|
+
# Messages
|
|
30
|
+
# ---------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Get a list of message names that this object receives.
|
|
34
|
+
#
|
|
35
|
+
def self.messages
|
|
36
|
+
return super + %w[now]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Get the current working branch.
|
|
40
|
+
def msg_now
|
|
41
|
+
t = DateTime.now.strftime( '%Y.%m.%d' )
|
|
42
|
+
self.value = t
|
|
43
|
+
$engine.heap.it.set_to t
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# ---------------------------------------------------------------------
|
|
47
|
+
# Help
|
|
48
|
+
# ---------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# Get help for this object type.
|
|
52
|
+
#
|
|
53
|
+
def self.help
|
|
54
|
+
return <<~TEXT
|
|
55
|
+
DATE OBJECT TYPE
|
|
56
|
+
NAME: date
|
|
57
|
+
SHORTCUT: date
|
|
58
|
+
|
|
59
|
+
DESCRIPTION
|
|
60
|
+
A reference to a date, but without time.
|
|
61
|
+
|
|
62
|
+
CHILDREN
|
|
63
|
+
None
|
|
64
|
+
|
|
65
|
+
MESSAGES
|
|
66
|
+
now - Set to the current system date.
|
|
67
|
+
TEXT
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A Date and Time object.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Objs
|
|
9
|
+
class Datetime < Gloo::Core::Obj
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'datetime'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'dt'.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
|
+
unless new_value.is_a? DateTime
|
|
33
|
+
self.value = $engine.convert( new_value, 'DateTime', nil )
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
self.value = new_value
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# ---------------------------------------------------------------------
|
|
41
|
+
# Messages
|
|
42
|
+
# ---------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Get a list of message names that this object receives.
|
|
46
|
+
#
|
|
47
|
+
def self.messages
|
|
48
|
+
return super + %w[now]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Get the current working branch.
|
|
52
|
+
def msg_now
|
|
53
|
+
t = DateTime.now.strftime( '%Y.%m.%d %I:%M:%S %P' )
|
|
54
|
+
self.value = t
|
|
55
|
+
$engine.heap.it.set_to t
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# ---------------------------------------------------------------------
|
|
59
|
+
# Help
|
|
60
|
+
# ---------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Get help for this object type.
|
|
64
|
+
#
|
|
65
|
+
def self.help
|
|
66
|
+
return <<~TEXT
|
|
67
|
+
DATETIME OBJECT TYPE
|
|
68
|
+
NAME: datetime
|
|
69
|
+
SHORTCUT: dt
|
|
70
|
+
|
|
71
|
+
DESCRIPTION
|
|
72
|
+
A reference to a date and time.
|
|
73
|
+
|
|
74
|
+
CHILDREN
|
|
75
|
+
None
|
|
76
|
+
|
|
77
|
+
MESSAGES
|
|
78
|
+
now - Set to the current system date and time.
|
|
79
|
+
TEXT
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# A Time object (does not include a date).
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Objs
|
|
9
|
+
class Time < Gloo::Core::Obj
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'time'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'time'.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
|
+
# Messages
|
|
30
|
+
# ---------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Get a list of message names that this object receives.
|
|
34
|
+
#
|
|
35
|
+
def self.messages
|
|
36
|
+
return super + %w[now]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Get the current working branch.
|
|
40
|
+
def msg_now
|
|
41
|
+
t = DateTime.now.strftime( '%I:%M:%S %P' )
|
|
42
|
+
self.value = t
|
|
43
|
+
$engine.heap.it.set_to t
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# ---------------------------------------------------------------------
|
|
47
|
+
# Help
|
|
48
|
+
# ---------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# Get help for this object type.
|
|
52
|
+
#
|
|
53
|
+
def self.help
|
|
54
|
+
return <<~TEXT
|
|
55
|
+
TIME OBJECT TYPE
|
|
56
|
+
NAME: time
|
|
57
|
+
SHORTCUT: time
|
|
58
|
+
|
|
59
|
+
DESCRIPTION
|
|
60
|
+
A reference to a time, but without a date.
|
|
61
|
+
|
|
62
|
+
CHILDREN
|
|
63
|
+
None
|
|
64
|
+
|
|
65
|
+
MESSAGES
|
|
66
|
+
now - Set to the current system time.
|
|
67
|
+
TEXT
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/gloo/objs/ror/erb.rb
CHANGED
|
@@ -8,61 +8,62 @@ require 'erb'
|
|
|
8
8
|
module Gloo
|
|
9
9
|
module Objs
|
|
10
10
|
class Erb < Gloo::Core::Obj
|
|
11
|
-
|
|
12
|
-
KEYWORD = 'erb'
|
|
13
|
-
KEYWORD_SHORT = 'erb'
|
|
14
|
-
TEMPLATE = 'template'
|
|
15
|
-
PARAMS = 'params'
|
|
16
|
-
RESULT = 'result'
|
|
17
|
-
|
|
18
|
-
#
|
|
11
|
+
|
|
12
|
+
KEYWORD = 'erb'.freeze
|
|
13
|
+
KEYWORD_SHORT = 'erb'.freeze
|
|
14
|
+
TEMPLATE = 'template'.freeze
|
|
15
|
+
PARAMS = 'params'.freeze
|
|
16
|
+
RESULT = 'result'.freeze
|
|
17
|
+
|
|
18
|
+
#
|
|
19
19
|
# The name of the object type.
|
|
20
|
-
#
|
|
20
|
+
#
|
|
21
21
|
def self.typename
|
|
22
22
|
return KEYWORD
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
#
|
|
25
|
+
#
|
|
26
26
|
# The short name of the object type.
|
|
27
|
-
#
|
|
27
|
+
#
|
|
28
28
|
def self.short_typename
|
|
29
29
|
return KEYWORD_SHORT
|
|
30
30
|
end
|
|
31
|
-
|
|
32
|
-
#
|
|
31
|
+
|
|
32
|
+
#
|
|
33
33
|
# Get the ERB template.
|
|
34
|
-
#
|
|
35
|
-
def
|
|
34
|
+
#
|
|
35
|
+
def template_value
|
|
36
36
|
tmpl = find_child TEMPLATE
|
|
37
37
|
return nil unless tmpl
|
|
38
|
+
|
|
38
39
|
return tmpl.value
|
|
39
40
|
end
|
|
40
|
-
|
|
41
|
-
#
|
|
41
|
+
|
|
42
|
+
#
|
|
42
43
|
# Set the result of the system call.
|
|
43
|
-
#
|
|
44
|
-
def set_result data
|
|
44
|
+
#
|
|
45
|
+
def set_result( data )
|
|
45
46
|
r = find_child RESULT
|
|
46
47
|
return nil unless r
|
|
48
|
+
|
|
47
49
|
r.set_value data
|
|
48
50
|
end
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
+
|
|
52
|
+
#
|
|
51
53
|
# Get a hash with parameters for the ERB render.
|
|
52
|
-
#
|
|
53
|
-
def
|
|
54
|
+
#
|
|
55
|
+
def param_hash
|
|
54
56
|
h = {}
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
body = find_child PARAMS
|
|
57
59
|
body.children.each do |child|
|
|
60
|
+
child = Gloo::Objs::Alias.resolve_alias( child )
|
|
58
61
|
h[ child.name ] = child.value
|
|
59
62
|
end
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
return h
|
|
62
65
|
end
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
67
|
# ---------------------------------------------------------------------
|
|
67
68
|
# Children
|
|
68
69
|
# ---------------------------------------------------------------------
|
|
@@ -73,37 +74,77 @@ module Gloo
|
|
|
73
74
|
def add_children_on_create?
|
|
74
75
|
return true
|
|
75
76
|
end
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
# Add children to this object.
|
|
78
|
-
# This is used by containers to add children needed
|
|
79
|
+
# This is used by containers to add children needed
|
|
79
80
|
# for default configurations.
|
|
80
81
|
def add_default_children
|
|
81
82
|
fac = $engine.factory
|
|
82
|
-
fac.create
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
fac.create( { :name => 'template',
|
|
84
|
+
:type => 'text',
|
|
85
|
+
:value => '',
|
|
86
|
+
:parent => self } )
|
|
87
|
+
fac.create( { :name => 'params',
|
|
88
|
+
:type => 'container',
|
|
89
|
+
:value => nil,
|
|
90
|
+
:parent => self } )
|
|
91
|
+
fac.create( { :name => 'result',
|
|
92
|
+
:type => 'text',
|
|
93
|
+
:value => nil,
|
|
94
|
+
:parent => self } )
|
|
85
95
|
end
|
|
86
96
|
|
|
87
|
-
|
|
88
97
|
# ---------------------------------------------------------------------
|
|
89
98
|
# Messages
|
|
90
99
|
# ---------------------------------------------------------------------
|
|
91
100
|
|
|
92
|
-
#
|
|
101
|
+
#
|
|
93
102
|
# Get a list of message names that this object receives.
|
|
94
|
-
#
|
|
103
|
+
#
|
|
95
104
|
def self.messages
|
|
96
|
-
return super + [
|
|
105
|
+
return super + [ 'run' ]
|
|
97
106
|
end
|
|
98
|
-
|
|
107
|
+
|
|
99
108
|
# Run the system command.
|
|
100
109
|
def msg_run
|
|
101
|
-
tmpl =
|
|
110
|
+
tmpl = template_value
|
|
102
111
|
return unless tmpl
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
|
|
113
|
+
render = ERB.new( tmpl )
|
|
114
|
+
set_result render.result_with_hash( param_hash )
|
|
105
115
|
end
|
|
106
|
-
|
|
116
|
+
|
|
117
|
+
# ---------------------------------------------------------------------
|
|
118
|
+
# Help
|
|
119
|
+
# ---------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
#
|
|
122
|
+
# Get help for this object type.
|
|
123
|
+
#
|
|
124
|
+
def self.help
|
|
125
|
+
return <<~TEXT
|
|
126
|
+
ERB OBJECT TYPE
|
|
127
|
+
NAME: erb
|
|
128
|
+
SHORTCUT: erb
|
|
129
|
+
|
|
130
|
+
DESCRIPTION
|
|
131
|
+
Use the ERB templating system to generate content.
|
|
132
|
+
|
|
133
|
+
CHILDREN
|
|
134
|
+
template - text
|
|
135
|
+
The template that will be used the the ERB object is run.
|
|
136
|
+
params - container
|
|
137
|
+
The collection of children values that will be used
|
|
138
|
+
when the template object is rendered.
|
|
139
|
+
result - text
|
|
140
|
+
The result of the template rendering.
|
|
141
|
+
|
|
142
|
+
MESSAGES
|
|
143
|
+
run - Render the result based on the template and the
|
|
144
|
+
parameter values.
|
|
145
|
+
TEXT
|
|
146
|
+
end
|
|
147
|
+
|
|
107
148
|
end
|
|
108
149
|
end
|
|
109
150
|
end
|
data/lib/gloo/objs/ror/eval.rb
CHANGED
|
@@ -7,45 +7,46 @@
|
|
|
7
7
|
module Gloo
|
|
8
8
|
module Objs
|
|
9
9
|
class Eval < Gloo::Core::Obj
|
|
10
|
-
|
|
11
|
-
KEYWORD = 'eval'
|
|
12
|
-
KEYWORD_SHORT = 'ruby'
|
|
13
|
-
CMD = 'command'
|
|
14
|
-
RESULT = 'result'
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
KEYWORD = 'eval'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'ruby'.freeze
|
|
13
|
+
CMD = 'command'.freeze
|
|
14
|
+
RESULT = 'result'.freeze
|
|
15
|
+
|
|
16
|
+
#
|
|
17
17
|
# The name of the object type.
|
|
18
|
-
#
|
|
18
|
+
#
|
|
19
19
|
def self.typename
|
|
20
20
|
return KEYWORD
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
#
|
|
24
24
|
# The short name of the object type.
|
|
25
|
-
#
|
|
25
|
+
#
|
|
26
26
|
def self.short_typename
|
|
27
27
|
return KEYWORD_SHORT
|
|
28
28
|
end
|
|
29
|
-
|
|
30
|
-
#
|
|
29
|
+
|
|
30
|
+
#
|
|
31
31
|
# Get the URI from the child object.
|
|
32
32
|
# Returns nil if there is none.
|
|
33
|
-
#
|
|
34
|
-
def
|
|
33
|
+
#
|
|
34
|
+
def cmd_value
|
|
35
35
|
cmd = find_child CMD
|
|
36
36
|
return nil unless cmd
|
|
37
|
+
|
|
37
38
|
return cmd.value
|
|
38
39
|
end
|
|
39
|
-
|
|
40
|
-
#
|
|
40
|
+
|
|
41
|
+
#
|
|
41
42
|
# Set the result of the system call.
|
|
42
|
-
#
|
|
43
|
-
def set_result data
|
|
43
|
+
#
|
|
44
|
+
def set_result( data )
|
|
44
45
|
r = find_child RESULT
|
|
45
46
|
return nil unless r
|
|
47
|
+
|
|
46
48
|
r.set_value data
|
|
47
49
|
end
|
|
48
|
-
|
|
49
50
|
|
|
50
51
|
# ---------------------------------------------------------------------
|
|
51
52
|
# Children
|
|
@@ -57,36 +58,77 @@ module Gloo
|
|
|
57
58
|
def add_children_on_create?
|
|
58
59
|
return true
|
|
59
60
|
end
|
|
60
|
-
|
|
61
|
+
|
|
61
62
|
# Add children to this object.
|
|
62
|
-
# This is used by containers to add children needed
|
|
63
|
+
# This is used by containers to add children needed
|
|
63
64
|
# for default configurations.
|
|
64
65
|
def add_default_children
|
|
65
66
|
fac = $engine.factory
|
|
66
|
-
fac.create
|
|
67
|
-
|
|
67
|
+
fac.create( { :name => 'command',
|
|
68
|
+
:type => 'string',
|
|
69
|
+
:value => '1+2',
|
|
70
|
+
:parent => self } )
|
|
71
|
+
fac.create( { :name => 'result',
|
|
72
|
+
:type => 'string',
|
|
73
|
+
:value => nil,
|
|
74
|
+
:parent => self } )
|
|
68
75
|
end
|
|
69
76
|
|
|
70
|
-
|
|
71
77
|
# ---------------------------------------------------------------------
|
|
72
78
|
# Messages
|
|
73
79
|
# ---------------------------------------------------------------------
|
|
74
80
|
|
|
75
|
-
#
|
|
81
|
+
#
|
|
76
82
|
# Get a list of message names that this object receives.
|
|
77
|
-
#
|
|
83
|
+
#
|
|
78
84
|
def self.messages
|
|
79
|
-
return super + [
|
|
85
|
+
return super + [ 'run' ]
|
|
80
86
|
end
|
|
81
|
-
|
|
87
|
+
|
|
82
88
|
# Run the system command.
|
|
83
89
|
def msg_run
|
|
84
|
-
cmd =
|
|
90
|
+
cmd = cmd_value
|
|
85
91
|
return unless cmd
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
|
|
93
|
+
begin
|
|
94
|
+
# rubocop:disable Security/Eval
|
|
95
|
+
result = eval cmd
|
|
96
|
+
# rubocop:enable Security/Eval
|
|
97
|
+
set_result result
|
|
98
|
+
$engine.heap.it.set_to result
|
|
99
|
+
rescue => e
|
|
100
|
+
$log.error e.message
|
|
101
|
+
$engine.heap.error.set_to e.message
|
|
102
|
+
end
|
|
88
103
|
end
|
|
89
|
-
|
|
104
|
+
|
|
105
|
+
# ---------------------------------------------------------------------
|
|
106
|
+
# Help
|
|
107
|
+
# ---------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Get help for this object type.
|
|
111
|
+
#
|
|
112
|
+
def self.help
|
|
113
|
+
return <<~TEXT
|
|
114
|
+
EVAL OBJECT TYPE
|
|
115
|
+
NAME: eval
|
|
116
|
+
SHORTCUT: ruby
|
|
117
|
+
|
|
118
|
+
DESCRIPTION
|
|
119
|
+
Execute a ruby expression.
|
|
120
|
+
|
|
121
|
+
CHILDREN
|
|
122
|
+
command - string
|
|
123
|
+
The ruby expression or command that will be run.
|
|
124
|
+
result - string
|
|
125
|
+
The result of the command or expression after it is run.
|
|
126
|
+
|
|
127
|
+
MESSAGES
|
|
128
|
+
run - Execute the ruby command and update the result.
|
|
129
|
+
TEXT
|
|
130
|
+
end
|
|
131
|
+
|
|
90
132
|
end
|
|
91
133
|
end
|
|
92
134
|
end
|