gloo-lang 0.9.4 → 0.9.5
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/Gemfile.lock +1 -1
- data/gloo-lang.gemspec +1 -0
- data/lib/VERSION +1 -1
- data/lib/gloo_lang/app/args.rb +0 -1
- data/lib/gloo_lang/app/engine.rb +6 -36
- data/lib/gloo_lang/app/help.rb +2 -41
- data/lib/gloo_lang/app/platform.rb +75 -0
- data/lib/gloo_lang/app/settings.rb +2 -3
- data/lib/gloo_lang/objs/basic/container.rb +1 -12
- data/lib/gloo_lang/objs/basic/text.rb +2 -10
- data/lib/gloo_lang/objs/data/markdown.rb +2 -7
- data/lib/gloo_lang/objs/data/table.rb +1 -29
- metadata +22 -20
- data/lib/gloo_lang/objs/cli/banner.rb +0 -108
- data/lib/gloo_lang/objs/cli/bar.rb +0 -133
- data/lib/gloo_lang/objs/cli/colorize.rb +0 -73
- data/lib/gloo_lang/objs/cli/confirm.rb +0 -96
- data/lib/gloo_lang/objs/cli/menu.rb +0 -206
- data/lib/gloo_lang/objs/cli/menu_item.rb +0 -95
- data/lib/gloo_lang/objs/cli/pastel.rb +0 -97
- data/lib/gloo_lang/objs/cli/prompt.rb +0 -110
- data/lib/gloo_lang/objs/cli/select.rb +0 -126
- data/lib/gloo_lang/objs/dev/git.rb +0 -140
- data/lib/gloo_lang/objs/dev/stats.rb +0 -120
- data/lib/gloo_lang/objs/snd/play.rb +0 -48
- data/lib/gloo_lang/objs/snd/say.rb +0 -98
- data/lib/gloo_lang/objs/system/file_handle.rb +0 -138
- data/lib/gloo_lang/objs/system/ssh_exec.rb +0 -126
- data/lib/gloo_lang/objs/system/system.rb +0 -136
- data/lib/gloo_lang/verbs/alert.rb +0 -79
- data/lib/gloo_lang/verbs/beep.rb +0 -40
- data/lib/gloo_lang/verbs/cls.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d19934c8b9f0ae7c4b7770b353555c19c4acb4b755775222e14cde8aa1a4bbee
|
4
|
+
data.tar.gz: b88f21b0a86cf71b92fcc3fe8c018884109b83293e54db266bb17cef5111e7c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3475c8c03da31aa4a05feb948b10a89a3b0fae818800ef14329c5028add3e5a788f3a6e7fff7b21c762c53fb67619ffa875dd6586044373110316e78c494480
|
7
|
+
data.tar.gz: 27d759c5e86633db59786a3a7db230c4f26c2e54d94a3d339af759983799fd6a4dccb21b84f0dd4cd8de80f1f3a46650c0d3bb283cee246ce95f5cca439ace4e
|
data/Gemfile.lock
CHANGED
data/gloo-lang.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
33
33
|
spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.0'
|
34
34
|
spec.add_dependency 'net-ssh', '~> 6.1', '>= 6.1.0'
|
35
|
+
spec.add_dependency 'tty-platform', '~> 0.3', '>= 0.3.0'
|
35
36
|
# spec.add_dependency 'mysql2', '~> 0.5', '>= 0.5.3'
|
36
37
|
# spec.add_dependency 'sqlite3', '~> 1.4', '>= 1.4.2'
|
37
38
|
end
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.5
|
data/lib/gloo_lang/app/args.rb
CHANGED
data/lib/gloo_lang/app/engine.rb
CHANGED
@@ -7,15 +7,11 @@
|
|
7
7
|
# to the relevant element.
|
8
8
|
#
|
9
9
|
|
10
|
-
require 'tty-prompt'
|
11
|
-
require 'tty-cursor'
|
12
|
-
require 'colorize'
|
13
|
-
|
14
10
|
module GlooLang
|
15
11
|
module App
|
16
12
|
class Engine
|
17
13
|
|
18
|
-
attr_reader :args, :mode, :running,
|
14
|
+
attr_reader :args, :mode, :running, :platform,
|
19
15
|
:dictionary, :parser, :heap, :factory
|
20
16
|
attr_accessor :last_cmd, :persist_man, :event_manager,
|
21
17
|
:exec_env, :help, :converter
|
@@ -23,12 +19,12 @@ module GlooLang
|
|
23
19
|
#
|
24
20
|
# Set up the engine with basic elements.
|
25
21
|
#
|
26
|
-
def initialize( params = [] )
|
22
|
+
def initialize( params = [], platform=nil )
|
27
23
|
$engine = self
|
28
24
|
@args = Args.new( params )
|
29
25
|
$settings = Settings.new( ENV[ 'GLOO_ENV' ] )
|
30
26
|
$log = Log.new( @args.quiet? )
|
31
|
-
|
27
|
+
@platform = platform ? platform : Platform.new
|
32
28
|
$log.debug 'engine intialized...'
|
33
29
|
end
|
34
30
|
|
@@ -113,23 +109,6 @@ module GlooLang
|
|
113
109
|
@persist_man.load( name ) if name
|
114
110
|
end
|
115
111
|
|
116
|
-
#
|
117
|
-
# Prompt for the next command.
|
118
|
-
#
|
119
|
-
def prompt_cmd
|
120
|
-
@last_cmd = $prompt.ask( default_prompt )
|
121
|
-
end
|
122
|
-
|
123
|
-
#
|
124
|
-
# Get the default prompt text.
|
125
|
-
#
|
126
|
-
def default_prompt
|
127
|
-
dt = DateTime.now
|
128
|
-
d = dt.strftime( '%Y.%m.%d' )
|
129
|
-
t = dt.strftime( '%I:%M:%S' )
|
130
|
-
return "#{'gloo'.blue} #{d.yellow} #{t.white} >"
|
131
|
-
end
|
132
|
-
|
133
112
|
#
|
134
113
|
# Is the last command entered blank?
|
135
114
|
#
|
@@ -145,7 +124,7 @@ module GlooLang
|
|
145
124
|
#
|
146
125
|
def loop
|
147
126
|
while @running
|
148
|
-
prompt_cmd
|
127
|
+
@last_cmd = @platform.prompt_cmd
|
149
128
|
process_cmd
|
150
129
|
end
|
151
130
|
end
|
@@ -155,7 +134,7 @@ module GlooLang
|
|
155
134
|
#
|
156
135
|
def process_cmd
|
157
136
|
if last_cmd_blank?
|
158
|
-
clear_screen
|
137
|
+
@platform.clear_screen
|
159
138
|
return
|
160
139
|
end
|
161
140
|
|
@@ -184,7 +163,7 @@ module GlooLang
|
|
184
163
|
# Show the version information and then quit.
|
185
164
|
#
|
186
165
|
def run_version
|
187
|
-
|
166
|
+
@platform.show Info.display_title unless @args.quiet?
|
188
167
|
quit
|
189
168
|
end
|
190
169
|
|
@@ -196,15 +175,6 @@ module GlooLang
|
|
196
175
|
quit
|
197
176
|
end
|
198
177
|
|
199
|
-
#
|
200
|
-
# Clear the screen.
|
201
|
-
#
|
202
|
-
def clear_screen
|
203
|
-
@cursor ||= TTY::Cursor
|
204
|
-
print @cursor.clear_screen
|
205
|
-
print @cursor.move_to( 0, 0 )
|
206
|
-
end
|
207
|
-
|
208
178
|
# ---------------------------------------------------------------------
|
209
179
|
# Error Handling
|
210
180
|
# ---------------------------------------------------------------------
|
data/lib/gloo_lang/app/help.rb
CHANGED
@@ -4,9 +4,6 @@
|
|
4
4
|
# Help system.
|
5
5
|
#
|
6
6
|
|
7
|
-
require 'tty-markdown'
|
8
|
-
require 'tty-pager'
|
9
|
-
|
10
7
|
module GlooLang
|
11
8
|
module App
|
12
9
|
class Help
|
@@ -61,11 +58,7 @@ module GlooLang
|
|
61
58
|
|
62
59
|
data = self.get_topic_data( topic )
|
63
60
|
page = data.lines.count > Settings.page_size
|
64
|
-
|
65
|
-
show_markdown_data( data, page )
|
66
|
-
else
|
67
|
-
show_text_data( data, page )
|
68
|
-
end
|
61
|
+
$engine.platform.show( data, topic_is_md?( topic ), page )
|
69
62
|
end
|
70
63
|
|
71
64
|
#
|
@@ -75,39 +68,7 @@ module GlooLang
|
|
75
68
|
return if $engine.args.quiet?
|
76
69
|
|
77
70
|
data = self.get_topic_data( topic )
|
78
|
-
|
79
|
-
show_markdown_data data
|
80
|
-
else
|
81
|
-
show_text_data data
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Show the markdown data.
|
87
|
-
#
|
88
|
-
def show_text_data( data, page = false )
|
89
|
-
if page
|
90
|
-
pager = TTY::Pager.new
|
91
|
-
pager.page( data )
|
92
|
-
else
|
93
|
-
puts data.white
|
94
|
-
puts
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
#
|
99
|
-
# Show the markdown data.
|
100
|
-
#
|
101
|
-
def show_markdown_data( data, page = false )
|
102
|
-
md = TTY::Markdown.parse data
|
103
|
-
|
104
|
-
if page
|
105
|
-
pager = TTY::Pager.new
|
106
|
-
pager.page( md )
|
107
|
-
else
|
108
|
-
puts md
|
109
|
-
puts
|
110
|
-
end
|
71
|
+
$engine.platform.show( data, topic_is_md?( topic ), false )
|
111
72
|
end
|
112
73
|
|
113
74
|
#
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Handle input and output for the current platform.
|
5
|
+
#
|
6
|
+
# This is an abstract base class and minimal implementation
|
7
|
+
# is only to facilitate testing.
|
8
|
+
#
|
9
|
+
|
10
|
+
module GlooLang
|
11
|
+
module App
|
12
|
+
class Platform
|
13
|
+
|
14
|
+
#
|
15
|
+
# Set up Platform.
|
16
|
+
#
|
17
|
+
def initialize
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Show a message.
|
22
|
+
# Abstract--implment in subclass.
|
23
|
+
#
|
24
|
+
def show( msg, md=false, page=false )
|
25
|
+
puts msg
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Prompt for the next command.
|
30
|
+
# Abstract--implment in subclass.
|
31
|
+
#
|
32
|
+
def prompt_cmd
|
33
|
+
return ''
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Clear the screen.
|
38
|
+
# Abstract--implment in subclass.
|
39
|
+
#
|
40
|
+
def clear_screen
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Edit some temporary text and return the edited text.
|
45
|
+
# Abstract--implment in subclass.
|
46
|
+
#
|
47
|
+
def edit initial_value
|
48
|
+
return initial_value
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Show the given table data.
|
53
|
+
# Abstract--implment in subclass.
|
54
|
+
#
|
55
|
+
def show_table( headers, data, title = nil )
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Get the number of vertical lines on screen.
|
60
|
+
# Abstract--implment in subclass.
|
61
|
+
#
|
62
|
+
def lines
|
63
|
+
return 40
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Get the number of horizontal columns on screen.
|
68
|
+
# Abstract--implment in subclass.
|
69
|
+
#
|
70
|
+
def cols
|
71
|
+
return 80
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -5,7 +5,6 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
require 'yaml'
|
8
|
-
require 'tty-screen'
|
9
8
|
require 'colorize'
|
10
9
|
|
11
10
|
module GlooLang
|
@@ -72,14 +71,14 @@ module GlooLang
|
|
72
71
|
# Get the number of vertical lines on screen.
|
73
72
|
#
|
74
73
|
def self.lines
|
75
|
-
|
74
|
+
$engine.platform.lines
|
76
75
|
end
|
77
76
|
|
78
77
|
#
|
79
78
|
# Get the number of horizontal columns on screen.
|
80
79
|
#
|
81
80
|
def self.cols
|
82
|
-
|
81
|
+
$engine.platform.cols
|
83
82
|
end
|
84
83
|
|
85
84
|
#
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# An object that contains a collection of other objects.
|
5
5
|
#
|
6
|
-
require 'tty-table'
|
7
|
-
require 'pastel'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -59,16 +57,7 @@ module GlooLang
|
|
59
57
|
#
|
60
58
|
def msg_show_key_value_table
|
61
59
|
data = self.children.map { |o| [ o.name, o.value ] }
|
62
|
-
|
63
|
-
table = TTY::Table.new rows: data
|
64
|
-
pad = [ 0, 1, 0, 1 ]
|
65
|
-
rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
|
66
|
-
r.border.style = :blue
|
67
|
-
r.filter = proc do |val, _row_index, col_index|
|
68
|
-
col_index.zero? ? pastel.blue( val ) : pastel.white( val )
|
69
|
-
end
|
70
|
-
end
|
71
|
-
puts "\n #{rendered}\n\n"
|
60
|
+
$engine.platform.show_table nil, data, title
|
72
61
|
end
|
73
62
|
|
74
63
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# A [multiline] block of text.
|
5
5
|
#
|
6
|
-
require 'tty-editor'
|
7
|
-
require 'tty-pager'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -12,7 +10,6 @@ module GlooLang
|
|
12
10
|
|
13
11
|
KEYWORD = 'text'.freeze
|
14
12
|
KEYWORD_SHORT = 'txt'.freeze
|
15
|
-
DEFAULT_TMP_FILE = 'tmp.txt'.freeze
|
16
13
|
|
17
14
|
#
|
18
15
|
# The name of the object type.
|
@@ -67,19 +64,14 @@ module GlooLang
|
|
67
64
|
def msg_page
|
68
65
|
return unless value
|
69
66
|
|
70
|
-
|
71
|
-
pager = TTY::Pager.new
|
72
|
-
pager.page( value )
|
67
|
+
$engine.platform.show( value, false, true )
|
73
68
|
end
|
74
69
|
|
75
70
|
#
|
76
71
|
# Edit the text in the default editor.
|
77
72
|
#
|
78
73
|
def msg_edit
|
79
|
-
|
80
|
-
File.open( tmp, 'w' ) { |file| file.write( self.value ) }
|
81
|
-
TTY::Editor.open( tmp )
|
82
|
-
set_value File.read( tmp )
|
74
|
+
self.value = $engine.platform.edit( self.value )
|
83
75
|
end
|
84
76
|
|
85
77
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Markdown data.
|
5
5
|
#
|
6
|
-
require 'tty-markdown'
|
7
|
-
require 'tty-pager'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -64,7 +62,7 @@ module GlooLang
|
|
64
62
|
# Show the markdown data in the terminal.
|
65
63
|
#
|
66
64
|
def msg_show
|
67
|
-
|
65
|
+
$engine.platform.show( self.value, true, false )
|
68
66
|
end
|
69
67
|
|
70
68
|
#
|
@@ -73,10 +71,7 @@ module GlooLang
|
|
73
71
|
def msg_page
|
74
72
|
return unless self.value
|
75
73
|
|
76
|
-
md
|
77
|
-
# pager = TTY::Pager::SystemPager.new command: 'less -R'
|
78
|
-
pager = TTY::Pager.new
|
79
|
-
pager.page( md )
|
74
|
+
$engine.platform.show( md, true, true )
|
80
75
|
end
|
81
76
|
|
82
77
|
end
|
@@ -4,8 +4,6 @@
|
|
4
4
|
# A data table.
|
5
5
|
# The table container headers and data.
|
6
6
|
#
|
7
|
-
require 'tty-table'
|
8
|
-
require 'pastel'
|
9
7
|
|
10
8
|
module GlooLang
|
11
9
|
module Objs
|
@@ -106,33 +104,7 @@ module GlooLang
|
|
106
104
|
#
|
107
105
|
def msg_show
|
108
106
|
title = self.value
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
# ---------------------------------------------------------------------
|
113
|
-
# Static table helper
|
114
|
-
# ---------------------------------------------------------------------
|
115
|
-
|
116
|
-
#
|
117
|
-
# Show the given table data.
|
118
|
-
#
|
119
|
-
def self.show( headers, data, title = nil )
|
120
|
-
pastel = ::Pastel.new
|
121
|
-
table = TTY::Table.new headers, data
|
122
|
-
pad = [ 0, 1, 0, 1 ]
|
123
|
-
rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
|
124
|
-
r.border.style = :blue
|
125
|
-
r.filter = proc do |val, row_index, _col_index|
|
126
|
-
# col_index % 2 == 1 ? pastel.red.on_green(val) : val
|
127
|
-
if row_index.zero?
|
128
|
-
pastel.blue( val )
|
129
|
-
else
|
130
|
-
row_index.odd? ? pastel.white( val ) : pastel.yellow( val )
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
puts "\n#{title.white}"
|
135
|
-
puts "#{rendered}\n\n"
|
107
|
+
$engine.platform.show_table headers, data, title
|
136
108
|
end
|
137
109
|
|
138
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo-lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
@@ -138,6 +138,26 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 6.1.0
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: tty-platform
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0.3'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 0.3.0
|
151
|
+
type: :runtime
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0.3'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.3.0
|
141
161
|
description: A scripting languge to keep it all together.
|
142
162
|
email:
|
143
163
|
- eric.crane@mac.com
|
@@ -164,6 +184,7 @@ files:
|
|
164
184
|
- lib/gloo_lang/app/info.rb
|
165
185
|
- lib/gloo_lang/app/log.rb
|
166
186
|
- lib/gloo_lang/app/mode.rb
|
187
|
+
- lib/gloo_lang/app/platform.rb
|
167
188
|
- lib/gloo_lang/app/settings.rb
|
168
189
|
- lib/gloo_lang/convert/converter.rb
|
169
190
|
- lib/gloo_lang/convert/string_to_datetime.rb
|
@@ -285,15 +306,6 @@ files:
|
|
285
306
|
- lib/gloo_lang/objs/basic/string.rb
|
286
307
|
- lib/gloo_lang/objs/basic/text.rb
|
287
308
|
- lib/gloo_lang/objs/basic/untyped.rb
|
288
|
-
- lib/gloo_lang/objs/cli/banner.rb
|
289
|
-
- lib/gloo_lang/objs/cli/bar.rb
|
290
|
-
- lib/gloo_lang/objs/cli/colorize.rb
|
291
|
-
- lib/gloo_lang/objs/cli/confirm.rb
|
292
|
-
- lib/gloo_lang/objs/cli/menu.rb
|
293
|
-
- lib/gloo_lang/objs/cli/menu_item.rb
|
294
|
-
- lib/gloo_lang/objs/cli/pastel.rb
|
295
|
-
- lib/gloo_lang/objs/cli/prompt.rb
|
296
|
-
- lib/gloo_lang/objs/cli/select.rb
|
297
309
|
- lib/gloo_lang/objs/ctrl/each.rb
|
298
310
|
- lib/gloo_lang/objs/ctrl/repeat.rb
|
299
311
|
- lib/gloo_lang/objs/data/markdown.rb
|
@@ -301,18 +313,11 @@ files:
|
|
301
313
|
- lib/gloo_lang/objs/data/query.rb
|
302
314
|
- lib/gloo_lang/objs/data/sqlite.rb
|
303
315
|
- lib/gloo_lang/objs/data/table.rb
|
304
|
-
- lib/gloo_lang/objs/dev/git.rb
|
305
|
-
- lib/gloo_lang/objs/dev/stats.rb
|
306
316
|
- lib/gloo_lang/objs/dt/date.rb
|
307
317
|
- lib/gloo_lang/objs/dt/datetime.rb
|
308
318
|
- lib/gloo_lang/objs/dt/time.rb
|
309
319
|
- lib/gloo_lang/objs/ror/erb.rb
|
310
320
|
- lib/gloo_lang/objs/ror/eval.rb
|
311
|
-
- lib/gloo_lang/objs/snd/play.rb
|
312
|
-
- lib/gloo_lang/objs/snd/say.rb
|
313
|
-
- lib/gloo_lang/objs/system/file_handle.rb
|
314
|
-
- lib/gloo_lang/objs/system/ssh_exec.rb
|
315
|
-
- lib/gloo_lang/objs/system/system.rb
|
316
321
|
- lib/gloo_lang/objs/web/http_get.rb
|
317
322
|
- lib/gloo_lang/objs/web/http_post.rb
|
318
323
|
- lib/gloo_lang/objs/web/json.rb
|
@@ -327,9 +332,6 @@ files:
|
|
327
332
|
- lib/gloo_lang/utils/format.rb
|
328
333
|
- lib/gloo_lang/utils/stats.rb
|
329
334
|
- lib/gloo_lang/utils/words.rb
|
330
|
-
- lib/gloo_lang/verbs/alert.rb
|
331
|
-
- lib/gloo_lang/verbs/beep.rb
|
332
|
-
- lib/gloo_lang/verbs/cls.rb
|
333
335
|
- lib/gloo_lang/verbs/context.rb
|
334
336
|
- lib/gloo_lang/verbs/create.rb
|
335
337
|
- lib/gloo_lang/verbs/execute.rb
|
@@ -1,108 +0,0 @@
|
|
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 GlooLang
|
10
|
-
module Objs
|
11
|
-
class Banner < GlooLang::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
|
-
end
|
107
|
-
end
|
108
|
-
end
|