diamante 0.2.0 → 0.3.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/README.md +49 -13
- data/lib/diamante/cli.rb +6 -0
- data/lib/diamante/files/config.yaml +11 -0
- data/lib/diamante/game.rb +15 -10
- data/lib/diamante/project.rb +23 -0
- data/lib/diamante/scenes/base.rb +13 -0
- data/lib/diamante/scenes/matrix.rb +8 -4
- data/lib/diamante/scenes/scene_factory.rb +25 -0
- data/lib/diamante/scenes/slides.rb +13 -3
- data/lib/diamante/scenes/space.rb +76 -0
- data/lib/diamante/scenes/ui.rb +6 -3
- data/lib/diamante/version.rb +1 -1
- data/lib/diamante.rb +5 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7607a260666a965bd57829cb9fb3955b0aab16b04f88475662238af66efcb2bb
|
|
4
|
+
data.tar.gz: f394a8fafab95e0fece4367014bc09ce5e45c2df92a8216b31c3da5e5d137d4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d125e9bf5ef1c98df9eb90320192cc09977e4a84f35bf7b33b160da0be5a1a8bad47e54b0b6b857e3df51d9d77201625c23b606377453a44615cfec2f672c829
|
|
7
|
+
data.tar.gz: efaf5b5b80af5c8dd5da9f84570834742bed9db047d610466e32564f2925b167737ed82184e6dab4c9c51d247ebb5d36c19a39a5b88dc9cc045f0595ec287f9b
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Diamante
|
|
2
2
|
|
|
3
|
-
Presentar diapositivas en el
|
|
3
|
+
Presentar diapositivas en el terminal.
|
|
4
4
|
|
|
5
5
|
## Instalación
|
|
6
6
|
|
|
@@ -9,27 +9,63 @@ Presentar diapositivas en el temrinal.
|
|
|
9
9
|
|
|
10
10
|
## Modo de uso
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
```bash
|
|
13
|
+
$ diamante PATH/TO/CONFIG.yaml
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
* Crear una carpeta con el fichero de configuración (YAML) y las diapositivas en ficheros de texto. [Ver ejemplo](./examples/data/).
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
examples/data
|
|
20
|
+
├── 01.txt
|
|
21
|
+
├── 02.txt
|
|
22
|
+
├── 03.txt
|
|
23
|
+
└── 04.txt
|
|
24
|
+
```
|
|
25
|
+
* Ejecutar `diamante show examples/matrix.yaml`.
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
| Tecla | Función |
|
|
30
|
+
| ----- | ----------------------------- |
|
|
31
|
+
| q | Salir de la presentación |
|
|
32
|
+
| right | Ir a la siguiente diapositiva |
|
|
33
|
+
| left | Ir a la diapositiva anterior |
|
|
15
34
|
|
|
16
35
|
## Características
|
|
17
36
|
|
|
18
37
|
* El contenido de cada diapositiva va en un fichero de texto separado.
|
|
19
38
|
* El fichero de configuración tiene el siguiente formato:
|
|
20
39
|
```yaml
|
|
21
|
-
:
|
|
22
|
-
:
|
|
23
|
-
:
|
|
40
|
+
:game:
|
|
41
|
+
:bye: "Morpheus: 'Follow me.'"
|
|
42
|
+
:bg:
|
|
43
|
+
:scene: Matrix
|
|
44
|
+
:chars: "!#$%&\\\/()*+,-.01:;<=>?@[]^_oO{}|ª·¿•xX "
|
|
45
|
+
:fg:
|
|
46
|
+
:scene: Slides
|
|
47
|
+
:files: "examples/data/*.txt"
|
|
48
|
+
:ui:
|
|
49
|
+
:scene: UI
|
|
50
|
+
:header: "Gema diamante"
|
|
24
51
|
```
|
|
25
52
|
|
|
26
|
-
Significado de los parámetros:
|
|
53
|
+
* Significado de los parámetros de configuración:
|
|
54
|
+
|
|
55
|
+
| Sección | Parámetro | Descripción |
|
|
56
|
+
| --------- | ----------- | -------------------- |
|
|
57
|
+
| `:game` | `:bye` | Mensaje de despedida |
|
|
58
|
+
| `:bg` | `:scene` | Escena de background |
|
|
59
|
+
| `:bg` | `:chars` | Caracteres para el efecto Matrix |
|
|
60
|
+
| `:fg` | `:scene` | Escena de foreground |
|
|
61
|
+
| `:fg` | `:files` | Ficheros de texto con las diapositivas |
|
|
62
|
+
| `:ui` | `:scene` | Escena del interfaz de usuario |
|
|
63
|
+
| `:ui` | `:header` | Título de la presentación |
|
|
64
|
+
|
|
65
|
+
## Desarrollo
|
|
27
66
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| `:header` | Título de la presentación |
|
|
31
|
-
| `:files` | Ficheros de texto que contienen las diapositivas |
|
|
32
|
-
| `:bye` | Mensaje de despedida |
|
|
67
|
+
* La biblioteca está hecha de forma modular para poder usar distintas escenas de background, foreground o user interface en el futuro.
|
|
68
|
+
* Actualmente no se están usando los parámetros `:scene`, pero en un futuro permitirán definir las escenas a cargar para reproducir la presentación.
|
|
33
69
|
|
|
34
70
|
## Contributing
|
|
35
71
|
|
data/lib/diamante/cli.rb
CHANGED
|
@@ -13,6 +13,12 @@ class CLI < Thor
|
|
|
13
13
|
exit 0
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
map ["n", "-n", "--new"] => "new"
|
|
17
|
+
desc "new", "Create new project"
|
|
18
|
+
def new(dirpath)
|
|
19
|
+
Diamante.new(dirpath)
|
|
20
|
+
end
|
|
21
|
+
|
|
16
22
|
map ["r", "-r", "--restart"] => "restart"
|
|
17
23
|
desc "restart", "Restart ANSI terminal"
|
|
18
24
|
def restart
|
data/lib/diamante/game.rb
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "ansi"
|
|
4
4
|
require_relative "config"
|
|
5
|
-
require_relative "scenes/
|
|
6
|
-
require_relative "scenes/slides"
|
|
7
|
-
require_relative "scenes/ui"
|
|
5
|
+
require_relative "scenes/scene_factory"
|
|
8
6
|
|
|
9
7
|
module Diamante
|
|
10
8
|
class Game
|
|
@@ -17,7 +15,7 @@ module Diamante
|
|
|
17
15
|
begin
|
|
18
16
|
init
|
|
19
17
|
loop do
|
|
20
|
-
|
|
18
|
+
update
|
|
21
19
|
render
|
|
22
20
|
sleep 0.1
|
|
23
21
|
end
|
|
@@ -31,9 +29,10 @@ module Diamante
|
|
|
31
29
|
|
|
32
30
|
def init
|
|
33
31
|
ANSI.set_raw_mode
|
|
34
|
-
scene1 = Scene::
|
|
35
|
-
scene2 = Scene::
|
|
36
|
-
scene3 = Scene::
|
|
32
|
+
scene1 = Scene::SceneFactory.create(@config[:bg])
|
|
33
|
+
scene2 = Scene::SceneFactory.create(@config[:fg])
|
|
34
|
+
scene3 = Scene::SceneFactory.create(@config[:ui])
|
|
35
|
+
scene3.slides = scene2
|
|
37
36
|
@scenes = {
|
|
38
37
|
bg: scene1,
|
|
39
38
|
fg: scene2,
|
|
@@ -41,16 +40,22 @@ module Diamante
|
|
|
41
40
|
}
|
|
42
41
|
end
|
|
43
42
|
|
|
44
|
-
def
|
|
43
|
+
def update
|
|
45
44
|
key = ANSI.pressed_key
|
|
46
45
|
|
|
47
46
|
case key
|
|
48
47
|
when :up then puts "↑ Arriba"
|
|
49
48
|
when :down then puts "↓ Abajo"
|
|
50
|
-
when :left then
|
|
51
|
-
|
|
49
|
+
when :left then
|
|
50
|
+
@scenes[:bg].init
|
|
51
|
+
@scenes[:fg].prev
|
|
52
|
+
when :right then
|
|
53
|
+
@scenes[:bg].init
|
|
54
|
+
@scenes[:fg].next
|
|
52
55
|
when :quit then deinit
|
|
53
56
|
end
|
|
57
|
+
|
|
58
|
+
@scenes.each_value { _1.update }
|
|
54
59
|
end
|
|
55
60
|
|
|
56
61
|
def render
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
module Diamante
|
|
5
|
+
class Project
|
|
6
|
+
def self.new(dirpath)
|
|
7
|
+
puts "==> Creating new project"
|
|
8
|
+
|
|
9
|
+
FileUtils.mkdir_p(dirpath)
|
|
10
|
+
puts "--> Create dir : #{dirpath}"
|
|
11
|
+
|
|
12
|
+
source_file = File.join(__dir__, 'files', 'config.yaml')
|
|
13
|
+
if File.exist?(source_file)
|
|
14
|
+
FileUtils.cp(source_file, dirpath)
|
|
15
|
+
puts "--> Create file : #{dirpath}/config.yaml"
|
|
16
|
+
else
|
|
17
|
+
puts "Error: El archivo no existe en la ruta esperada: #{source_file}"
|
|
18
|
+
end
|
|
19
|
+
rescue StandardError => e
|
|
20
|
+
puts "Error: #{e.message}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "pastel"
|
|
4
|
+
require_relative "base"
|
|
4
5
|
require_relative "../ansi"
|
|
5
6
|
|
|
6
7
|
module Diamante
|
|
7
8
|
module Scene
|
|
8
|
-
class Matrix
|
|
9
|
+
class Matrix < Base
|
|
9
10
|
|
|
10
11
|
def initialize(config)
|
|
11
|
-
@config = config
|
|
12
|
+
@config = config
|
|
12
13
|
@pastel = Pastel.new
|
|
13
|
-
# @eligible_chars = "ª\|@·#$~%&/\¿¸^*¨;•:·_-+'.,".chars + ['.', ' ']
|
|
14
14
|
@matrix_chars = @config[:chars].chars
|
|
15
15
|
@term = ANSI.new
|
|
16
16
|
@height = @term.height
|
|
17
17
|
@width = @term.width
|
|
18
|
-
|
|
18
|
+
init
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def init
|
|
22
|
+
@chars = {}
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
def render
|
|
22
26
|
@chars[rand(@width)] = 0
|
|
23
27
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative "matrix"
|
|
2
|
+
require_relative "slides"
|
|
3
|
+
require_relative "space"
|
|
4
|
+
require_relative "ui"
|
|
5
|
+
|
|
6
|
+
module Diamante
|
|
7
|
+
module Scene
|
|
8
|
+
class SceneFactory
|
|
9
|
+
def self.create(config)
|
|
10
|
+
klass_name = config[:scene]
|
|
11
|
+
|
|
12
|
+
case klass_name
|
|
13
|
+
when "Matrix" then return Matrix.new(config)
|
|
14
|
+
when "Slides" then return Slides.new(config)
|
|
15
|
+
when "Space" then return Space.new(config)
|
|
16
|
+
when "UI" then return UI.new(config)
|
|
17
|
+
else
|
|
18
|
+
warn "[SceneFactory] Unkown scene! (#{klass_name})"
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "pastel"
|
|
4
|
+
require_relative "base"
|
|
4
5
|
require_relative "../ansi"
|
|
5
6
|
|
|
6
7
|
module Diamante
|
|
7
8
|
module Scene
|
|
8
|
-
class Slides
|
|
9
|
+
class Slides < Base
|
|
9
10
|
attr_reader :index
|
|
10
11
|
|
|
11
12
|
def initialize(config)
|
|
@@ -16,6 +17,11 @@ module Diamante
|
|
|
16
17
|
@width = @term.width
|
|
17
18
|
|
|
18
19
|
@files = Dir.glob(@config[:files])
|
|
20
|
+
if @files.empty?
|
|
21
|
+
ANSI.set_cooked_mode
|
|
22
|
+
warn "[ERROR] No slides! Revise config.yaml"
|
|
23
|
+
exit 1
|
|
24
|
+
end
|
|
19
25
|
@index = 0
|
|
20
26
|
load_slide
|
|
21
27
|
end
|
|
@@ -52,8 +58,12 @@ module Diamante
|
|
|
52
58
|
|
|
53
59
|
def load_slide
|
|
54
60
|
@chars = {}
|
|
55
|
-
ANSI.clear_screen
|
|
56
|
-
|
|
61
|
+
ANSI.clear_screen
|
|
62
|
+
if @files[@index].nil?
|
|
63
|
+
@slide = "Undefined!"
|
|
64
|
+
else
|
|
65
|
+
@slide = File.readlines(@files[@index])
|
|
66
|
+
end
|
|
57
67
|
end
|
|
58
68
|
end
|
|
59
69
|
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pastel"
|
|
4
|
+
require_relative "base"
|
|
5
|
+
require_relative "../ansi"
|
|
6
|
+
|
|
7
|
+
module Diamante
|
|
8
|
+
module Scene
|
|
9
|
+
class Space < Base
|
|
10
|
+
def initialize(config)
|
|
11
|
+
@config = config
|
|
12
|
+
@chars_list = "-O "
|
|
13
|
+
init
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def init
|
|
17
|
+
@stars = []
|
|
18
|
+
5.times { @stars << Star.new }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def update
|
|
22
|
+
@stars.each { _1.render }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def render
|
|
26
|
+
@stars.each { _1.update }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
class Star
|
|
32
|
+
attr_reader :char
|
|
33
|
+
attr_reader :x
|
|
34
|
+
attr_reader :y
|
|
35
|
+
|
|
36
|
+
def initialize
|
|
37
|
+
@pastel = Pastel.new
|
|
38
|
+
@term = ANSI.new
|
|
39
|
+
@char = @pastel.white.bold("*")
|
|
40
|
+
@x = 0
|
|
41
|
+
@y = 0
|
|
42
|
+
init
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def init
|
|
46
|
+
@last_y = @y
|
|
47
|
+
@last_x = @x
|
|
48
|
+
@y = rand(@term.height).to_f
|
|
49
|
+
@x = rand(@term.width).to_f
|
|
50
|
+
@speed = rand * 0.000000001
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def update
|
|
54
|
+
sleep 0.1
|
|
55
|
+
@last_y = @y
|
|
56
|
+
@last_x = @x
|
|
57
|
+
@x += @x + @speed * 0.000000000001
|
|
58
|
+
if @x >= @term.width
|
|
59
|
+
ANSI.print_text_at(@last_y.to_i, @last_x.to_i + 1, " ")
|
|
60
|
+
@y = rand(@term.height).to_f
|
|
61
|
+
@x = 0
|
|
62
|
+
@speed = rand * 0.00000001
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def render
|
|
67
|
+
return if (@x - @last_x + @y - @last_y).zero?
|
|
68
|
+
ANSI.print_text_at(@last_y.to_i, @last_x.to_i + 1, " ")
|
|
69
|
+
text = @pastel.white.bold(@char)
|
|
70
|
+
ANSI.print_text_at(@y.to_i, @x.to_i + 1, text)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
data/lib/diamante/scenes/ui.rb
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "pastel"
|
|
4
|
-
require_relative "
|
|
4
|
+
require_relative "base"
|
|
5
5
|
require_relative "slides"
|
|
6
|
+
require_relative "../ansi"
|
|
6
7
|
|
|
7
8
|
module Diamante
|
|
8
9
|
module Scene
|
|
9
|
-
class UI
|
|
10
|
-
|
|
10
|
+
class UI < Base
|
|
11
|
+
attr_accessor :slides
|
|
12
|
+
|
|
13
|
+
def initialize(config)
|
|
11
14
|
@pastel = Pastel.new
|
|
12
15
|
|
|
13
16
|
@header = config[:header]
|
data/lib/diamante/version.rb
CHANGED
data/lib/diamante.rb
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "diamante/md/markdown"
|
|
4
|
+
require_relative "diamante/project"
|
|
4
5
|
require_relative "diamante/version"
|
|
5
6
|
|
|
6
7
|
module Diamante
|
|
7
8
|
|
|
9
|
+
def self.new(dirpath)
|
|
10
|
+
Project.new(dirpath)
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
def self.show(filepath)
|
|
9
14
|
if filepath.end_with? ".md"
|
|
10
15
|
Markdown.new(filepath).show
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: diamante
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Vargas Ruiz
|
|
@@ -70,11 +70,16 @@ files:
|
|
|
70
70
|
- lib/diamante/ansi.rb
|
|
71
71
|
- lib/diamante/cli.rb
|
|
72
72
|
- lib/diamante/config.rb
|
|
73
|
+
- lib/diamante/files/config.yaml
|
|
73
74
|
- lib/diamante/game.rb
|
|
74
75
|
- lib/diamante/md/markdown.rb
|
|
75
76
|
- lib/diamante/md/parser.rb
|
|
77
|
+
- lib/diamante/project.rb
|
|
78
|
+
- lib/diamante/scenes/base.rb
|
|
76
79
|
- lib/diamante/scenes/matrix.rb
|
|
80
|
+
- lib/diamante/scenes/scene_factory.rb
|
|
77
81
|
- lib/diamante/scenes/slides.rb
|
|
82
|
+
- lib/diamante/scenes/space.rb
|
|
78
83
|
- lib/diamante/scenes/ui.rb
|
|
79
84
|
- lib/diamante/version.rb
|
|
80
85
|
homepage: https://github.com/dvarrui/diamante
|