gloo 0.5.4 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/gloo/app/args.rb +48 -6
- data/lib/gloo/app/engine.rb +60 -38
- data/lib/gloo/app/help.rb +137 -16
- data/lib/gloo/app/info.rb +3 -1
- data/lib/gloo/app/log.rb +23 -0
- data/lib/gloo/app/mode.rb +2 -0
- data/lib/gloo/app/settings.rb +98 -47
- data/lib/gloo/convert/converter.rb +35 -0
- data/lib/gloo/convert/string_to_datetime.rb +1 -1
- data/lib/gloo/convert/string_to_decimal.rb +1 -1
- data/lib/gloo/convert/string_to_integer.rb +1 -1
- data/lib/gloo/core/dictionary.rb +99 -22
- data/lib/gloo/core/error.rb +19 -8
- data/lib/gloo/core/event_manager.rb +4 -0
- data/lib/gloo/core/factory.rb +11 -0
- data/lib/gloo/core/gloo_system.rb +1 -1
- data/lib/gloo/core/heap.rb +11 -3
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +6 -0
- data/lib/gloo/core/literal.rb +5 -0
- data/lib/gloo/core/obj.rb +22 -0
- data/lib/gloo/core/op.rb +7 -0
- data/lib/gloo/core/parser.rb +6 -0
- data/lib/gloo/core/pn.rb +38 -0
- data/lib/gloo/core/tokens.rb +66 -22
- data/lib/gloo/core/verb.rb +12 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +15 -5
- data/lib/gloo/exec/exec_env.rb +74 -0
- data/lib/gloo/exec/runner.rb +4 -2
- data/lib/gloo/{core → exec}/script.rb +21 -9
- data/lib/gloo/exec/stack.rb +78 -0
- data/lib/gloo/expr/expression.rb +26 -4
- data/lib/gloo/expr/l_boolean.rb +6 -0
- data/lib/gloo/expr/l_decimal.rb +5 -0
- data/lib/gloo/expr/l_integer.rb +7 -0
- data/lib/gloo/expr/l_string.rb +7 -0
- data/lib/gloo/expr/op_div.rb +2 -0
- data/lib/gloo/expr/op_minus.rb +2 -0
- data/lib/gloo/expr/op_mult.rb +2 -0
- data/lib/gloo/expr/op_plus.rb +2 -0
- data/lib/gloo/help/app/application.txt +22 -0
- data/lib/gloo/help/app/configuration.txt +7 -0
- data/lib/gloo/help/app/default_help.txt +14 -0
- data/lib/gloo/help/app/logging.txt +16 -0
- data/lib/gloo/help/core/color.txt +31 -0
- data/lib/gloo/help/core/error.txt +33 -0
- data/lib/gloo/help/core/events.txt +21 -0
- data/lib/gloo/help/core/gloo_system.txt +54 -0
- data/lib/gloo/help/core/here.txt +30 -0
- data/lib/gloo/help/core/it.txt +23 -0
- data/lib/gloo/help/core/ops.txt +16 -0
- data/lib/gloo/help/core/pathname.txt +29 -0
- data/lib/gloo/help/objs/basic/alias.txt +36 -0
- data/lib/gloo/help/objs/basic/boolean.txt +28 -0
- data/lib/gloo/help/objs/basic/container.txt +33 -0
- data/lib/gloo/help/objs/basic/decimal.txt +28 -0
- data/lib/gloo/help/objs/basic/integer.txt +27 -0
- data/lib/gloo/help/objs/basic/script.txt +29 -0
- data/lib/gloo/help/objs/basic/string.txt +28 -0
- data/lib/gloo/help/objs/basic/text.txt +27 -0
- data/lib/gloo/help/objs/basic/untyped.txt +22 -0
- data/lib/gloo/help/objs/cli/banner.txt +49 -0
- data/lib/gloo/help/objs/cli/bar.txt +34 -0
- data/lib/gloo/help/objs/cli/colorize.txt +33 -0
- data/lib/gloo/help/objs/cli/confirm.txt +26 -0
- data/lib/gloo/help/objs/cli/menu.txt +44 -0
- data/lib/gloo/help/objs/cli/menu_item.txt +26 -0
- data/lib/gloo/help/objs/cli/pastel.txt +43 -0
- data/lib/gloo/help/objs/cli/prompt.txt +27 -0
- data/lib/gloo/help/objs/cli/select.txt +34 -0
- data/lib/gloo/help/objs/ctrl/each.txt +48 -0
- data/lib/gloo/help/objs/ctrl/repeat.txt +38 -0
- data/lib/gloo/help/objs/data/markdown.txt +25 -0
- data/lib/gloo/help/objs/data/table.txt +46 -0
- data/lib/gloo/help/objs/dev/git_repo.txt +35 -0
- data/lib/gloo/help/objs/dt/date.txt +23 -0
- data/lib/gloo/help/objs/dt/datetime.txt +24 -0
- data/lib/gloo/help/objs/dt/time.txt +23 -0
- data/lib/gloo/help/objs/ror/erb.txt +37 -0
- data/lib/gloo/help/objs/ror/eval.txt +24 -0
- data/lib/gloo/help/objs/snd/play.txt +23 -0
- data/lib/gloo/help/objs/snd/say.txt +28 -0
- data/lib/gloo/help/objs/system/file.txt +41 -0
- data/lib/gloo/help/objs/system/system.txt +32 -0
- data/lib/gloo/help/objs/web/http_get.txt +35 -0
- data/lib/gloo/help/objs/web/http_post.txt +32 -0
- data/lib/gloo/help/objs/web/json.txt +34 -0
- data/lib/gloo/help/objs/web/slack.txt +33 -0
- data/lib/gloo/help/objs/web/teams.txt +30 -0
- data/lib/gloo/help/objs/web/uri.txt +37 -0
- data/lib/gloo/help/verbs/alert.txt +33 -0
- data/lib/gloo/help/verbs/beep.txt +25 -0
- data/lib/gloo/help/verbs/cls.txt +24 -0
- data/lib/gloo/help/verbs/context.txt +43 -0
- data/lib/gloo/help/verbs/create.txt +33 -0
- data/lib/gloo/help/verbs/execute.txt +27 -0
- data/lib/gloo/help/verbs/help.txt +34 -0
- data/lib/gloo/help/verbs/if.txt +37 -0
- data/lib/gloo/help/verbs/list.txt +34 -0
- data/lib/gloo/help/verbs/load.txt +38 -0
- data/lib/gloo/help/verbs/move.txt +42 -0
- data/lib/gloo/help/verbs/put.txt +38 -0
- data/lib/gloo/help/verbs/quit.txt +25 -0
- data/lib/gloo/help/verbs/run.txt +41 -0
- data/lib/gloo/help/verbs/save.txt +26 -0
- data/lib/gloo/help/verbs/show.txt +30 -0
- data/lib/gloo/help/verbs/tell.txt +34 -0
- data/lib/gloo/help/verbs/unless.txt +38 -0
- data/lib/gloo/help/verbs/version.txt +32 -0
- data/lib/gloo/help/verbs/wait.txt +29 -0
- data/lib/gloo/objs/basic/alias.rb +0 -33
- data/lib/gloo/objs/basic/boolean.rb +6 -27
- data/lib/gloo/objs/basic/container.rb +0 -33
- data/lib/gloo/objs/basic/decimal.rb +8 -28
- data/lib/gloo/objs/basic/integer.rb +5 -26
- data/lib/gloo/objs/basic/script.rb +1 -27
- data/lib/gloo/objs/basic/string.rb +6 -26
- data/lib/gloo/objs/basic/text.rb +0 -25
- data/lib/gloo/objs/basic/untyped.rb +0 -26
- data/lib/gloo/objs/cli/banner.rb +0 -29
- data/lib/gloo/objs/cli/bar.rb +0 -29
- data/lib/gloo/objs/cli/colorize.rb +4 -34
- data/lib/gloo/objs/cli/confirm.rb +6 -36
- data/lib/gloo/objs/cli/menu.rb +6 -36
- data/lib/gloo/objs/cli/menu_item.rb +0 -33
- data/lib/gloo/objs/cli/pastel.rb +4 -27
- data/lib/gloo/objs/cli/prompt.rb +4 -28
- data/lib/gloo/objs/cli/select.rb +4 -31
- data/lib/gloo/objs/ctrl/each.rb +33 -33
- data/lib/gloo/objs/ctrl/repeat.rb +8 -29
- data/lib/gloo/objs/data/markdown.rb +0 -25
- data/lib/gloo/objs/data/table.rb +4 -32
- data/lib/gloo/objs/dev/git.rb +12 -30
- data/lib/gloo/objs/dt/date.rb +3 -25
- data/lib/gloo/objs/dt/datetime.rb +4 -26
- data/lib/gloo/objs/dt/time.rb +3 -25
- data/lib/gloo/objs/ror/erb.rb +11 -45
- data/lib/gloo/objs/ror/eval.rb +11 -38
- data/lib/gloo/objs/snd/play.rb +2 -25
- data/lib/gloo/objs/snd/say.rb +9 -31
- data/lib/gloo/objs/system/file_handle.rb +0 -38
- data/lib/gloo/objs/system/system.rb +16 -46
- data/lib/gloo/objs/web/http_get.rb +57 -83
- data/lib/gloo/objs/web/http_post.rb +8 -31
- data/lib/gloo/objs/web/json.rb +11 -31
- data/lib/gloo/objs/web/slack.rb +7 -34
- data/lib/gloo/objs/web/teams.rb +13 -48
- data/lib/gloo/objs/web/uri.rb +0 -29
- data/lib/gloo/persist/file_loader.rb +8 -0
- data/lib/gloo/persist/file_saver.rb +6 -0
- data/lib/gloo/persist/file_storage.rb +2 -0
- data/lib/gloo/persist/line_splitter.rb +2 -0
- data/lib/gloo/persist/persist_man.rb +6 -0
- data/lib/gloo/verbs/alert.rb +30 -44
- data/lib/gloo/verbs/beep.rb +0 -30
- data/lib/gloo/verbs/cls.rb +0 -30
- data/lib/gloo/verbs/context.rb +9 -39
- data/lib/gloo/verbs/create.rb +17 -32
- data/lib/gloo/verbs/execute.rb +52 -0
- data/lib/gloo/verbs/help.rb +151 -115
- data/lib/gloo/verbs/if.rb +46 -44
- data/lib/gloo/verbs/list.rb +36 -54
- data/lib/gloo/verbs/load.rb +8 -37
- data/lib/gloo/verbs/move.rb +12 -51
- data/lib/gloo/verbs/put.rb +28 -52
- data/lib/gloo/verbs/quit.rb +0 -31
- data/lib/gloo/verbs/run.rb +23 -39
- data/lib/gloo/verbs/save.rb +0 -33
- data/lib/gloo/verbs/show.rb +6 -31
- data/lib/gloo/verbs/tell.rb +31 -31
- data/lib/gloo/verbs/unless.rb +47 -46
- data/lib/gloo/verbs/version.rb +0 -30
- data/lib/gloo/verbs/wait.rb +0 -31
- metadata +79 -3
data/lib/gloo/objs/data/table.rb
CHANGED
@@ -70,16 +70,20 @@ module Gloo
|
|
70
70
|
# Children
|
71
71
|
# ---------------------------------------------------------------------
|
72
72
|
|
73
|
+
#
|
73
74
|
# Does this object have children to add when an object
|
74
75
|
# is created in interactive mode?
|
75
76
|
# This does not apply during obj load, etc.
|
77
|
+
#
|
76
78
|
def add_children_on_create?
|
77
79
|
return true
|
78
80
|
end
|
79
81
|
|
82
|
+
#
|
80
83
|
# Add children to this object.
|
81
84
|
# This is used by containers to add children needed
|
82
85
|
# for default configurations.
|
86
|
+
#
|
83
87
|
def add_default_children
|
84
88
|
fac = $engine.factory
|
85
89
|
fac.create_can HEADERS, self
|
@@ -131,38 +135,6 @@ module Gloo
|
|
131
135
|
puts "#{rendered}\n\n"
|
132
136
|
end
|
133
137
|
|
134
|
-
# ---------------------------------------------------------------------
|
135
|
-
# Help
|
136
|
-
# ---------------------------------------------------------------------
|
137
|
-
|
138
|
-
#
|
139
|
-
# Get help for this object type.
|
140
|
-
#
|
141
|
-
def self.help
|
142
|
-
return <<~TEXT
|
143
|
-
TABLE OBJECT TYPE
|
144
|
-
NAME: table
|
145
|
-
SHORTCUT: tbl
|
146
|
-
|
147
|
-
DESCRIPTION
|
148
|
-
A data table.
|
149
|
-
|
150
|
-
CHILDREN
|
151
|
-
headers - container
|
152
|
-
A list of headers.
|
153
|
-
The name of the header object needs to be the same as the
|
154
|
-
name of the object in the data container.
|
155
|
-
The value of the header is what will be displayed.
|
156
|
-
data - container
|
157
|
-
The table's data.
|
158
|
-
The data container will have one or more containers, each
|
159
|
-
of which represents one row of data.
|
160
|
-
|
161
|
-
MESSAGES
|
162
|
-
show - Show the contents of the table in the CLI.
|
163
|
-
TEXT
|
164
|
-
end
|
165
|
-
|
166
138
|
end
|
167
139
|
end
|
168
140
|
end
|
data/lib/gloo/objs/dev/git.rb
CHANGED
@@ -43,7 +43,9 @@ module Gloo
|
|
43
43
|
return super + %w[validate check_changes get_changes commit get_branch]
|
44
44
|
end
|
45
45
|
|
46
|
+
#
|
46
47
|
# Get the current working branch.
|
48
|
+
#
|
47
49
|
def msg_get_branch
|
48
50
|
branch = ''
|
49
51
|
path = path_value
|
@@ -55,7 +57,9 @@ module Gloo
|
|
55
57
|
$engine.heap.it.set_to branch
|
56
58
|
end
|
57
59
|
|
60
|
+
#
|
58
61
|
# Commit pending changes.
|
62
|
+
#
|
59
63
|
def msg_commit
|
60
64
|
msg = 'Commit'
|
61
65
|
path = path_value
|
@@ -74,7 +78,9 @@ module Gloo
|
|
74
78
|
$engine.heap.it.set_to msg
|
75
79
|
end
|
76
80
|
|
81
|
+
#
|
77
82
|
# Get the pending changes.
|
83
|
+
#
|
78
84
|
def msg_get_changes
|
79
85
|
path = path_value
|
80
86
|
result = `cd #{path}; git status -s` if path_is_dir?( path )
|
@@ -82,12 +88,16 @@ module Gloo
|
|
82
88
|
$engine.heap.it.set_to result
|
83
89
|
end
|
84
90
|
|
91
|
+
#
|
85
92
|
# Is the given path non nil and is it a directory?
|
93
|
+
#
|
86
94
|
def path_is_dir?( path )
|
87
95
|
return path && File.directory?( path )
|
88
96
|
end
|
89
97
|
|
98
|
+
#
|
90
99
|
# Check to see if the repo has changes.
|
100
|
+
#
|
91
101
|
def msg_check_changes
|
92
102
|
result = false
|
93
103
|
path = path_value
|
@@ -99,7 +109,9 @@ module Gloo
|
|
99
109
|
$engine.heap.it.set_to result
|
100
110
|
end
|
101
111
|
|
112
|
+
#
|
102
113
|
# Check to make sure this is a valide git repo.
|
114
|
+
#
|
103
115
|
def msg_validate
|
104
116
|
result = false
|
105
117
|
path = path_value
|
@@ -111,36 +123,6 @@ module Gloo
|
|
111
123
|
$engine.heap.it.set_to result
|
112
124
|
end
|
113
125
|
|
114
|
-
# ---------------------------------------------------------------------
|
115
|
-
# Help
|
116
|
-
# ---------------------------------------------------------------------
|
117
|
-
|
118
|
-
#
|
119
|
-
# Get help for this object type.
|
120
|
-
#
|
121
|
-
def self.help
|
122
|
-
return <<~TEXT
|
123
|
-
GIT OBJECT TYPE
|
124
|
-
NAME: git_repo
|
125
|
-
SHORTCUT: git
|
126
|
-
|
127
|
-
DESCRIPTION
|
128
|
-
Reference to a git repository in the file system.
|
129
|
-
The value of the git_repo objectd is a string.
|
130
|
-
There are no children needed.
|
131
|
-
|
132
|
-
CHILDREN
|
133
|
-
None
|
134
|
-
|
135
|
-
MESSAGES
|
136
|
-
validate - Validate that this is a git repo.
|
137
|
-
check_changes - Check to see if there are any pending changes.
|
138
|
-
get_changes - Get the list of pending changes.
|
139
|
-
commit - Commit changes.
|
140
|
-
get_branch - Get the current branch.
|
141
|
-
TEXT
|
142
|
-
end
|
143
|
-
|
144
126
|
end
|
145
127
|
end
|
146
128
|
end
|
data/lib/gloo/objs/dt/date.rb
CHANGED
@@ -36,37 +36,15 @@ module Gloo
|
|
36
36
|
return super + %w[now]
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
39
|
+
#
|
40
|
+
# Set to the current date.
|
41
|
+
#
|
40
42
|
def msg_now
|
41
43
|
t = DateTime.now.strftime( '%Y.%m.%d' )
|
42
44
|
self.value = t
|
43
45
|
$engine.heap.it.set_to t
|
44
46
|
end
|
45
47
|
|
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
48
|
end
|
71
49
|
end
|
72
50
|
end
|
@@ -30,7 +30,7 @@ module Gloo
|
|
30
30
|
#
|
31
31
|
def set_value( new_value )
|
32
32
|
unless new_value.is_a? DateTime
|
33
|
-
self.value = $engine.convert( new_value, 'DateTime', nil )
|
33
|
+
self.value = $engine.converter.convert( new_value, 'DateTime', nil )
|
34
34
|
return
|
35
35
|
end
|
36
36
|
|
@@ -48,37 +48,15 @@ module Gloo
|
|
48
48
|
return super + %w[now]
|
49
49
|
end
|
50
50
|
|
51
|
-
#
|
51
|
+
#
|
52
|
+
# Set to the current date and time.
|
53
|
+
#
|
52
54
|
def msg_now
|
53
55
|
t = DateTime.now.strftime( '%Y.%m.%d %I:%M:%S %P' )
|
54
56
|
self.value = t
|
55
57
|
$engine.heap.it.set_to t
|
56
58
|
end
|
57
59
|
|
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
60
|
end
|
83
61
|
end
|
84
62
|
end
|
data/lib/gloo/objs/dt/time.rb
CHANGED
@@ -36,37 +36,15 @@ module Gloo
|
|
36
36
|
return super + %w[now]
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
39
|
+
#
|
40
|
+
# Set to the current time.
|
41
|
+
#
|
40
42
|
def msg_now
|
41
43
|
t = DateTime.now.strftime( '%I:%M:%S %P' )
|
42
44
|
self.value = t
|
43
45
|
$engine.heap.it.set_to t
|
44
46
|
end
|
45
47
|
|
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
48
|
end
|
71
49
|
end
|
72
50
|
end
|
data/lib/gloo/objs/ror/erb.rb
CHANGED
@@ -40,7 +40,7 @@ module Gloo
|
|
40
40
|
end
|
41
41
|
|
42
42
|
#
|
43
|
-
# Set the result of the
|
43
|
+
# Set the result of the ERB template conversion.
|
44
44
|
#
|
45
45
|
def set_result( data )
|
46
46
|
r = find_child RESULT
|
@@ -68,30 +68,25 @@ module Gloo
|
|
68
68
|
# Children
|
69
69
|
# ---------------------------------------------------------------------
|
70
70
|
|
71
|
+
#
|
71
72
|
# Does this object have children to add when an object
|
72
73
|
# is created in interactive mode?
|
73
74
|
# This does not apply during obj load, etc.
|
75
|
+
#
|
74
76
|
def add_children_on_create?
|
75
77
|
return true
|
76
78
|
end
|
77
79
|
|
80
|
+
#
|
78
81
|
# Add children to this object.
|
79
82
|
# This is used by containers to add children needed
|
80
83
|
# for default configurations.
|
84
|
+
#
|
81
85
|
def add_default_children
|
82
86
|
fac = $engine.factory
|
83
|
-
fac.
|
84
|
-
|
85
|
-
|
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 } )
|
87
|
+
fac.create_text TEMPLATE, '', self
|
88
|
+
fac.create_can PARAMS, self
|
89
|
+
fac.create_text RESULT, '', self
|
95
90
|
end
|
96
91
|
|
97
92
|
# ---------------------------------------------------------------------
|
@@ -105,7 +100,9 @@ module Gloo
|
|
105
100
|
return super + [ 'run' ]
|
106
101
|
end
|
107
102
|
|
108
|
-
#
|
103
|
+
#
|
104
|
+
# Run the ERB template conversion.
|
105
|
+
#
|
109
106
|
def msg_run
|
110
107
|
tmpl = template_value
|
111
108
|
return unless tmpl
|
@@ -114,37 +111,6 @@ module Gloo
|
|
114
111
|
set_result render.result_with_hash( param_hash )
|
115
112
|
end
|
116
113
|
|
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
|
-
|
148
114
|
end
|
149
115
|
end
|
150
116
|
end
|
data/lib/gloo/objs/ror/eval.rb
CHANGED
@@ -11,6 +11,7 @@ module Gloo
|
|
11
11
|
KEYWORD = 'eval'.freeze
|
12
12
|
KEYWORD_SHORT = 'ruby'.freeze
|
13
13
|
CMD = 'command'.freeze
|
14
|
+
DEFAULT_CMD = '1+2'.freeze
|
14
15
|
RESULT = 'result'.freeze
|
15
16
|
|
16
17
|
#
|
@@ -52,26 +53,24 @@ module Gloo
|
|
52
53
|
# Children
|
53
54
|
# ---------------------------------------------------------------------
|
54
55
|
|
56
|
+
#
|
55
57
|
# Does this object have children to add when an object
|
56
58
|
# is created in interactive mode?
|
57
59
|
# This does not apply during obj load, etc.
|
60
|
+
#
|
58
61
|
def add_children_on_create?
|
59
62
|
return true
|
60
63
|
end
|
61
64
|
|
65
|
+
#
|
62
66
|
# Add children to this object.
|
63
67
|
# This is used by containers to add children needed
|
64
68
|
# for default configurations.
|
69
|
+
#
|
65
70
|
def add_default_children
|
66
71
|
fac = $engine.factory
|
67
|
-
fac.
|
68
|
-
|
69
|
-
:value => '1+2',
|
70
|
-
:parent => self } )
|
71
|
-
fac.create( { :name => 'result',
|
72
|
-
:type => 'string',
|
73
|
-
:value => nil,
|
74
|
-
:parent => self } )
|
72
|
+
fac.create_string CMD, DEFAULT_CMD, self
|
73
|
+
fac.create_string RESULT, nil, self
|
75
74
|
end
|
76
75
|
|
77
76
|
# ---------------------------------------------------------------------
|
@@ -85,7 +84,9 @@ module Gloo
|
|
85
84
|
return super + [ 'run' ]
|
86
85
|
end
|
87
86
|
|
88
|
-
#
|
87
|
+
#
|
88
|
+
# Run the command and evaluate the expression.
|
89
|
+
#
|
89
90
|
def msg_run
|
90
91
|
cmd = cmd_value
|
91
92
|
return unless cmd
|
@@ -97,38 +98,10 @@ module Gloo
|
|
97
98
|
set_result result
|
98
99
|
$engine.heap.it.set_to result
|
99
100
|
rescue => e
|
100
|
-
$
|
101
|
-
$engine.heap.error.set_to e.message
|
101
|
+
$engine.err e.message
|
102
102
|
end
|
103
103
|
end
|
104
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
|
-
|
132
105
|
end
|
133
106
|
end
|
134
107
|
end
|