gloo 2.0.2 → 2.1.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/gloo/objs/cli/banner.rb +13 -3
- data/lib/gloo/objs/cli/menu.rb +68 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20774ab083e3f97894367f2e5ab0ede6ae65edeb72e8153af73df130da3a728c
|
4
|
+
data.tar.gz: 9225ba79729353ed2a21966dfdf380ad1d6b081615895d6bef1eec83720d428b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4d53f40b31c60a0d32f45bf5ab8a3a6489325f34fb4f488333a3fdc5c67b876b13bd7cf9ad7daa388124386ba866033b5c96357d6621239f9b02e466db13c4
|
7
|
+
data.tar.gz: c3326a3b85ca3996cf5a0ecee1dbf4d49ada7f8ae37815bdfa053ba9c593bf1a01e508870ebff7b263e159d48472a37c874baddba78d2dfce52ba1aabe9dee99
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/lib/gloo/objs/cli/banner.rb
CHANGED
@@ -96,10 +96,20 @@ module Gloo
|
|
96
96
|
# Show the banner bar
|
97
97
|
#
|
98
98
|
def msg_show
|
99
|
-
|
100
|
-
|
99
|
+
Banner.show_banner( self.text_value, self.style_value, self.color_value )
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Show the banner bar.
|
104
|
+
# text - the text of the banner
|
105
|
+
# style - the style of the banner
|
106
|
+
# color - the color of the banner
|
107
|
+
#
|
108
|
+
def self.show_banner( text, style, color )
|
109
|
+
font = TTY::Font.new style
|
110
|
+
t = font.write( text )
|
101
111
|
pastel = ::Pastel.new
|
102
|
-
c =
|
112
|
+
c = color.split( ' ' ).map( &:to_sym )
|
103
113
|
puts pastel.decorate( t, *c )
|
104
114
|
end
|
105
115
|
|
data/lib/gloo/objs/cli/menu.rb
CHANGED
@@ -18,6 +18,10 @@ module Gloo
|
|
18
18
|
HIDE_ITEMS = 'hide_items'.freeze
|
19
19
|
BEFORE_MENU = 'before_menu'.freeze
|
20
20
|
DEFAULT = 'default'.freeze
|
21
|
+
TITLE = 'title'.freeze
|
22
|
+
TITLE_STYLE = 'straight'.freeze
|
23
|
+
TITLE_COLOR = 'bright_cyan'.freeze
|
24
|
+
QUIT_ITEM_NAME = 'q'.freeze
|
21
25
|
|
22
26
|
#
|
23
27
|
# The name of the object type.
|
@@ -55,6 +59,53 @@ module Gloo
|
|
55
59
|
return o.value
|
56
60
|
end
|
57
61
|
|
62
|
+
#
|
63
|
+
# If there is no loop child, add it.
|
64
|
+
#
|
65
|
+
def add_loop_child
|
66
|
+
o = find_child LOOP
|
67
|
+
return if o
|
68
|
+
|
69
|
+
fac = @engine.factory
|
70
|
+
fac.create_bool LOOP, true, self
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Add a Quit menu item
|
75
|
+
#
|
76
|
+
def add_quit_item
|
77
|
+
items = find_child ITEMS
|
78
|
+
q = items.find_child QUIT_ITEM_NAME
|
79
|
+
return if q
|
80
|
+
|
81
|
+
fac = @engine.factory
|
82
|
+
fac.create_bool LOOP, true, self
|
83
|
+
|
84
|
+
params = { :name => QUIT_ITEM_NAME,
|
85
|
+
:type => 'mitem',
|
86
|
+
:value => 'Quit',
|
87
|
+
:parent => items }
|
88
|
+
mitem = fac.create params
|
89
|
+
script = "put false into #{self.pn}.loop"
|
90
|
+
fac.create_script 'do', script, mitem
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Add any required children not specified in the source.
|
95
|
+
#
|
96
|
+
def lazy_add_children
|
97
|
+
add_loop_child
|
98
|
+
add_quit_item
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Does the menu have a title?
|
103
|
+
#
|
104
|
+
def title?
|
105
|
+
o = find_child TITLE
|
106
|
+
return o ? true : false
|
107
|
+
end
|
108
|
+
|
58
109
|
# ---------------------------------------------------------------------
|
59
110
|
# Children
|
60
111
|
# ---------------------------------------------------------------------
|
@@ -96,6 +147,7 @@ module Gloo
|
|
96
147
|
# Show the menu options, and prompt for user input.
|
97
148
|
#
|
98
149
|
def msg_run
|
150
|
+
lazy_add_children
|
99
151
|
run_default
|
100
152
|
loop do
|
101
153
|
begin_menu
|
@@ -103,7 +155,7 @@ module Gloo
|
|
103
155
|
dt = DateTime.now
|
104
156
|
d = dt.strftime( '%Y.%m.%d' )
|
105
157
|
t = dt.strftime( '%I:%M:%S' )
|
106
|
-
cmd = @engine.platform.prompt.ask( "#{d.yellow} #{t.white} >" )
|
158
|
+
cmd = @engine.platform.prompt.ask( "\n#{d.yellow} #{t.white} >" )
|
107
159
|
else
|
108
160
|
cmd = @engine.platform.prompt.ask( prompt_value )
|
109
161
|
end
|
@@ -174,10 +226,22 @@ module Gloo
|
|
174
226
|
#
|
175
227
|
def run_default
|
176
228
|
obj = find_child DEFAULT
|
177
|
-
|
229
|
+
if obj
|
230
|
+
s = Gloo::Exec::Script.new( @engine, obj )
|
231
|
+
s.run
|
232
|
+
elsif title?
|
233
|
+
run_default_title
|
234
|
+
end
|
235
|
+
end
|
178
236
|
|
179
|
-
|
180
|
-
|
237
|
+
#
|
238
|
+
# There is a title, so show it.
|
239
|
+
#
|
240
|
+
def run_default_title
|
241
|
+
obj = find_child TITLE
|
242
|
+
title = obj.value
|
243
|
+
@engine.platform&.clear_screen
|
244
|
+
Banner.show_banner( title, TITLE_STYLE, TITLE_COLOR )
|
181
245
|
end
|
182
246
|
|
183
247
|
#
|
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: 2.0
|
4
|
+
version: 2.1.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: 2023-05-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|