gloo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +73 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +3 -3
- data/Rakefile +6 -6
- data/bin/console +4 -4
- data/gloo.gemspec +19 -18
- data/lib/gloo.rb +6 -6
- data/lib/gloo/app/args.rb +30 -31
- data/lib/gloo/app/engine.rb +33 -28
- 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 +43 -40
- 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 -19
- data/lib/gloo/core/factory.rb +92 -39
- data/lib/gloo/core/gloo_system.rb +49 -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 +89 -79
- data/lib/gloo/core/obj_finder.rb +9 -14
- data/lib/gloo/core/op.rb +8 -8
- data/lib/gloo/core/parser.rb +25 -26
- data/lib/gloo/core/pn.rb +65 -50
- data/lib/gloo/core/runner.rb +26 -0
- 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/expr/expression.rb +35 -43
- data/lib/gloo/expr/l_boolean.rb +7 -6
- 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 +3 -5
- data/lib/gloo/expr/op_minus.rb +3 -5
- data/lib/gloo/expr/op_mult.rb +3 -5
- data/lib/gloo/expr/op_plus.rb +5 -7
- data/lib/gloo/objs/basic/boolean.rb +63 -38
- data/lib/gloo/objs/basic/container.rb +40 -12
- data/lib/gloo/objs/basic/integer.rb +40 -16
- data/lib/gloo/objs/basic/script.rb +62 -38
- data/lib/gloo/objs/basic/string.rb +39 -15
- data/lib/gloo/objs/basic/text.rb +43 -20
- data/lib/gloo/objs/basic/untyped.rb +35 -10
- data/lib/gloo/objs/cli/colorize.rb +53 -23
- data/lib/gloo/objs/cli/confirm.rb +63 -29
- data/lib/gloo/objs/cli/prompt.rb +63 -29
- data/lib/gloo/objs/ctrl/each.rb +98 -60
- data/lib/gloo/objs/dev/git.rb +98 -64
- data/lib/gloo/objs/ror/erb.rb +81 -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 +80 -48
- data/lib/gloo/objs/system/system.rb +84 -38
- data/lib/gloo/objs/web/http_get.rb +83 -46
- data/lib/gloo/objs/web/http_post.rb +69 -43
- data/lib/gloo/objs/web/slack.rb +89 -58
- data/lib/gloo/objs/web/teams.rb +88 -53
- data/lib/gloo/persist/file_loader.rb +81 -82
- 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 +74 -0
- data/lib/gloo/persist/persist_man.rb +29 -29
- 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/context.rb +61 -21
- data/lib/gloo/verbs/create.rb +52 -21
- data/lib/gloo/verbs/help.rb +177 -27
- data/lib/gloo/verbs/if.rb +54 -21
- data/lib/gloo/verbs/list.rb +55 -24
- data/lib/gloo/verbs/load.rb +46 -12
- data/lib/gloo/verbs/put.rb +90 -34
- data/lib/gloo/verbs/quit.rb +43 -12
- data/lib/gloo/verbs/run.rb +42 -11
- data/lib/gloo/verbs/save.rb +45 -10
- data/lib/gloo/verbs/show.rb +56 -22
- data/lib/gloo/verbs/tell.rb +44 -12
- data/lib/gloo/verbs/unless.rb +55 -21
- data/lib/gloo/verbs/version.rb +42 -12
- data/lib/run.rb +5 -5
- metadata +19 -12
data/lib/gloo/verbs/quit.rb
CHANGED
@@ -7,34 +7,65 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Verbs
|
9
9
|
class Quit < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'quit'
|
12
|
-
KEYWORD_SHORT = 'q'
|
13
10
|
|
14
|
-
|
11
|
+
KEYWORD = 'quit'.freeze
|
12
|
+
KEYWORD_SHORT = 'q'.freeze
|
13
|
+
|
14
|
+
#
|
15
15
|
# Run the verb.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# We'll mark the application as not running and let the
|
18
18
|
# engine stop gracefully next time through the loop.
|
19
|
-
#
|
19
|
+
#
|
20
20
|
def run
|
21
21
|
$engine.stop_running
|
22
22
|
end
|
23
|
-
|
24
|
-
#
|
23
|
+
|
24
|
+
#
|
25
25
|
# Get the Verb's keyword.
|
26
|
-
#
|
26
|
+
#
|
27
27
|
def self.keyword
|
28
28
|
return KEYWORD
|
29
29
|
end
|
30
|
-
|
31
|
-
#
|
30
|
+
|
31
|
+
#
|
32
32
|
# Get the Verb's keyword shortcut.
|
33
|
-
#
|
33
|
+
#
|
34
34
|
def self.keyword_shortcut
|
35
35
|
return KEYWORD_SHORT
|
36
36
|
end
|
37
37
|
|
38
|
+
# ---------------------------------------------------------------------
|
39
|
+
# Help
|
40
|
+
# ---------------------------------------------------------------------
|
41
|
+
|
42
|
+
#
|
43
|
+
# Get help for this verb.
|
44
|
+
#
|
45
|
+
def self.help
|
46
|
+
return <<~TEXT
|
47
|
+
QUIT VERB
|
48
|
+
NAME: quit
|
49
|
+
SHORTCUT: q
|
50
|
+
|
51
|
+
DESCRIPTION
|
52
|
+
Stop running the gloo application.
|
53
|
+
Cleanup and shutdown.
|
54
|
+
|
55
|
+
SYNTAX
|
56
|
+
quit
|
57
|
+
|
58
|
+
PARAMETERS
|
59
|
+
None
|
60
|
+
|
61
|
+
RESULT
|
62
|
+
None
|
63
|
+
|
64
|
+
ERRORS
|
65
|
+
None
|
66
|
+
TEXT
|
67
|
+
end
|
68
|
+
|
38
69
|
end
|
39
70
|
end
|
40
71
|
end
|
data/lib/gloo/verbs/run.rb
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
module Gloo
|
9
9
|
module Verbs
|
10
10
|
class Run < Gloo::Core::Verb
|
11
|
-
|
12
|
-
KEYWORD = 'run'
|
13
|
-
KEYWORD_SHORT = 'r'
|
14
|
-
|
15
|
-
#
|
11
|
+
|
12
|
+
KEYWORD = 'run'.freeze
|
13
|
+
KEYWORD_SHORT = 'r'.freeze
|
14
|
+
|
15
|
+
#
|
16
16
|
# Run the verb.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
def run
|
19
19
|
name = @tokens.second
|
20
20
|
pn = Gloo::Core::Pn.new name
|
@@ -26,21 +26,52 @@ module Gloo
|
|
26
26
|
$log.error "Could not send message to object. Bad path: #{name}"
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
#
|
29
|
+
|
30
|
+
#
|
31
31
|
# Get the Verb's keyword.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
def self.keyword
|
34
34
|
return KEYWORD
|
35
35
|
end
|
36
36
|
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# Get the Verb's keyword shortcut.
|
39
|
-
#
|
39
|
+
#
|
40
40
|
def self.keyword_shortcut
|
41
41
|
return KEYWORD_SHORT
|
42
42
|
end
|
43
43
|
|
44
|
+
# ---------------------------------------------------------------------
|
45
|
+
# Help
|
46
|
+
# ---------------------------------------------------------------------
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get help for this verb.
|
50
|
+
#
|
51
|
+
def self.help
|
52
|
+
return <<~TEXT
|
53
|
+
RUN VERB
|
54
|
+
NAME: run
|
55
|
+
SHORTCUT: r
|
56
|
+
|
57
|
+
DESCRIPTION
|
58
|
+
Run a script or other object.
|
59
|
+
This is the same as sending a 'run' message to the object.
|
60
|
+
|
61
|
+
SYNTAX
|
62
|
+
run <path.to.object>
|
63
|
+
|
64
|
+
PARAMETERS
|
65
|
+
path.to.object - Reference to the object which will be run.
|
66
|
+
|
67
|
+
RESULT
|
68
|
+
The result depends on the object that is run.
|
69
|
+
|
70
|
+
ERRORS
|
71
|
+
The errors depend on the object that is run.
|
72
|
+
TEXT
|
73
|
+
end
|
74
|
+
|
44
75
|
end
|
45
76
|
end
|
46
77
|
end
|
data/lib/gloo/verbs/save.rb
CHANGED
@@ -7,31 +7,66 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Verbs
|
9
9
|
class Save < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'save'
|
12
|
-
KEYWORD_SHORT = '>'
|
13
10
|
|
14
|
-
|
11
|
+
KEYWORD = 'save'.freeze
|
12
|
+
KEYWORD_SHORT = '>'.freeze
|
13
|
+
|
14
|
+
#
|
15
15
|
# Run the verb.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
def run
|
18
|
+
# TODO: Not currently using folders or keeping
|
19
|
+
# track of where the object was loaded from.
|
18
20
|
$engine.persist_man.save @tokens.second
|
19
21
|
end
|
20
|
-
|
21
|
-
#
|
22
|
+
|
23
|
+
#
|
22
24
|
# Get the Verb's keyword.
|
23
|
-
#
|
25
|
+
#
|
24
26
|
def self.keyword
|
25
27
|
return KEYWORD
|
26
28
|
end
|
27
29
|
|
28
|
-
#
|
30
|
+
#
|
29
31
|
# Get the Verb's keyword shortcut.
|
30
|
-
#
|
32
|
+
#
|
31
33
|
def self.keyword_shortcut
|
32
34
|
return KEYWORD_SHORT
|
33
35
|
end
|
34
36
|
|
37
|
+
# ---------------------------------------------------------------------
|
38
|
+
# Help
|
39
|
+
# ---------------------------------------------------------------------
|
40
|
+
|
41
|
+
#
|
42
|
+
# Get help for this verb.
|
43
|
+
#
|
44
|
+
def self.help
|
45
|
+
return <<~TEXT
|
46
|
+
SAVE VERB
|
47
|
+
NAME: save
|
48
|
+
SHORTCUT: >
|
49
|
+
|
50
|
+
DESCRIPTION
|
51
|
+
Stop running the gloo application.
|
52
|
+
Cleanup and shutdown.
|
53
|
+
|
54
|
+
SYNTAX
|
55
|
+
save <path.to.object>
|
56
|
+
Save a previously loaded object. The path will be for the
|
57
|
+
root level object that was loaded earlier.
|
58
|
+
|
59
|
+
PARAMETERS
|
60
|
+
path.to.object - Name of the object file that is to be saved.
|
61
|
+
|
62
|
+
RESULT
|
63
|
+
The file is updated with the latest object state.
|
64
|
+
|
65
|
+
ERRORS
|
66
|
+
None
|
67
|
+
TEXT
|
68
|
+
end
|
69
|
+
|
35
70
|
end
|
36
71
|
end
|
37
72
|
end
|
data/lib/gloo/verbs/show.rb
CHANGED
@@ -8,47 +8,81 @@ require 'colorized_string'
|
|
8
8
|
module Gloo
|
9
9
|
module Verbs
|
10
10
|
class Show < Gloo::Core::Verb
|
11
|
-
|
12
|
-
KEYWORD = 'show'
|
13
|
-
KEYWORD_SHORT = '='
|
14
11
|
|
15
|
-
|
12
|
+
KEYWORD = 'show'.freeze
|
13
|
+
KEYWORD_SHORT = '='.freeze
|
14
|
+
|
15
|
+
#
|
16
16
|
# Run the verb.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
def run
|
19
19
|
if @tokens.token_count > 1
|
20
20
|
expr = Gloo::Expr::Expression.new( @tokens.params )
|
21
|
-
|
21
|
+
result = expr.evaluate
|
22
22
|
$log.show get_formatted_string( result )
|
23
23
|
$engine.heap.it.set_to result
|
24
24
|
else
|
25
|
-
$log.show
|
25
|
+
$log.show ''
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
#
|
28
|
+
|
29
|
+
#
|
30
30
|
# Get the Verb's keyword.
|
31
|
-
#
|
31
|
+
#
|
32
32
|
def self.keyword
|
33
33
|
return KEYWORD
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
#
|
37
37
|
# Get the Verb's keyword shortcut.
|
38
|
-
#
|
38
|
+
#
|
39
39
|
def self.keyword_shortcut
|
40
40
|
return KEYWORD_SHORT
|
41
41
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
|
43
|
+
#
|
44
|
+
# Get the formatted string.
|
45
|
+
#
|
46
|
+
def get_formatted_string( str )
|
47
|
+
if @params&.token_count&.positive?
|
48
|
+
expr = Gloo::Expr::Expression.new( @params.tokens )
|
49
|
+
val = expr.evaluate
|
50
|
+
color = val.to_sym
|
51
|
+
return ColorizedString[ str.to_s ].colorize( color )
|
52
|
+
end
|
53
|
+
return str
|
54
|
+
end
|
55
|
+
|
56
|
+
# ---------------------------------------------------------------------
|
57
|
+
# Help
|
58
|
+
# ---------------------------------------------------------------------
|
59
|
+
|
60
|
+
#
|
61
|
+
# Get help for this verb.
|
62
|
+
#
|
63
|
+
def self.help
|
64
|
+
return <<~TEXT
|
65
|
+
SHOW VERB
|
66
|
+
NAME: show
|
67
|
+
SHORTCUT: =
|
68
|
+
|
69
|
+
DESCRIPTION
|
70
|
+
Show an object's value.
|
71
|
+
|
72
|
+
SYNTAX
|
73
|
+
show <path.to.object>
|
74
|
+
|
75
|
+
PARAMETERS
|
76
|
+
path.to.object - The object that we want to see.
|
77
|
+
|
78
|
+
RESULT
|
79
|
+
The object's value is shown.
|
80
|
+
<it> will contain the object's value.
|
81
|
+
|
82
|
+
ERRORS
|
83
|
+
None
|
84
|
+
TEXT
|
85
|
+
end
|
52
86
|
|
53
87
|
end
|
54
88
|
end
|
data/lib/gloo/verbs/tell.rb
CHANGED
@@ -7,14 +7,14 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Verbs
|
9
9
|
class Tell < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'tell'
|
12
|
-
KEYWORD_SHORT = '->'
|
13
|
-
TO = 'to'
|
14
|
-
|
15
|
-
#
|
10
|
+
|
11
|
+
KEYWORD = 'tell'.freeze
|
12
|
+
KEYWORD_SHORT = '->'.freeze
|
13
|
+
TO = 'to'.freeze
|
14
|
+
|
15
|
+
#
|
16
16
|
# Run the verb.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
def run
|
19
19
|
name = @tokens.second
|
20
20
|
msg = @tokens.after_token( TO )
|
@@ -27,21 +27,53 @@ module Gloo
|
|
27
27
|
$log.error "Could not send message to object. Bad path: #{name}"
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
#
|
30
|
+
|
31
|
+
#
|
32
32
|
# Get the Verb's keyword.
|
33
|
-
#
|
33
|
+
#
|
34
34
|
def self.keyword
|
35
35
|
return KEYWORD
|
36
36
|
end
|
37
37
|
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# Get the Verb's keyword shortcut.
|
40
|
-
#
|
40
|
+
#
|
41
41
|
def self.keyword_shortcut
|
42
42
|
return KEYWORD_SHORT
|
43
43
|
end
|
44
44
|
|
45
|
+
# ---------------------------------------------------------------------
|
46
|
+
# Help
|
47
|
+
# ---------------------------------------------------------------------
|
48
|
+
|
49
|
+
#
|
50
|
+
# Get help for this verb.
|
51
|
+
#
|
52
|
+
def self.help
|
53
|
+
return <<~TEXT
|
54
|
+
TELL VERB
|
55
|
+
NAME: tell
|
56
|
+
SHORTCUT: ->
|
57
|
+
|
58
|
+
DESCRIPTION
|
59
|
+
Send a message to an object.
|
60
|
+
Ask the object to perform an action.
|
61
|
+
|
62
|
+
SYNTAX
|
63
|
+
tell <path.to.object> to <message>
|
64
|
+
|
65
|
+
PARAMETERS
|
66
|
+
path.to.object - The object that we want to see.
|
67
|
+
message - The message to send.
|
68
|
+
|
69
|
+
RESULT
|
70
|
+
The result depends on the message that is sent.
|
71
|
+
|
72
|
+
ERRORS
|
73
|
+
Errors depend on the message that is sent.
|
74
|
+
TEXT
|
75
|
+
end
|
76
|
+
|
45
77
|
end
|
46
78
|
end
|
47
79
|
end
|
data/lib/gloo/verbs/unless.rb
CHANGED
@@ -7,50 +7,84 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Verbs
|
9
9
|
class Unless < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'unless'
|
12
|
-
KEYWORD_SHORT = 'if!'
|
13
|
-
THEN = 'do'
|
14
|
-
|
15
|
-
#
|
10
|
+
|
11
|
+
KEYWORD = 'unless'.freeze
|
12
|
+
KEYWORD_SHORT = 'if!'.freeze
|
13
|
+
THEN = 'do'.freeze
|
14
|
+
|
15
|
+
#
|
16
16
|
# Run the verb.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
def run
|
19
19
|
value = @tokens.before_token( THEN )
|
20
20
|
if value.count > 1
|
21
21
|
# The first token is the verb, so we drop it.
|
22
|
-
value = value[1..-1]
|
22
|
+
value = value[ 1..-1 ]
|
23
23
|
end
|
24
24
|
|
25
25
|
evals_false = false
|
26
|
-
if value.count
|
26
|
+
if value.count.positive?
|
27
27
|
expr = Gloo::Expr::Expression.new( value )
|
28
28
|
result = expr.evaluate
|
29
29
|
evals_false = true if result == false
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
return unless evals_false
|
32
|
+
|
33
|
+
cmd = @tokens.expr_after( THEN )
|
34
|
+
i = $engine.parser.parse_immediate cmd
|
35
|
+
return unless i
|
36
|
+
|
37
|
+
i.run
|
38
38
|
end
|
39
|
-
|
40
|
-
#
|
39
|
+
|
40
|
+
#
|
41
41
|
# Get the Verb's keyword.
|
42
|
-
#
|
42
|
+
#
|
43
43
|
def self.keyword
|
44
44
|
return KEYWORD
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# Get the Verb's keyword shortcut.
|
49
|
-
#
|
49
|
+
#
|
50
50
|
def self.keyword_shortcut
|
51
51
|
return KEYWORD_SHORT
|
52
52
|
end
|
53
53
|
|
54
|
+
# ---------------------------------------------------------------------
|
55
|
+
# Help
|
56
|
+
# ---------------------------------------------------------------------
|
57
|
+
|
58
|
+
#
|
59
|
+
# Get help for this verb.
|
60
|
+
#
|
61
|
+
def self.help
|
62
|
+
return <<~TEXT
|
63
|
+
UNLESS VERB
|
64
|
+
NAME: unless
|
65
|
+
SHORTCUT: if!
|
66
|
+
|
67
|
+
DESCRIPTION
|
68
|
+
Unless an expression is true, do something.
|
69
|
+
This is the opposite of the if verb.
|
70
|
+
|
71
|
+
SYNTAX
|
72
|
+
unless <true> do <do>
|
73
|
+
|
74
|
+
PARAMETERS
|
75
|
+
true - Does the expression evaluate to true?
|
76
|
+
do - Execute command if the expression is not true.
|
77
|
+
|
78
|
+
RESULT
|
79
|
+
Unchanged if the expression is true.
|
80
|
+
If not true, then the result will be based on the command
|
81
|
+
specified after the 'do' keyword.
|
82
|
+
|
83
|
+
ERRORS
|
84
|
+
The errors depend on the object that is run.
|
85
|
+
TEXT
|
86
|
+
end
|
87
|
+
|
54
88
|
end
|
55
89
|
end
|
56
90
|
end
|