gloo 5.1.0 → 5.2.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/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +15 -1
- data/lib/gloo/app/args.rb +9 -0
- data/lib/gloo/app/engine.rb +48 -2
- data/lib/gloo/app/mode.rb +1 -1
- data/lib/gloo/core/it.rb +14 -0
- data/lib/gloo/core/obj.rb +22 -1
- data/lib/gloo/core/obj_finder.rb +21 -0
- data/lib/gloo/expr/op_eq.rb +5 -0
- data/lib/gloo/objs/basic/string.rb +5 -228
- data/lib/gloo/objs/basic/string_msgs.rb +269 -0
- data/lib/gloo/objs/basic/text.rb +7 -1
- data/lib/gloo/objs/ctrl/each.rb +2 -0
- data/lib/gloo/objs/ctrl/each_dir.rb +72 -0
- data/lib/gloo/persist/disc_mech.rb +10 -1
- data/lib/gloo/persist/persist_man.rb +11 -2
- data/lib/gloo/plugin/ext_manager.rb +5 -0
- data/lib/gloo/plugin/lib_manager.rb +6 -0
- data/lib/gloo/verbs/eval.rb +43 -0
- data/lib/gloo/verbs/exists.rb +13 -0
- data/lib/gloo/verbs/reload.rb +2 -0
- data/lib/gloo/verbs/unload.rb +1 -0
- data/test.gloo/basic.test.gloo +53 -0
- data/test.gloo/lang/gloo_sys.test.gloo +91 -0
- data/test.gloo/lang/ops.test.gloo +79 -0
- data/test.gloo/math/add.test.gloo +46 -0
- data/test.gloo/math/div.test.gloo +37 -0
- data/test.gloo/math/mult.test.gloo +37 -0
- data/test.gloo/math/sub.test.gloo +37 -0
- data/test.gloo/objs/bool.test.gloo +60 -0
- data/test.gloo/objs/can.test.gloo +47 -0
- data/test.gloo/objs/int.test.gloo +56 -0
- data/test.gloo/objs/obj.test.gloo +52 -0
- data/test.gloo/objs/script.test.gloo +23 -0
- data/test.gloo/objs/text.test.gloo +84 -0
- data/test.gloo/objs/untyped.test.gloo +25 -0
- data/test.gloo/string/str.test.gloo +118 -0
- data/test.gloo/string/str_gen.test.gloo +76 -0
- data/test.gloo/verbs/break.test.gloo +22 -0
- data/test.gloo/verbs/check.test.gloo +35 -0
- data/test.gloo/verbs/eval.test.gloo +19 -0
- data/test.gloo/verbs/exists.test.gloo +49 -0
- data/test.gloo/verbs/if.test.gloo +16 -0
- data/test.gloo/verbs/log.test.gloo +14 -0
- data/test.gloo/verbs/move.test.gloo +20 -0
- data/test.gloo/verbs/put.test.gloo +19 -0
- data/test.gloo/verbs/run.test.gloo +16 -0
- data/test.gloo/verbs/tell.test.gloo +16 -0
- metadata +31 -3
- data/lib/gloo/objs/system/eval.rb +0 -107
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#
|
|
2
|
+
# String tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
string [can] :
|
|
7
|
+
|
|
8
|
+
on_load [script] :
|
|
9
|
+
log 'Include functionality for all test in on_load' (debug)
|
|
10
|
+
|
|
11
|
+
s [string] :
|
|
12
|
+
|
|
13
|
+
put_value [test] :
|
|
14
|
+
description [string] : Put a value into the string
|
|
15
|
+
on_test [script] :
|
|
16
|
+
put 'hello' into ^^.s
|
|
17
|
+
eval ^^.s = "hello"
|
|
18
|
+
assert "expected s to be 'hello'"
|
|
19
|
+
|
|
20
|
+
put ^^.s and ' world' into ^^.s
|
|
21
|
+
eval ^^.s = "hello world"
|
|
22
|
+
assert "expected s to be 'hello world'"
|
|
23
|
+
|
|
24
|
+
blank [test] :
|
|
25
|
+
description [string] : Check to see if the string is blank
|
|
26
|
+
on_test [script] :
|
|
27
|
+
put '' into ^^.s
|
|
28
|
+
check ^^.s for blank?
|
|
29
|
+
assert "expected s to be blank?"
|
|
30
|
+
|
|
31
|
+
put 'abc' into ^^.s
|
|
32
|
+
check ^^.s for blank?
|
|
33
|
+
refute "expected s to not be blank?"
|
|
34
|
+
|
|
35
|
+
uppercase [test] :
|
|
36
|
+
description [string] : Uppercase the string
|
|
37
|
+
on_test [script] :
|
|
38
|
+
put 'hello' into ^^.s
|
|
39
|
+
tell ^^.s to up
|
|
40
|
+
eval ^^.s = "HELLO"
|
|
41
|
+
assert "expected s to be 'HELLO'"
|
|
42
|
+
|
|
43
|
+
lowercase [test] :
|
|
44
|
+
description [string] : Lowercase the string
|
|
45
|
+
on_test [script] :
|
|
46
|
+
put 'HELLO' into ^^.s
|
|
47
|
+
tell ^^.s to down
|
|
48
|
+
eval ^^.s = "hello"
|
|
49
|
+
assert "expected s to be 'hello'"
|
|
50
|
+
|
|
51
|
+
length [test] :
|
|
52
|
+
description [string] : Get the length of the string
|
|
53
|
+
on_test [script] :
|
|
54
|
+
put 'hello' into ^^.s
|
|
55
|
+
tell ^^.s to size
|
|
56
|
+
eval it = 5
|
|
57
|
+
assert "expected length to be 5"
|
|
58
|
+
|
|
59
|
+
count_chars [test] :
|
|
60
|
+
description [string] : Get the number of characters
|
|
61
|
+
on_test [script] :
|
|
62
|
+
put 'hello' into ^^.s
|
|
63
|
+
tell ^^.s to count_chars
|
|
64
|
+
eval it = 5
|
|
65
|
+
assert "expected text to have 5 characters"
|
|
66
|
+
|
|
67
|
+
count_words [test] :
|
|
68
|
+
description [string] : Get the number of words
|
|
69
|
+
on_test [script] :
|
|
70
|
+
put 'hello' into ^^.s
|
|
71
|
+
tell ^^.s to count_words
|
|
72
|
+
eval it = 1
|
|
73
|
+
assert "expected text to have 1 word"
|
|
74
|
+
|
|
75
|
+
put '' into ^^.s
|
|
76
|
+
tell ^^.s to count_words
|
|
77
|
+
eval it = 0
|
|
78
|
+
assert "expected text to have no words"
|
|
79
|
+
|
|
80
|
+
put 'hello world!' into ^^.s
|
|
81
|
+
tell ^^.s to count_words
|
|
82
|
+
eval it = 2
|
|
83
|
+
assert "expected text to have 2 words"
|
|
84
|
+
|
|
85
|
+
count_lines [test] :
|
|
86
|
+
description [string] : Get the number of lines
|
|
87
|
+
on_test [script] :
|
|
88
|
+
put '' into ^^.s
|
|
89
|
+
tell ^^.s to count_lines
|
|
90
|
+
eval it = 0
|
|
91
|
+
assert "expected text to have 0 lines"
|
|
92
|
+
|
|
93
|
+
put 'hello world!' into ^^.s
|
|
94
|
+
tell ^^.s to count_lines
|
|
95
|
+
eval it = 1
|
|
96
|
+
assert "expected text to have 1 line"
|
|
97
|
+
|
|
98
|
+
starts_with [test] :
|
|
99
|
+
description [string] : Check if the string starts with a value
|
|
100
|
+
on_test [script] :
|
|
101
|
+
put 'hello' into ^^.s
|
|
102
|
+
tell ^^.s to starts_with? ('he')
|
|
103
|
+
assert "expected it to be true that s starts with 'he'"
|
|
104
|
+
|
|
105
|
+
ends_with [test] :
|
|
106
|
+
description [string] : Check if the string ends with a value
|
|
107
|
+
on_test [script] :
|
|
108
|
+
put 'hello' into ^^.s
|
|
109
|
+
tell ^^.s to ends_with? ('lo')
|
|
110
|
+
assert "expected it to be true that s ends with 'lo'"
|
|
111
|
+
|
|
112
|
+
contains [test] :
|
|
113
|
+
description [string] : Check if the string ends with a value
|
|
114
|
+
on_test [script] :
|
|
115
|
+
put 'hello world' into ^^.s
|
|
116
|
+
tell ^^.s to substring? ('lo w')
|
|
117
|
+
assert "expected it to be true that s contains 'lo w'"
|
|
118
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#
|
|
2
|
+
# String generation tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
string [can] :
|
|
7
|
+
|
|
8
|
+
on_load [script] :
|
|
9
|
+
log 'Include functionality for all test in on_load' (debug)
|
|
10
|
+
|
|
11
|
+
s [string] :
|
|
12
|
+
a [string] :
|
|
13
|
+
|
|
14
|
+
uuid [test] :
|
|
15
|
+
description [string] : Generate a couple of UUIDs
|
|
16
|
+
on_test [script] :
|
|
17
|
+
tell ^^.s to gen_uuid
|
|
18
|
+
tell ^^.a to gen_uuid
|
|
19
|
+
eval ^^.a != ^^.s
|
|
20
|
+
assert "expected a to be different from s"
|
|
21
|
+
|
|
22
|
+
tell ^^.a to size
|
|
23
|
+
eval it = 36
|
|
24
|
+
assert "expected a to be 36 characters long"
|
|
25
|
+
|
|
26
|
+
gen_alpha [test] :
|
|
27
|
+
description [string] : Generate a couple of alpha strings
|
|
28
|
+
on_test [script] :
|
|
29
|
+
tell ^^.s to gen_alphanumeric (10)
|
|
30
|
+
tell ^^.a to gen_alphanumeric (10)
|
|
31
|
+
eval ^^.a != ^^.s
|
|
32
|
+
assert "expected a to be different from s"
|
|
33
|
+
|
|
34
|
+
tell ^^.a to size
|
|
35
|
+
eval it = 10
|
|
36
|
+
assert "expected a to be 10 characters long"
|
|
37
|
+
|
|
38
|
+
tell ^^.a to gen_alphanumeric (7)
|
|
39
|
+
tell ^^.a to size
|
|
40
|
+
eval it = 7
|
|
41
|
+
assert "expected a to be 7 characters long"
|
|
42
|
+
|
|
43
|
+
gen_hex [test] :
|
|
44
|
+
description [string] : Generate a couple of hex strings
|
|
45
|
+
on_test [script] :
|
|
46
|
+
tell ^^.s to gen_hex (10)
|
|
47
|
+
tell ^^.a to gen_hex (10)
|
|
48
|
+
eval ^^.a != ^^.s
|
|
49
|
+
assert "expected a to be different from s"
|
|
50
|
+
|
|
51
|
+
tell ^^.a to size
|
|
52
|
+
eval it >= 10
|
|
53
|
+
assert "expected a to be 10 characters long"
|
|
54
|
+
|
|
55
|
+
tell ^^.a to gen_hex (30)
|
|
56
|
+
tell ^^.a to size
|
|
57
|
+
eval it >= 30
|
|
58
|
+
assert "expected a to be 30 characters long"
|
|
59
|
+
|
|
60
|
+
gen_base64 [test] :
|
|
61
|
+
description [string] : Generate a couple of base64 strings
|
|
62
|
+
on_test [script] :
|
|
63
|
+
tell ^^.s to gen_base64 (30)
|
|
64
|
+
tell ^^.a to gen_base64 (30)
|
|
65
|
+
eval ^^.a != ^^.s
|
|
66
|
+
assert "expected a to be different from s"
|
|
67
|
+
|
|
68
|
+
tell ^^.a to size
|
|
69
|
+
eval it >= 30
|
|
70
|
+
assert "expected a to be >= 30 characters long"
|
|
71
|
+
|
|
72
|
+
tell ^^.a to gen_base64 (10)
|
|
73
|
+
tell ^^.a to size
|
|
74
|
+
eval it >= 10
|
|
75
|
+
assert "expected a to be >= 10 characters long"
|
|
76
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Break verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
break [can] :
|
|
8
|
+
|
|
9
|
+
b [bool] : true
|
|
10
|
+
|
|
11
|
+
s [script] :
|
|
12
|
+
if ^.b then break
|
|
13
|
+
|
|
14
|
+
# Should not get here
|
|
15
|
+
put false into ^.b
|
|
16
|
+
|
|
17
|
+
break [test] :
|
|
18
|
+
description [string] : Break out of a script
|
|
19
|
+
on_test [script] :
|
|
20
|
+
tell ^^.s to run
|
|
21
|
+
eval ^^.b
|
|
22
|
+
assert "expected b to be true"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Check verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
check [can] :
|
|
8
|
+
|
|
9
|
+
c [container] :
|
|
10
|
+
a [string] : "a"
|
|
11
|
+
t [container] :
|
|
12
|
+
|
|
13
|
+
check_contains [test] :
|
|
14
|
+
description [string] : Check an object for containment
|
|
15
|
+
on_test [script] :
|
|
16
|
+
check ^^.c for contains?
|
|
17
|
+
assert "expected c to contain a"
|
|
18
|
+
|
|
19
|
+
check ^^.t for contains?
|
|
20
|
+
refute "expected t to not contain a"
|
|
21
|
+
|
|
22
|
+
check ^^.c.a for contains?
|
|
23
|
+
refute "expected a to not be a container"
|
|
24
|
+
|
|
25
|
+
check_blank [test] :
|
|
26
|
+
description [string] : Check an object for blankness
|
|
27
|
+
on_test [script] :
|
|
28
|
+
check ^^.c for blank?
|
|
29
|
+
refute "expected c to not be blank"
|
|
30
|
+
|
|
31
|
+
check ^^.t for blank?
|
|
32
|
+
assert "expected t to be blank"
|
|
33
|
+
|
|
34
|
+
check ^^.c.a for blank?
|
|
35
|
+
refute "expected a to not be blank"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Eval verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
eval [can] :
|
|
8
|
+
|
|
9
|
+
eval_expr [test] :
|
|
10
|
+
description [string] : Evaluate an expression.
|
|
11
|
+
on_test [script] :
|
|
12
|
+
eval 1 + 1 = 2
|
|
13
|
+
assert "expected 1 + 1 to equal 2"
|
|
14
|
+
|
|
15
|
+
eval true
|
|
16
|
+
assert "expected true to be true"
|
|
17
|
+
|
|
18
|
+
eval false
|
|
19
|
+
refute "expected false to be false"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Exists verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
exists [can] :
|
|
8
|
+
|
|
9
|
+
verb [test] :
|
|
10
|
+
description [string] : Check on existance of exists verb
|
|
11
|
+
on_test [script] :
|
|
12
|
+
exists? verb exists?
|
|
13
|
+
assert "expected exists? to exist"
|
|
14
|
+
|
|
15
|
+
exists? verb does_not_exist
|
|
16
|
+
refute "expected does_not_exist to not exist"
|
|
17
|
+
|
|
18
|
+
object [test] :
|
|
19
|
+
description [string] : Check on existance of exists object type
|
|
20
|
+
on_test [script] :
|
|
21
|
+
exists? object container
|
|
22
|
+
assert "expected container to exist"
|
|
23
|
+
|
|
24
|
+
exists? object can
|
|
25
|
+
assert "expected can to exist"
|
|
26
|
+
|
|
27
|
+
exists? object does_not_exist
|
|
28
|
+
refute "expected does_not_exist to not exist"
|
|
29
|
+
|
|
30
|
+
any_v_or_o [test] :
|
|
31
|
+
description [string] : Check on existance of any type
|
|
32
|
+
on_test [script] :
|
|
33
|
+
exists? str
|
|
34
|
+
assert "expected str to exist"
|
|
35
|
+
|
|
36
|
+
exists? show
|
|
37
|
+
assert "expected show to exist"
|
|
38
|
+
|
|
39
|
+
exists? does_not_exist
|
|
40
|
+
refute "expected does_not_exist to not exist"
|
|
41
|
+
|
|
42
|
+
instance [test] :
|
|
43
|
+
description [string] : Check on existance of objects.
|
|
44
|
+
on_test [script] :
|
|
45
|
+
exists? instance tests.verbs.exists.instance
|
|
46
|
+
assert "expected instance to exist"
|
|
47
|
+
|
|
48
|
+
exists? instance tests.verbs.exists.instance2
|
|
49
|
+
refute "expected instance to not exist"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#
|
|
2
|
+
# If verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
if [can] :
|
|
8
|
+
|
|
9
|
+
b [bool] : true
|
|
10
|
+
|
|
11
|
+
if_test [test] :
|
|
12
|
+
description [string] : If true then evaluate
|
|
13
|
+
on_test [script] :
|
|
14
|
+
eval false
|
|
15
|
+
if ^^.b then eval true
|
|
16
|
+
assert "expected b to be true"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Move verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
move [can] :
|
|
8
|
+
|
|
9
|
+
c [container] :
|
|
10
|
+
a [string] : "a"
|
|
11
|
+
t [container] :
|
|
12
|
+
|
|
13
|
+
move_a [test] :
|
|
14
|
+
description [string] : Move an object and verify.
|
|
15
|
+
on_test [script] :
|
|
16
|
+
move tests.verbs.move.c.a to tests.verbs.move.t
|
|
17
|
+
exists? instance tests.verbs.move.t.a
|
|
18
|
+
assert "expected a to be in t"
|
|
19
|
+
exists? instance tests.verbs.move.c.a
|
|
20
|
+
refute "expected a not to be in c"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Put verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
put [can] :
|
|
8
|
+
|
|
9
|
+
s [string] : abc
|
|
10
|
+
|
|
11
|
+
put_into [test] :
|
|
12
|
+
description [string] : Assign a value.
|
|
13
|
+
on_test [script] :
|
|
14
|
+
eval ^^.s = 'abc'
|
|
15
|
+
assert 'initial value is abc'
|
|
16
|
+
|
|
17
|
+
put 'xyz' into ^^.s
|
|
18
|
+
eval it = ^^.s
|
|
19
|
+
assert "expected it to be 'xyz'"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Tell verb tests
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
tests [can] :
|
|
6
|
+
verbs [can] :
|
|
7
|
+
tell [can] :
|
|
8
|
+
|
|
9
|
+
s [string] : abc123d
|
|
10
|
+
|
|
11
|
+
tell [test] :
|
|
12
|
+
description [string] : Tell verb sets value to it
|
|
13
|
+
on_test [script] :
|
|
14
|
+
tell ^^.s to count_chars
|
|
15
|
+
eval it = 7
|
|
16
|
+
assert "expected it to be 7"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gloo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Crane
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -348,10 +348,12 @@ files:
|
|
|
348
348
|
- lib/gloo/objs/basic/script.rb
|
|
349
349
|
- lib/gloo/objs/basic/string.rb
|
|
350
350
|
- lib/gloo/objs/basic/string_generator.rb
|
|
351
|
+
- lib/gloo/objs/basic/string_msgs.rb
|
|
351
352
|
- lib/gloo/objs/basic/text.rb
|
|
352
353
|
- lib/gloo/objs/basic/untyped.rb
|
|
353
354
|
- lib/gloo/objs/ctrl/each.rb
|
|
354
355
|
- lib/gloo/objs/ctrl/each_child.rb
|
|
356
|
+
- lib/gloo/objs/ctrl/each_dir.rb
|
|
355
357
|
- lib/gloo/objs/ctrl/each_file.rb
|
|
356
358
|
- lib/gloo/objs/ctrl/each_line.rb
|
|
357
359
|
- lib/gloo/objs/ctrl/each_word.rb
|
|
@@ -366,7 +368,6 @@ files:
|
|
|
366
368
|
- lib/gloo/objs/str_utils/outline.rb
|
|
367
369
|
- lib/gloo/objs/str_utils/password.rb
|
|
368
370
|
- lib/gloo/objs/system/erb.rb
|
|
369
|
-
- lib/gloo/objs/system/eval.rb
|
|
370
371
|
- lib/gloo/objs/system/file_handle.rb
|
|
371
372
|
- lib/gloo/objs/system/system.rb
|
|
372
373
|
- lib/gloo/objs/web/http_get.rb
|
|
@@ -390,6 +391,7 @@ files:
|
|
|
390
391
|
- lib/gloo/verbs/cls.rb
|
|
391
392
|
- lib/gloo/verbs/context.rb
|
|
392
393
|
- lib/gloo/verbs/create.rb
|
|
394
|
+
- lib/gloo/verbs/eval.rb
|
|
393
395
|
- lib/gloo/verbs/execute.rb
|
|
394
396
|
- lib/gloo/verbs/exists.rb
|
|
395
397
|
- lib/gloo/verbs/files.rb
|
|
@@ -413,6 +415,32 @@ files:
|
|
|
413
415
|
- lib/gloo/verbs/version.rb
|
|
414
416
|
- lib/gloo/verbs/wait.rb
|
|
415
417
|
- lib/run.rb
|
|
418
|
+
- test.gloo/basic.test.gloo
|
|
419
|
+
- test.gloo/lang/gloo_sys.test.gloo
|
|
420
|
+
- test.gloo/lang/ops.test.gloo
|
|
421
|
+
- test.gloo/math/add.test.gloo
|
|
422
|
+
- test.gloo/math/div.test.gloo
|
|
423
|
+
- test.gloo/math/mult.test.gloo
|
|
424
|
+
- test.gloo/math/sub.test.gloo
|
|
425
|
+
- test.gloo/objs/bool.test.gloo
|
|
426
|
+
- test.gloo/objs/can.test.gloo
|
|
427
|
+
- test.gloo/objs/int.test.gloo
|
|
428
|
+
- test.gloo/objs/obj.test.gloo
|
|
429
|
+
- test.gloo/objs/script.test.gloo
|
|
430
|
+
- test.gloo/objs/text.test.gloo
|
|
431
|
+
- test.gloo/objs/untyped.test.gloo
|
|
432
|
+
- test.gloo/string/str.test.gloo
|
|
433
|
+
- test.gloo/string/str_gen.test.gloo
|
|
434
|
+
- test.gloo/verbs/break.test.gloo
|
|
435
|
+
- test.gloo/verbs/check.test.gloo
|
|
436
|
+
- test.gloo/verbs/eval.test.gloo
|
|
437
|
+
- test.gloo/verbs/exists.test.gloo
|
|
438
|
+
- test.gloo/verbs/if.test.gloo
|
|
439
|
+
- test.gloo/verbs/log.test.gloo
|
|
440
|
+
- test.gloo/verbs/move.test.gloo
|
|
441
|
+
- test.gloo/verbs/put.test.gloo
|
|
442
|
+
- test.gloo/verbs/run.test.gloo
|
|
443
|
+
- test.gloo/verbs/tell.test.gloo
|
|
416
444
|
homepage: http://github.com/ecrane/gloo
|
|
417
445
|
licenses:
|
|
418
446
|
- MIT
|
|
@@ -1,107 +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 that evaluate a ruby statement.
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
module Gloo
|
|
8
|
-
module Objs
|
|
9
|
-
class Eval < Gloo::Core::Obj
|
|
10
|
-
|
|
11
|
-
KEYWORD = 'eval'.freeze
|
|
12
|
-
KEYWORD_SHORT = 'ruby'.freeze
|
|
13
|
-
CMD = 'command'.freeze
|
|
14
|
-
DEFAULT_CMD = '1+2'.freeze
|
|
15
|
-
RESULT = 'result'.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 cmd_value
|
|
36
|
-
cmd = find_child CMD
|
|
37
|
-
return nil unless cmd
|
|
38
|
-
|
|
39
|
-
return cmd.value
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
# Set the result of the system call.
|
|
44
|
-
#
|
|
45
|
-
def set_result( data )
|
|
46
|
-
r = find_child RESULT
|
|
47
|
-
return nil unless r
|
|
48
|
-
|
|
49
|
-
r.set_value data
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# ---------------------------------------------------------------------
|
|
53
|
-
# Children
|
|
54
|
-
# ---------------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
#
|
|
57
|
-
# Does this object have children to add when an object
|
|
58
|
-
# is created in interactive mode?
|
|
59
|
-
# This does not apply during obj load, etc.
|
|
60
|
-
#
|
|
61
|
-
def add_children_on_create?
|
|
62
|
-
return true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
#
|
|
66
|
-
# Add children to this object.
|
|
67
|
-
# This is used by containers to add children needed
|
|
68
|
-
# for default configurations.
|
|
69
|
-
#
|
|
70
|
-
def add_default_children
|
|
71
|
-
fac = @engine.factory
|
|
72
|
-
fac.create_string CMD, DEFAULT_CMD, self
|
|
73
|
-
fac.create_string RESULT, nil, self
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# ---------------------------------------------------------------------
|
|
77
|
-
# Messages
|
|
78
|
-
# ---------------------------------------------------------------------
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
# Get a list of message names that this object receives.
|
|
82
|
-
#
|
|
83
|
-
def self.messages
|
|
84
|
-
return super + [ 'run' ]
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
# Run the command and evaluate the expression.
|
|
89
|
-
#
|
|
90
|
-
def msg_run
|
|
91
|
-
cmd = cmd_value
|
|
92
|
-
return unless cmd
|
|
93
|
-
|
|
94
|
-
begin
|
|
95
|
-
# rubocop:disable Security/Eval
|
|
96
|
-
result = eval cmd
|
|
97
|
-
# rubocop:enable Security/Eval
|
|
98
|
-
set_result result
|
|
99
|
-
@engine.heap.it.set_to result
|
|
100
|
-
rescue => e
|
|
101
|
-
@engine.log_exception e
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|