grmenu 3.0.0 → 4.0.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.
data/e.rb ADDED
@@ -0,0 +1,394 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(__dir__))
4
+ require "GRmenu"
5
+
6
+ # 1. Definicion de acciones del sistema
7
+ def iniciar_servidor
8
+ GRmenu.clear_screen
9
+ puts Color.bright_green("-> Servidor iniciado correctamente en http://localhost:3000")
10
+ puts Color.gray(" Worker PID: #{Process.pid} | Entorno: Produccion | Hilos: 16")
11
+ GRmenu.continue
12
+ end
13
+
14
+ def crear_respaldo
15
+ GRmenu.clear_screen
16
+ puts Color.bright_cyan("-> Creando respaldo completo de la base de datos...")
17
+ puts Color.bright_white(" Destino: /var/backups/db_backup_#{Time.now.strftime('%Y%m%d_%H%M%S')}.sql.gz")
18
+ GRmenu.continue
19
+ end
20
+
21
+ def ver_metricas
22
+ GRmenu.clear_screen
23
+ puts Color.rgb("=== Metricas del Servidor en Tiempo Real ===")
24
+ puts Color.bright_green(" CPU: 14% (8 Nucleos activos)")
25
+ puts Color.bright_cyan(" Memoria RAM: 4.8 GB / 16.0 GB (30% en uso)")
26
+ puts Color.bright_yellow(" Almacenamiento: 42.1 GB / 250.0 GB (17%)")
27
+ puts Color.bright_magenta(" Uptime: 18 dias, 4 horas, 22 minutos")
28
+ GRmenu.continue
29
+ end
30
+
31
+ def prueba_banner_rapido
32
+ GRmenu.clear_screen
33
+ GRmenu.banner("OK", 0, color: "rgb", style: 3, font: 1)
34
+ GRmenu.div(46, "rgb", 1, "═")
35
+ puts Color.bright_green(" Banner ASCII 3D y divisor renderizados en Chroma RGB.")
36
+ GRmenu.div(46, "rgb", 1, "═")
37
+ GRmenu.continue
38
+ end
39
+
40
+ def ver_ayuda_completa
41
+ GRmenu.clear_screen
42
+ GRmenu.help
43
+ GRmenu.continue
44
+ end
45
+
46
+ def salir
47
+ GRmenu.clear_screen
48
+ puts Color.bright_yellow("-> Sesion finalizada con exito. Hasta pronto!")
49
+ exit(0)
50
+ end
51
+
52
+ # 2. Demos de Carga, Paginacion y Modales
53
+ def demo_barra_progreso
54
+ GRmenu.clear_screen
55
+ GRmenu.progress(10, title: "Descargando Paquetes de Actualizacion", color: "rgb", style: 3) do |bar|
56
+ 10.times do |i|
57
+ sleep 0.1
58
+ bar.advance(1, status: "Paquete #{i + 1} de 10 completado...")
59
+ end
60
+ end
61
+ puts Color.bright_green("\n-> Descarga e instalacion completadas al 100%!")
62
+ GRmenu.continue
63
+ end
64
+
65
+ def demo_spinner
66
+ GRmenu.clear_screen
67
+ GRmenu.spinner("Conectando con el cluster PostgreSQL en la nube...", color: "rgb") do
68
+ sleep 1.4
69
+ end
70
+ puts Color.bright_green("\n-> Conexion establecida con exito (Latencia: 1.2 ms).")
71
+ GRmenu.continue
72
+ end
73
+
74
+ def demo_paginacion
75
+ GRmenu.clear_screen
76
+ opciones_largas = (1..20).map do |n|
77
+ ["Elemento del Sistema ##{n}", -> {
78
+ GRmenu.clear_screen
79
+ puts Color.bright_cyan("-> Has seleccionado el Elemento ##{n}")
80
+ GRmenu.continue
81
+ }, "Configuracion y detalles avanzados del elemento ##{n}"]
82
+ end
83
+
84
+ sub = GRmenu.new(
85
+ opciones_largas,
86
+ title: "Submenu Paginado (20 Elementos)",
87
+ subtitle: "Usa ↑ / ↓ para ver el auto-scroll interactivo",
88
+ style: 7,
89
+ page_size: 6
90
+ )
91
+ sub.set_style.focus("rgb")
92
+ sub.set_style.border("rgb")
93
+ sub.draw(size_max: 42)
94
+ end
95
+
96
+ def demo_buscador_en_vivo
97
+ GRmenu.clear_screen
98
+ servicios = [
99
+ ["Servidor HTTP Nginx", -> { puts Color.bright_green("-> Nginx Reiniciado"); GRmenu.continue }, "Proxy inverso HTTP principal"],
100
+ ["Servidor Base PostgreSQL", -> { puts Color.bright_green("-> PostgreSQL Activo"); GRmenu.continue }, "Motor de BD relacional principal"],
101
+ ["Servicio Cache Redis", -> { puts Color.bright_green("-> Redis Operativo"); GRmenu.continue }, "Almacen en memoria ultrarrapido"],
102
+ ["Servicio de Colas Sidekiq", -> { puts Color.bright_green("-> Workers listos"); GRmenu.continue }, "Procesamiento en segundo plano"],
103
+ ["Microservicio de Pagos", -> { puts Color.bright_green("-> Gateway Stripe OK"); GRmenu.continue }, "API de cobros y facturacion"],
104
+ ["Monitor de Logs Elastic", -> { puts Color.bright_green("-> ElasticSearch activo"); GRmenu.continue }, "Busqueda y agregacion de logs"],
105
+ ["Servicio de Emails SMTP", -> { puts Color.bright_green("-> Mailer conectado"); GRmenu.continue }, "Envio de notificaciones transaccionales"]
106
+ ]
107
+
108
+ sub_search = GRmenu.new(
109
+ servicios,
110
+ title: "Buscador Interactivo en Vivo",
111
+ subtitle: "Escribe letras para filtrar al instante (Backspace borra)",
112
+ search: true,
113
+ style: 3
114
+ )
115
+ sub_search.set_style.banner("rgb")
116
+ sub_search.set_style.focus("rgb")
117
+ sub_search.set_style.border("rgb")
118
+ sub_search.draw(size_max: 48)
119
+ end
120
+
121
+ def demo_cuadricula_columnas
122
+ GRmenu.clear_screen
123
+ panel_acciones = (1..12).map do |i|
124
+ ["Nodo ##{i}", -> {
125
+ GRmenu.clear_screen
126
+ puts Color.bright_cyan("-> Accediste al Nodo ##{i}")
127
+ GRmenu.continue
128
+ }, "Panel de control y metricas del cluster #{i}"]
129
+ end
130
+
131
+ sub_grid = GRmenu.new(
132
+ panel_acciones,
133
+ title: "Panel Cuadricula 2D (2 Columnas)",
134
+ subtitle: "Usa las 4 flechas (↑, ↓, ←, →) para moverte en 2D",
135
+ columns: 2,
136
+ style: 7,
137
+ page_size: 4
138
+ )
139
+ sub_grid.set_style.focus("rgb")
140
+ sub_grid.set_style.border("rgb")
141
+ sub_grid.draw(size_max: 48)
142
+ end
143
+
144
+ def demo_modales_confirm_input
145
+ GRmenu.clear_screen
146
+
147
+ # Modal 1: Entrada de texto interactiva
148
+ nombre = GRmenu.input("Ingresa tu nombre de usuario administrador:", default: "admin", color: "rgb", style: 3)
149
+
150
+ # Modal 2: Confirmacion interactiva Si / No con flechas
151
+ confirmado = GRmenu.confirm("Deseas activar privilegios de superusuario para '#{nombre}'?", default: true, color: "rgb", style: 3)
152
+
153
+ GRmenu.clear_screen
154
+ if confirmado
155
+ puts Color.bright_green("-> Acceso concedido con exito para el usuario '#{nombre}'!")
156
+ else
157
+ puts Color.bright_red("-> Operacion cancelada por el usuario.")
158
+ end
159
+ GRmenu.continue
160
+ end
161
+
162
+ def demo_seleccion_multiple
163
+ GRmenu.clear_screen
164
+ paquetes = [
165
+ ["Servidor Nginx Web", true, "Proxy inverso de alto rendimiento"],
166
+ ["Motor PostgreSQL 16", true, "Base de datos relacional robusta"],
167
+ ["Cache Redis 7.2", false, "Almacen clave-valor en memoria RAM"],
168
+ ["Monitor Prometheus", false, "Recoleccion de metricas del sistema"],
169
+ ["Visualizador Grafana", true, "Dashboards de analitica en tiempo real"],
170
+ ["Servicio Docker Engine", true, "Contenedores y virtualizacion ligera"],
171
+ ["Firewall UFW", false, "Reglas de seguridad y filtrado de red"]
172
+ ]
173
+
174
+ seleccionados = GRmenu.checkbox(
175
+ paquetes,
176
+ title: "Instalador de Paquetes (Multi-Select)",
177
+ subtitle: "Espacio: Marcar | a: Todos | n: Ninguno | i: Invertir | Enter: Confirmar",
178
+ color: "rgb",
179
+ style: 3
180
+ )
181
+
182
+ GRmenu.clear_screen
183
+ if seleccionados.empty?
184
+ puts Color.bright_yellow("-> No seleccionaste ningun paquete para instalar.")
185
+ else
186
+ puts Color.bright_green("-> Paquetes seleccionados para instalacion (#{seleccionados.length}):")
187
+ seleccionados.each_with_index do |p, i|
188
+ nombre = p.is_a?(Array) ? p[0] : p
189
+ puts Color.bright_cyan(" #{i + 1}. [X] #{nombre}")
190
+ end
191
+ end
192
+ GRmenu.continue
193
+ end
194
+
195
+ def demo_slider_interactivo
196
+ GRmenu.clear_screen
197
+ ram = GRmenu.slider(
198
+ "Asignar Memoria RAM para Servidor",
199
+ min: 1,
200
+ max: 64,
201
+ step: 1,
202
+ default: 16,
203
+ unit: "GB",
204
+ color: "rgb",
205
+ style: 3
206
+ )
207
+
208
+ GRmenu.clear_screen
209
+ puts Color.bright_green("-> Has configurado exitosamente #{ram} GB de memoria RAM asignada.")
210
+ GRmenu.continue
211
+ end
212
+
213
+ def demo_imagen_terminal
214
+ GRmenu.clear_screen
215
+ posibles = [
216
+ "/home/gabo/Escritorio/kali-dragon-original.png",
217
+ File.expand_path("~/Escritorio/kali-dragon-original.png")
218
+ ]
219
+ img_path = posibles.find { |p| File.exist?(p) }
220
+ unless img_path
221
+ puts Color.bright_red("-> No se encontro la imagen PNG en el Escritorio.")
222
+ GRmenu.continue
223
+ return
224
+ end
225
+
226
+ puts Color.rgb("=== 1. Renderizado Directo con GRmenu.image ===")
227
+ GRmenu.image(img_path, width: 60, color: "rgb", style: 3)
228
+ puts Color.bright_green("\n-> Imagen PNG renderizada con micro-pixeles ANSI TrueColor de 24 bits.")
229
+ GRmenu.continue("Presiona una tecla para ver el submenu con cabecera de imagen...")
230
+
231
+ sub = GRmenu.new(
232
+ [
233
+ ["Escanear Puertos (Nmap)", -> { puts Color.bright_green("-> Escaneando..."); GRmenu.continue }, "Escaneo rapido de red"],
234
+ ["Lanzar Metasploit", -> { puts Color.bright_green("-> Iniciando consola..."); GRmenu.continue }, "Framework de explotacion"],
235
+ ["Capturar Paquetes", -> { puts Color.bright_green("-> Sniffer activo..."); GRmenu.continue }, "Analisis de trafico de red"],
236
+ ["Volver al Menu Principal", -> { puts Color.bright_yellow("-> Volviendo..."); GRmenu.continue }]
237
+ ],
238
+ image: img_path,
239
+ image_width: 44,
240
+ title: "Kali Linux Toolset",
241
+ subtitle: "Suite de Seguridad Ofensiva\nRenderizado PNG en Terminal",
242
+ style: 3,
243
+ banner_style: 3
244
+ )
245
+ sub.set_style.focus("rgb")
246
+ sub.set_style.border("rgb")
247
+ sub.draw(size_max: 48)
248
+ end
249
+
250
+ def demo_imagen_fondo_jpeg
251
+ GRmenu.clear_screen
252
+ posibles = [
253
+ "/home/gabo/Imágenes/fondo.jpeg",
254
+ "/home/gabo/Imagenes/fondo.jpeg",
255
+ File.expand_path("~/Imágenes/fondo.jpeg"),
256
+ File.expand_path("~/Imagenes/fondo.jpeg")
257
+ ]
258
+ img_path = posibles.find { |p| File.exist?(p) }
259
+ unless img_path
260
+ puts Color.bright_red("-> No se encontro la imagen fondo.jpeg")
261
+ GRmenu.continue
262
+ return
263
+ end
264
+
265
+ puts Color.rgb("=== 1. Renderizado Directo de JPEG con GRmenu.image ===")
266
+ GRmenu.image(img_path, width: 80, color: "rgb", style: 3)
267
+ puts Color.bright_green("\n-> Imagen JPEG decodificada y renderizada en TrueColor de 24 bits.")
268
+ GRmenu.continue("Presiona una tecla para ver el submenu con fondo JPEG...")
269
+
270
+ sub = GRmenu.new(
271
+ [
272
+ ["Ver Informacion de Imagen", -> { puts Color.bright_green("-> Resolucion: 1344x768 (JPEG)"); GRmenu.continue }, "Detalles tecnicos del archivo"],
273
+ ["Aplicar Filtro de Color", -> { puts Color.bright_cyan("-> Filtro aplicado correctamente"); GRmenu.continue }, "Ajustes de visualizacion"],
274
+ ["Exportar a Terminal", -> { puts Color.bright_green("-> Exportacion ANSI completada"); GRmenu.continue }, "Generar archivo de texto ANSI"],
275
+ ["Volver al Menu Principal", -> { puts Color.bright_yellow("-> Volviendo..."); GRmenu.continue }]
276
+ ],
277
+ image: img_path,
278
+ image_width: 44,
279
+ title: "Galeria Wallpaper JPEG",
280
+ subtitle: "Visor de Imagenes en Terminal\nRenderizado Ultra-Rapido con Cache",
281
+ style: 3,
282
+ banner_style: 3
283
+ )
284
+ sub.set_style.focus("rgb")
285
+ sub.set_style.border("rgb")
286
+ sub.draw(size_max: 48)
287
+ end
288
+
289
+ def demo_tabla_interactiva
290
+ GRmenu.clear_screen
291
+ headers = ["ID", "SERVICIO", "ESTADO", "PUERTO", "CPU", "RAM", "UPTIME"]
292
+ servidores = [
293
+ ["01", "Puma Web Server", "Operativo", "3000", "12.4%", "450 MB", "18 dias"],
294
+ ["02", "PostgreSQL 16", "Operativo", "5432", "28.1%", "1.8 GB", "18 dias"],
295
+ ["03", "Redis Cache", "Operativo", "6379", " 2.0%", "120 MB", "40 dias"],
296
+ ["04", "Sidekiq Workers", "Alerta", "----", "85.0%", "2.4 GB", " 2 horas"],
297
+ ["05", "Nginx SSL Proxy", "Operativo", " 443", " 4.2%", " 85 MB", "45 dias"],
298
+ ["06", "ElasticSearch", "Operativo", "9200", "44.0%", "3.2 GB", "12 dias"],
299
+ ["07", "RabbitMQ Broker", "Operativo", "5672", " 6.5%", "210 MB", "30 dias"],
300
+ ["08", "Grafana Monitor", "Operativo", "3001", " 1.1%", " 90 MB", "20 dias"]
301
+ ]
302
+
303
+ elegido = GRmenu.table(
304
+ headers: headers,
305
+ rows: servidores,
306
+ title: "Monitoreo de Infraestructura en Vivo",
307
+ color: "rgb",
308
+ style: 3,
309
+ search: true,
310
+ sort: true,
311
+ page_size: 6
312
+ )
313
+
314
+ GRmenu.clear_screen
315
+ if elegido
316
+ puts Color.bright_green("-> Has seleccionado el servicio:")
317
+ puts Color.bright_cyan(" ID: #{elegido[0]} | Servicio: #{elegido[1]} | Estado: #{elegido[2]} | CPU: #{elegido[4]}")
318
+ else
319
+ puts Color.bright_yellow("-> No seleccionaste ningun registro de la tabla.")
320
+ end
321
+ GRmenu.continue
322
+ end
323
+
324
+ def demo_tarjetas_alertas
325
+ GRmenu.clear_screen
326
+ puts Color.rgb("=== Demos de Alertas del Sistema (GRmenu.alert) ===")
327
+ GRmenu.alert(:success, "Base de datos migrada exitosamente a v3.0.0.", style: 3, pause: false)
328
+ puts ""
329
+ GRmenu.alert(:warning, "Uso de disco al 88% en la particion /var/log.", style: 7, pause: false)
330
+ puts ""
331
+ GRmenu.alert(:error, "Fallo de conexion con el nodo replica #3.", style: 4, pause: false)
332
+ puts ""
333
+ GRmenu.alert(:info, "Certificados SSL renovados por 90 dias.", style: 6, pause: false)
334
+ puts ""
335
+ GRmenu.card(
336
+ title: "Resumen Ejecutivo de Rendimiento",
337
+ content: "Peticiones por segundo: 14,200 req/s\nLatencia p99: 14.2 ms\nDisponibilidad mensual: 99.98%\nCluster saludable.",
338
+ style: 7,
339
+ color: "rgb",
340
+ pause: false
341
+ )
342
+ GRmenu.continue
343
+ end
344
+
345
+ # 3. Menu Principal Interactivo
346
+ def main
347
+ menu = GRmenu.new(
348
+ [
349
+ method(:iniciar_servidor),
350
+ :crear_respaldo,
351
+ ["Metricas del Sistema", method(:ver_metricas)],
352
+ ["Tablas Interactivas (GRmenu.table)", method(:demo_tabla_interactiva), "Navegacion, ordenamiento por columnas y busqueda en vivo"],
353
+ ["Tarjetas y Alertas (card & alert)", method(:demo_tarjetas_alertas), "Alertas de exito, error, advertencia y tarjetas ejecutivas"],
354
+ ["Probar Barra de Progreso", method(:demo_barra_progreso), "Ejemplo interactivo de GRmenu.progress al 100%"],
355
+ ["Probar Spinner de Carga", method(:demo_spinner), "Animacion en tiempo real para funciones pesadas"],
356
+ ["Seleccion Multiple (Checkbox)", method(:demo_seleccion_multiple), "Marcar/Desmarcar items con Espacio, a, n, i"],
357
+ ["Control Deslizante (Slider / Range)", method(:demo_slider_interactivo), "Ajustar valores numericos interactivamente con ← y →"],
358
+ ["Probar Paginacion (20 items)", method(:demo_paginacion), "Desplazamiento suave con auto-scroll"],
359
+ ["Buscador en Vivo (search: true)", method(:demo_buscador_en_vivo), "Filtro instantaneo en vivo mientras escribes"],
360
+ ["Cuadricula 2D (columns: 2)", method(:demo_cuadricula_columnas), "Navegacion con las 4 flechas (↑, ↓, ←, →)"],
361
+ ["Modales Nativos (Confirm & Input)", method(:demo_modales_confirm_input), "Dialogos emergentes interactivos para preguntas y texto"],
362
+ ["Probar Imagen PNG (Kali Dragon)", method(:demo_imagen_terminal), "Muestra fotos PNG con micro-pixeles ANSI TrueColor"],
363
+ ["Probar Imagen JPEG (Wallpaper Fondo)", method(:demo_imagen_fondo_jpeg), "Muestra imagenes JPEG/JPG con cache instantanea"],
364
+ ["Ejecutar Lambda", -> { puts Color.rgb("Ejecutando bloque lambda dinamico!"); GRmenu.continue }],
365
+ ["Probar Banner Helper", method(:prueba_banner_rapido)],
366
+ ["Ver Ayuda y Referencia", method(:ver_ayuda_completa), "Abre la guia de documentacion interactiva en consola"],
367
+ method(:salir)
368
+ ],
369
+ banner: "GRMENU",
370
+ title: "Panel de Control v3.0",
371
+ subtitle: "Consola de Administracion TTY\nUsa las flechas y Enter",
372
+ style: 3,
373
+ banner_style: 3,
374
+ divider: true,
375
+ center: true,
376
+ page_size: 7,
377
+ animate: "diagonal"
378
+ )
379
+
380
+ # Configuracion completa en modo RGB Chroma Wave
381
+ menu.set_style.font(1)
382
+ menu.set_style.banner("rgb")
383
+ menu.set_style.title("rgb")
384
+ menu.set_style.subtitle("rgb")
385
+ menu.set_style.divider("rgb")
386
+ menu.set_style.border("rgb")
387
+ menu.set_style.options("white")
388
+ menu.set_style.focus("neon_red",2)
389
+
390
+ menu.draw(size_max: 44)
391
+ end
392
+
393
+ loop { main }
394
+
data/grmenu.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'GRmenu'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grmenu
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - grcode
@@ -20,12 +20,20 @@ extra_rdoc_files:
20
20
  - README.md
21
21
  files:
22
22
  - GRmenu.rb
23
- - LICENSE
24
23
  - README.md
25
24
  - data/borders.json
26
25
  - data/colors.json
27
26
  - data/fonts.json
28
27
  - data/help.txt
28
+ - data/themes/cyberpunk.gr
29
+ - data/themes/dracula.gr
30
+ - data/themes/matrix.gr
31
+ - data/themes/monokai.gr
32
+ - data/themes/neon_red.gr
33
+ - data/themes/nord.gr
34
+ - data/themes/sunset.gr
35
+ - e.rb
36
+ - grmenu.rb
29
37
  homepage: https://github.com/JoseEduardoGR/GRmenu
30
38
  licenses:
31
39
  - MIT
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 grcode
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.