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
@@ -7,36 +7,61 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Objs
|
9
9
|
class Untyped < Gloo::Core::Obj
|
10
|
-
|
11
|
-
KEYWORD = 'untyped'
|
12
|
-
KEYWORD_SHORT = 'un'
|
13
10
|
|
14
|
-
|
11
|
+
KEYWORD = 'untyped'.freeze
|
12
|
+
KEYWORD_SHORT = 'un'.freeze
|
13
|
+
|
14
|
+
#
|
15
15
|
# The name of the object type.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
def self.typename
|
18
18
|
return KEYWORD
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# The short name of the object type.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
def self.short_typename
|
25
25
|
return KEYWORD_SHORT
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
28
|
# ---------------------------------------------------------------------
|
30
29
|
# Messages
|
31
30
|
# ---------------------------------------------------------------------
|
32
31
|
|
33
|
-
#
|
32
|
+
#
|
34
33
|
# Get a list of message names that this object receives.
|
35
|
-
#
|
34
|
+
#
|
36
35
|
def self.messages
|
37
36
|
return super # + [ "run" ]
|
38
37
|
end
|
39
38
|
|
39
|
+
# ---------------------------------------------------------------------
|
40
|
+
# Help
|
41
|
+
# ---------------------------------------------------------------------
|
42
|
+
|
43
|
+
#
|
44
|
+
# Get help for this object type.
|
45
|
+
#
|
46
|
+
def self.help
|
47
|
+
return <<~TEXT
|
48
|
+
UNTYPED OBJECT TYPE
|
49
|
+
NAME: untyped
|
50
|
+
SHORTCUT: un
|
51
|
+
|
52
|
+
DESCRIPTION
|
53
|
+
An untyped object.
|
54
|
+
If no type is specified when an object is created it
|
55
|
+
will be of this type.
|
56
|
+
|
57
|
+
CHILDREN
|
58
|
+
None
|
59
|
+
|
60
|
+
MESSAGES
|
61
|
+
None
|
62
|
+
TEXT
|
63
|
+
end
|
64
|
+
|
40
65
|
end
|
41
66
|
end
|
42
67
|
end
|
@@ -8,24 +8,23 @@ require 'colorized_string'
|
|
8
8
|
module Gloo
|
9
9
|
module Objs
|
10
10
|
class Colorize < Gloo::Core::Obj
|
11
|
-
|
12
|
-
KEYWORD = 'colorize'
|
13
|
-
KEYWORD_SHORT = 'color'
|
14
11
|
|
15
|
-
|
12
|
+
KEYWORD = 'colorize'.freeze
|
13
|
+
KEYWORD_SHORT = 'color'.freeze
|
14
|
+
|
15
|
+
#
|
16
16
|
# The name of the object type.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
def self.typename
|
19
19
|
return KEYWORD
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# The short name of the object type.
|
24
|
-
#
|
24
|
+
#
|
25
25
|
def self.short_typename
|
26
26
|
return KEYWORD_SHORT
|
27
27
|
end
|
28
|
-
|
29
28
|
|
30
29
|
# ---------------------------------------------------------------------
|
31
30
|
# Children
|
@@ -37,37 +36,68 @@ module Gloo
|
|
37
36
|
def add_children_on_create?
|
38
37
|
return true
|
39
38
|
end
|
40
|
-
|
39
|
+
|
41
40
|
# Add children to this object.
|
42
|
-
# This is used by containers to add children needed
|
41
|
+
# This is used by containers to add children needed
|
43
42
|
# for default configurations.
|
44
43
|
def add_default_children
|
45
44
|
fac = $engine.factory
|
46
|
-
fac.create
|
45
|
+
fac.create( { :name => 'white',
|
46
|
+
:type => 'string',
|
47
|
+
:value => '',
|
48
|
+
:parent => self } )
|
47
49
|
end
|
48
50
|
|
49
|
-
|
50
51
|
# ---------------------------------------------------------------------
|
51
52
|
# Messages
|
52
53
|
# ---------------------------------------------------------------------
|
53
54
|
|
54
|
-
#
|
55
|
+
#
|
55
56
|
# Get a list of message names that this object receives.
|
56
|
-
#
|
57
|
+
#
|
57
58
|
def self.messages
|
58
|
-
return super + [
|
59
|
+
return super + [ 'run' ]
|
59
60
|
end
|
60
|
-
|
61
|
+
|
61
62
|
# Run the system command.
|
62
63
|
def msg_run
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
msg = ''
|
65
|
+
children.each do |o|
|
66
|
+
msg += ColorizedString[ o.value_display ].colorize( o.name.to_sym )
|
67
|
+
end
|
68
|
+
$log.show msg
|
69
|
+
$engine.heap.it.set_to msg.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
# ---------------------------------------------------------------------
|
73
|
+
# Help
|
74
|
+
# ---------------------------------------------------------------------
|
75
|
+
|
76
|
+
#
|
77
|
+
# Get help for this object type.
|
78
|
+
#
|
79
|
+
def self.help
|
80
|
+
return <<~TEXT
|
81
|
+
COLORIZE OBJECT TYPE
|
82
|
+
NAME: colorize
|
83
|
+
SHORTCUT: color
|
84
|
+
|
85
|
+
DESCRIPTION
|
86
|
+
The Colorize object can be used to write output in color.
|
87
|
+
The Colorize container can contain multiple strings, each
|
88
|
+
one can have a different color as specified by the names
|
89
|
+
of the children.
|
90
|
+
|
91
|
+
CHILDREN
|
92
|
+
<color> - string - no default value
|
93
|
+
The name of the child or children is the color.
|
94
|
+
The string's value is what will be written out.
|
95
|
+
|
96
|
+
MESSAGES
|
97
|
+
run - Output the string in the color specified.
|
98
|
+
TEXT
|
69
99
|
end
|
70
|
-
|
100
|
+
|
71
101
|
end
|
72
102
|
end
|
73
103
|
end
|
@@ -7,45 +7,46 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Objs
|
9
9
|
class Confirm < Gloo::Core::Obj
|
10
|
-
|
11
|
-
KEYWORD = 'confirm'
|
12
|
-
KEYWORD_SHORT = 'confirm'
|
13
|
-
PROMPT = 'prompt'
|
14
|
-
RESULT = 'result'
|
15
10
|
|
16
|
-
|
11
|
+
KEYWORD = 'confirm'.freeze
|
12
|
+
KEYWORD_SHORT = 'confirm'.freeze
|
13
|
+
PROMPT = 'prompt'.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 prompt_value
|
35
35
|
o = find_child PROMPT
|
36
36
|
return nil unless o
|
37
|
+
|
37
38
|
return o.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,69 @@ 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 => 'prompt',
|
68
|
+
:type => 'string',
|
69
|
+
:value => '> ',
|
70
|
+
:parent => self } )
|
71
|
+
fac.create( { :name => 'result',
|
72
|
+
:type => 'boolean',
|
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
|
-
prompt =
|
90
|
+
prompt = prompt_value
|
85
91
|
return unless prompt
|
92
|
+
|
86
93
|
result = $prompt.yes?( prompt )
|
87
94
|
set_result result
|
88
95
|
end
|
89
|
-
|
96
|
+
|
97
|
+
# ---------------------------------------------------------------------
|
98
|
+
# Help
|
99
|
+
# ---------------------------------------------------------------------
|
100
|
+
|
101
|
+
#
|
102
|
+
# Get help for this object type.
|
103
|
+
#
|
104
|
+
def self.help
|
105
|
+
return <<~TEXT
|
106
|
+
CONFIRM OBJECT TYPE
|
107
|
+
NAME: confirm
|
108
|
+
SHORTCUT: confirm
|
109
|
+
|
110
|
+
DESCRIPTION
|
111
|
+
CLI confirmation prompt.
|
112
|
+
|
113
|
+
CHILDREN
|
114
|
+
prompt - string - '> '
|
115
|
+
The confirmation prompt.
|
116
|
+
result - boolean - none
|
117
|
+
The result of the prompt.
|
118
|
+
|
119
|
+
MESSAGES
|
120
|
+
run - Prompt the user and then set the result.
|
121
|
+
TEXT
|
122
|
+
end
|
123
|
+
|
90
124
|
end
|
91
125
|
end
|
92
126
|
end
|
data/lib/gloo/objs/cli/prompt.rb
CHANGED
@@ -7,45 +7,46 @@
|
|
7
7
|
module Gloo
|
8
8
|
module Objs
|
9
9
|
class Prompt < Gloo::Core::Obj
|
10
|
-
|
11
|
-
KEYWORD = 'prompt'
|
12
|
-
KEYWORD_SHORT = 'ask'
|
13
|
-
PROMPT = 'prompt'
|
14
|
-
RESULT = 'result'
|
15
10
|
|
16
|
-
|
11
|
+
KEYWORD = 'prompt'.freeze
|
12
|
+
KEYWORD_SHORT = 'ask'.freeze
|
13
|
+
PROMPT = 'prompt'.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 prompt_value
|
35
35
|
o = find_child PROMPT
|
36
36
|
return nil unless o
|
37
|
+
|
37
38
|
return o.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,69 @@ 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 => 'prompt',
|
68
|
+
:type => 'string',
|
69
|
+
:value => '> ',
|
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
|
-
prompt =
|
90
|
+
prompt = prompt_value
|
85
91
|
return unless prompt
|
92
|
+
|
86
93
|
result = $prompt.ask( prompt )
|
87
94
|
set_result result
|
88
95
|
end
|
89
|
-
|
96
|
+
|
97
|
+
# ---------------------------------------------------------------------
|
98
|
+
# Help
|
99
|
+
# ---------------------------------------------------------------------
|
100
|
+
|
101
|
+
#
|
102
|
+
# Get help for this object type.
|
103
|
+
#
|
104
|
+
def self.help
|
105
|
+
return <<~TEXT
|
106
|
+
PROMPT OBJECT TYPE
|
107
|
+
NAME: prompt
|
108
|
+
SHORTCUT: ask
|
109
|
+
|
110
|
+
DESCRIPTION
|
111
|
+
CLI prompt for user input.
|
112
|
+
|
113
|
+
CHILDREN
|
114
|
+
prompt - string - '> '
|
115
|
+
The prompt displayed to the user.
|
116
|
+
result - string - none
|
117
|
+
The result with the user's input.
|
118
|
+
|
119
|
+
MESSAGES
|
120
|
+
run - Prompt the user and then set the result.
|
121
|
+
TEXT
|
122
|
+
end
|
123
|
+
|
90
124
|
end
|
91
125
|
end
|
92
126
|
end
|