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
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 )
|
|
@@ -22,26 +22,58 @@ module Gloo
|
|
|
22
22
|
o = pn.resolve
|
|
23
23
|
|
|
24
24
|
if o
|
|
25
|
-
|
|
25
|
+
Gloo::Exec::Dispatch.message msg, o, @params
|
|
26
26
|
else
|
|
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,85 @@
|
|
|
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
|
+
evals_false = true if result.is_a?( Numeric ) && result.zero?
|
|
30
31
|
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
return unless evals_false
|
|
33
|
+
|
|
34
|
+
cmd = @tokens.expr_after( THEN )
|
|
35
|
+
i = $engine.parser.parse_immediate cmd
|
|
36
|
+
return unless i
|
|
37
|
+
|
|
38
|
+
i.run
|
|
38
39
|
end
|
|
39
|
-
|
|
40
|
-
#
|
|
40
|
+
|
|
41
|
+
#
|
|
41
42
|
# Get the Verb's keyword.
|
|
42
|
-
#
|
|
43
|
+
#
|
|
43
44
|
def self.keyword
|
|
44
45
|
return KEYWORD
|
|
45
46
|
end
|
|
46
47
|
|
|
47
|
-
#
|
|
48
|
+
#
|
|
48
49
|
# Get the Verb's keyword shortcut.
|
|
49
|
-
#
|
|
50
|
+
#
|
|
50
51
|
def self.keyword_shortcut
|
|
51
52
|
return KEYWORD_SHORT
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
# ---------------------------------------------------------------------
|
|
56
|
+
# Help
|
|
57
|
+
# ---------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# Get help for this verb.
|
|
61
|
+
#
|
|
62
|
+
def self.help
|
|
63
|
+
return <<~TEXT
|
|
64
|
+
UNLESS VERB
|
|
65
|
+
NAME: unless
|
|
66
|
+
SHORTCUT: if!
|
|
67
|
+
|
|
68
|
+
DESCRIPTION
|
|
69
|
+
Unless an expression is true, do something.
|
|
70
|
+
This is the opposite of the if verb.
|
|
71
|
+
|
|
72
|
+
SYNTAX
|
|
73
|
+
unless <true> do <do>
|
|
74
|
+
|
|
75
|
+
PARAMETERS
|
|
76
|
+
true - Does the expression evaluate to true?
|
|
77
|
+
do - Execute command if the expression is not true.
|
|
78
|
+
|
|
79
|
+
RESULT
|
|
80
|
+
Unchanged if the expression is true.
|
|
81
|
+
If not true, then the result will be based on the command
|
|
82
|
+
specified after the 'do' keyword.
|
|
83
|
+
|
|
84
|
+
ERRORS
|
|
85
|
+
The errors depend on the object that is run.
|
|
86
|
+
TEXT
|
|
87
|
+
end
|
|
88
|
+
|
|
54
89
|
end
|
|
55
90
|
end
|
|
56
91
|
end
|
data/lib/gloo/verbs/version.rb
CHANGED
|
@@ -7,31 +7,61 @@
|
|
|
7
7
|
module Gloo
|
|
8
8
|
module Verbs
|
|
9
9
|
class Version < Gloo::Core::Verb
|
|
10
|
-
|
|
11
|
-
KEYWORD = 'version'
|
|
12
|
-
KEYWORD_SHORT = 'v'
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
KEYWORD = 'version'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'v'.freeze
|
|
13
|
+
|
|
14
|
+
#
|
|
15
15
|
# Run the verb.
|
|
16
|
-
#
|
|
16
|
+
#
|
|
17
17
|
def run
|
|
18
18
|
$log.show Gloo::App::Info.display_title
|
|
19
19
|
end
|
|
20
|
-
|
|
21
|
-
#
|
|
20
|
+
|
|
21
|
+
#
|
|
22
22
|
# Get the Verb's keyword.
|
|
23
|
-
#
|
|
23
|
+
#
|
|
24
24
|
def self.keyword
|
|
25
25
|
return KEYWORD
|
|
26
26
|
end
|
|
27
|
-
|
|
28
|
-
#
|
|
27
|
+
|
|
28
|
+
#
|
|
29
29
|
# Get the Verb's keyword shortcut.
|
|
30
|
-
#
|
|
30
|
+
#
|
|
31
31
|
def self.keyword_shortcut
|
|
32
32
|
return KEYWORD_SHORT
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
# ---------------------------------------------------------------------
|
|
36
|
+
# Help
|
|
37
|
+
# ---------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Get help for this verb.
|
|
41
|
+
#
|
|
42
|
+
def self.help
|
|
43
|
+
return <<~TEXT
|
|
44
|
+
VERSION VERB
|
|
45
|
+
NAME: version
|
|
46
|
+
SHORTCUT: v
|
|
47
|
+
|
|
48
|
+
DESCRIPTION
|
|
49
|
+
Show the application version information.
|
|
50
|
+
|
|
51
|
+
SYNTAX
|
|
52
|
+
version
|
|
53
|
+
|
|
54
|
+
PARAMETERS
|
|
55
|
+
None
|
|
56
|
+
|
|
57
|
+
RESULT
|
|
58
|
+
None
|
|
59
|
+
|
|
60
|
+
ERRORS
|
|
61
|
+
None
|
|
62
|
+
TEXT
|
|
63
|
+
end
|
|
64
|
+
|
|
35
65
|
end
|
|
36
66
|
end
|
|
37
67
|
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Wait for the given number of seconds.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
module Gloo
|
|
8
|
+
module Verbs
|
|
9
|
+
class Wait < Gloo::Core::Verb
|
|
10
|
+
|
|
11
|
+
KEYWORD = 'wait'.freeze
|
|
12
|
+
KEYWORD_SHORT = 'w'.freeze
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Run the verb.
|
|
16
|
+
#
|
|
17
|
+
def run
|
|
18
|
+
x = 1
|
|
19
|
+
if @tokens.token_count > 1
|
|
20
|
+
expr = Gloo::Expr::Expression.new( @tokens.params )
|
|
21
|
+
x = expr.evaluate.to_i
|
|
22
|
+
end
|
|
23
|
+
sleep x
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Get the Verb's keyword.
|
|
28
|
+
#
|
|
29
|
+
def self.keyword
|
|
30
|
+
return KEYWORD
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Get the Verb's keyword shortcut.
|
|
35
|
+
#
|
|
36
|
+
def self.keyword_shortcut
|
|
37
|
+
return KEYWORD_SHORT
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# ---------------------------------------------------------------------
|
|
41
|
+
# Help
|
|
42
|
+
# ---------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# Get help for this verb.
|
|
46
|
+
#
|
|
47
|
+
def self.help
|
|
48
|
+
return <<~TEXT
|
|
49
|
+
WAIT VERB
|
|
50
|
+
NAME: wait
|
|
51
|
+
SHORTCUT: w
|
|
52
|
+
|
|
53
|
+
DESCRIPTION
|
|
54
|
+
Wait for the given number of seconds.
|
|
55
|
+
|
|
56
|
+
SYNTAX
|
|
57
|
+
wait <seconds>
|
|
58
|
+
|
|
59
|
+
PARAMETERS
|
|
60
|
+
seconds - The number of seconds.
|
|
61
|
+
If no value is given, we'll wait for 1 second.
|
|
62
|
+
|
|
63
|
+
RESULT
|
|
64
|
+
None
|
|
65
|
+
|
|
66
|
+
ERRORS
|
|
67
|
+
None
|
|
68
|
+
TEXT
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|