gloo 0.3.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -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
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Show a large-text banner.
|
5
|
+
#
|
6
|
+
require 'tty-font'
|
7
|
+
require 'pastel'
|
8
|
+
|
9
|
+
module Gloo
|
10
|
+
module Objs
|
11
|
+
class Banner < Gloo::Core::Obj
|
12
|
+
|
13
|
+
KEYWORD = 'banner'.freeze
|
14
|
+
KEYWORD_SHORT = 'ban'.freeze
|
15
|
+
TEXT = 'text'.freeze
|
16
|
+
STYLE = 'style'.freeze
|
17
|
+
COLOR = 'color'.freeze
|
18
|
+
|
19
|
+
#
|
20
|
+
# The name of the object type.
|
21
|
+
#
|
22
|
+
def self.typename
|
23
|
+
return KEYWORD
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# The short name of the object type.
|
28
|
+
#
|
29
|
+
def self.short_typename
|
30
|
+
return KEYWORD_SHORT
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Get the banner text from the child object.
|
35
|
+
#
|
36
|
+
def text_value
|
37
|
+
o = find_child TEXT
|
38
|
+
return '' unless o
|
39
|
+
|
40
|
+
return o.value
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Get the banner style from the child object.
|
45
|
+
#
|
46
|
+
def style_value
|
47
|
+
o = find_child STYLE
|
48
|
+
return '' unless o
|
49
|
+
|
50
|
+
return o.value
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Get the banner color from the child object.
|
55
|
+
#
|
56
|
+
def color_value
|
57
|
+
o = find_child COLOR
|
58
|
+
return '' unless o
|
59
|
+
|
60
|
+
return o.value
|
61
|
+
end
|
62
|
+
|
63
|
+
# ---------------------------------------------------------------------
|
64
|
+
# Children
|
65
|
+
# ---------------------------------------------------------------------
|
66
|
+
|
67
|
+
# Does this object have children to add when an object
|
68
|
+
# is created in interactive mode?
|
69
|
+
# This does not apply during obj load, etc.
|
70
|
+
def add_children_on_create?
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
|
74
|
+
# Add children to this object.
|
75
|
+
# This is used by containers to add children needed
|
76
|
+
# for default configurations.
|
77
|
+
def add_default_children
|
78
|
+
fac = $engine.factory
|
79
|
+
fac.create_string TEXT, '', self
|
80
|
+
fac.create_string STYLE, '', self
|
81
|
+
fac.create_string COLOR, '', self
|
82
|
+
end
|
83
|
+
|
84
|
+
# ---------------------------------------------------------------------
|
85
|
+
# Messages
|
86
|
+
# ---------------------------------------------------------------------
|
87
|
+
|
88
|
+
#
|
89
|
+
# Get a list of message names that this object receives.
|
90
|
+
#
|
91
|
+
def self.messages
|
92
|
+
return super + %w[show]
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Show the banner bar
|
97
|
+
#
|
98
|
+
def msg_show
|
99
|
+
font = TTY::Font.new self.style_value
|
100
|
+
t = font.write( self.text_value )
|
101
|
+
pastel = ::Pastel.new
|
102
|
+
c = self.color_value.split( ' ' ).map( &:to_sym )
|
103
|
+
puts pastel.decorate( t, *c )
|
104
|
+
end
|
105
|
+
|
106
|
+
# ---------------------------------------------------------------------
|
107
|
+
# Help
|
108
|
+
# ---------------------------------------------------------------------
|
109
|
+
|
110
|
+
#
|
111
|
+
# Get help for this object type.
|
112
|
+
#
|
113
|
+
def self.help
|
114
|
+
return <<~TEXT
|
115
|
+
BANNER OBJECT TYPE
|
116
|
+
NAME: banner
|
117
|
+
SHORTCUT: ban
|
118
|
+
|
119
|
+
DESCRIPTION
|
120
|
+
Banner text in large, colored font.
|
121
|
+
|
122
|
+
CHILDREN
|
123
|
+
text - string
|
124
|
+
The text for the banner.
|
125
|
+
style - string
|
126
|
+
The banner style. See tty-font for options.
|
127
|
+
color - string
|
128
|
+
The color for the banner. See pastel for options.
|
129
|
+
|
130
|
+
MESSAGES
|
131
|
+
show - Show the text banner.
|
132
|
+
TEXT
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Show a CLI progress bar.
|
5
|
+
#
|
6
|
+
require 'tty-progressbar'
|
7
|
+
|
8
|
+
module Gloo
|
9
|
+
module Objs
|
10
|
+
class Bar < Gloo::Core::Obj
|
11
|
+
|
12
|
+
KEYWORD = 'bar'.freeze
|
13
|
+
KEYWORD_SHORT = 'bar'.freeze
|
14
|
+
NAME = 'name'.freeze
|
15
|
+
TOTAL = 'total'.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 bar's name from the child object.
|
33
|
+
#
|
34
|
+
def name_value
|
35
|
+
o = find_child NAME
|
36
|
+
return '' unless o
|
37
|
+
|
38
|
+
return o.value
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Get the bar's total from the child object.
|
43
|
+
#
|
44
|
+
def total_value
|
45
|
+
o = find_child TOTAL
|
46
|
+
return 100 unless o
|
47
|
+
|
48
|
+
return o.value
|
49
|
+
end
|
50
|
+
|
51
|
+
# ---------------------------------------------------------------------
|
52
|
+
# Children
|
53
|
+
# ---------------------------------------------------------------------
|
54
|
+
|
55
|
+
# Does this object have children to add when an object
|
56
|
+
# is created in interactive mode?
|
57
|
+
# This does not apply during obj load, etc.
|
58
|
+
def add_children_on_create?
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add children to this object.
|
63
|
+
# This is used by containers to add children needed
|
64
|
+
# for default configurations.
|
65
|
+
def add_default_children
|
66
|
+
fac = $engine.factory
|
67
|
+
fac.create_string NAME, '', self
|
68
|
+
fac.create_int TOTAL, 100, self
|
69
|
+
end
|
70
|
+
|
71
|
+
# ---------------------------------------------------------------------
|
72
|
+
# Messages
|
73
|
+
# ---------------------------------------------------------------------
|
74
|
+
|
75
|
+
#
|
76
|
+
# Get a list of message names that this object receives.
|
77
|
+
#
|
78
|
+
def self.messages
|
79
|
+
return super + %w[start advance stop]
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# Start the progress bar.
|
84
|
+
#
|
85
|
+
def msg_start
|
86
|
+
msg = "#{name_value} [:bar] :percent"
|
87
|
+
@bar = TTY::ProgressBar.new( msg, total: total_value )
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# Finish the progress bar.
|
92
|
+
#
|
93
|
+
def msg_stop
|
94
|
+
@bar.finish
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Advance the progress bar.
|
99
|
+
#
|
100
|
+
def msg_advance
|
101
|
+
x = 1
|
102
|
+
if @params&.token_count&.positive?
|
103
|
+
expr = Gloo::Expr::Expression.new( @params.tokens )
|
104
|
+
x = expr.evaluate.to_i
|
105
|
+
end
|
106
|
+
|
107
|
+
@bar.advance x
|
108
|
+
end
|
109
|
+
|
110
|
+
# ---------------------------------------------------------------------
|
111
|
+
# Help
|
112
|
+
# ---------------------------------------------------------------------
|
113
|
+
|
114
|
+
#
|
115
|
+
# Get help for this object type.
|
116
|
+
#
|
117
|
+
def self.help
|
118
|
+
return <<~TEXT
|
119
|
+
BAR OBJECT TYPE
|
120
|
+
NAME: bar
|
121
|
+
SHORTCUT: bar
|
122
|
+
|
123
|
+
DESCRIPTION
|
124
|
+
CLI progress bar
|
125
|
+
|
126
|
+
CHILDREN
|
127
|
+
name - string
|
128
|
+
The name of the progress bar.
|
129
|
+
total - integer - 100
|
130
|
+
The total for the bar.
|
131
|
+
|
132
|
+
MESSAGES
|
133
|
+
start - Start the bar.
|
134
|
+
advance <amount> - Advance by the given amount.
|
135
|
+
stop - Complete the bar.
|
136
|
+
TEXT
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
3
|
#
|
4
4
|
# Show colorized output.
|
5
5
|
#
|
@@ -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
|