term-slides 0.10.0 → 0.11.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/.gitignore +1 -0
- data/README.md +7 -5
- data/examples/basic.rb +32 -0
- data/examples/basic_capture.gif +0 -0
- data/examples/cat.jpg +0 -0
- data/lib/term-slides.rb +26 -10
- data/lib/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138b7b4ed7cfc89de8f0a18695dd9a3436f2ec1defd645f1d7f677fae06f5870
|
4
|
+
data.tar.gz: 3732abab645f4e8f96802fafb051fd2c43e5b3855a0cdbd5c4fc029596d43cdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c314a3e436de1a74a87c25029c6271f3af3903eba3732ad809caa58a8d6f691abf701c5d3a1087ab2e0c1040d98f5a6c016e6d5ef035f08a524e60c0e3b04eed
|
7
|
+
data.tar.gz: c008f47f52c08297f2250d108fefaf58147f69ca1c36a4fd22a17c6d09d63eb500af0023820838b5bdbdc815b3dd641ff10693d16fb1cdcf9463273c2d6b167f
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# TermSlides
|
2
2
|
|
3
|
-
|
3
|
+
This is a DSL to make your own presentations in the shel in the shell.
|
4
4
|
|
5
|
-
|
5
|
+
Here is an example:
|
6
|
+
|
7
|
+

|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -22,7 +24,7 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
see examples/basic.rb
|
26
28
|
|
27
29
|
## Development
|
28
30
|
|
@@ -40,4 +42,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
42
|
|
41
43
|
## Code of Conduct
|
42
44
|
|
43
|
-
Everyone interacting in the
|
45
|
+
Everyone interacting in the TermSlides project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/term-slides/blob/master/CODE_OF_CONDUCT.md).
|
data/examples/basic.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'term-slides'
|
3
|
+
|
4
|
+
TermSlides::Slides.new(ARGV) do
|
5
|
+
slide("a slide with just text") do
|
6
|
+
text "text in the first slide"
|
7
|
+
text ""
|
8
|
+
t "t is an alias for text"
|
9
|
+
end
|
10
|
+
slide("code (requires vimcat)") do
|
11
|
+
code :ruby, """
|
12
|
+
def example_code(a, b)
|
13
|
+
p a
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
end
|
17
|
+
slide("table") do
|
18
|
+
table("first column name", "second column name") do
|
19
|
+
row 1, 2
|
20
|
+
row "a", "b"
|
21
|
+
row :sym1, :sym2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
slide("diagram (requires dot (graphviz), terminal must support it)") do
|
25
|
+
diagram "digraph {
|
26
|
+
a -> b
|
27
|
+
}"
|
28
|
+
end
|
29
|
+
slide("image (terminal must support it)") do
|
30
|
+
image "#{File.dirname(__FILE__)}/cat.jpg"
|
31
|
+
end
|
32
|
+
end.run
|
Binary file
|
data/examples/cat.jpg
ADDED
Binary file
|
data/lib/term-slides.rb
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
require "version"
|
2
2
|
|
3
|
-
module
|
3
|
+
module TermSlides
|
4
4
|
class Error < StandardError; end
|
5
5
|
require 'colorize'
|
6
6
|
require 'tty-table'
|
7
7
|
require 'tty-command'
|
8
8
|
require 'highline'
|
9
|
+
require 'mkmf'
|
10
|
+
require 'tempfile'
|
11
|
+
|
12
|
+
module MakeMakefile::Logging
|
13
|
+
@logfile = File::NULL
|
14
|
+
@quiet = true
|
15
|
+
end
|
9
16
|
|
10
17
|
class TTYRenderer
|
11
18
|
def render_code code
|
12
|
-
path = "
|
19
|
+
path = Tempfile.new(['code', ".#{code.format}"]).path
|
13
20
|
File.write(path, code.content)
|
14
|
-
|
15
|
-
|
21
|
+
vimcat = 'vimcat'
|
22
|
+
if find_executable vimcat
|
23
|
+
out, err = TTY::Command.new(pty: true, printer: :null).run(vimcat, path)
|
24
|
+
puts out
|
25
|
+
else
|
26
|
+
puts code
|
27
|
+
end
|
16
28
|
end
|
17
29
|
def render_table table
|
18
30
|
puts center(TTY::Table.new(table.headers, table.rows).render(:unicode))
|
@@ -36,7 +48,7 @@ module TermSlide
|
|
36
48
|
render_image_file diagram.build
|
37
49
|
end
|
38
50
|
def render_slide slide
|
39
|
-
puts center(slide.name.colorize(:light_blue).bold
|
51
|
+
puts center(slide.name).colorize(:light_blue).bold
|
40
52
|
puts
|
41
53
|
slide.content.each { |c| c.render }
|
42
54
|
end
|
@@ -131,9 +143,12 @@ module TermSlide
|
|
131
143
|
end
|
132
144
|
def build
|
133
145
|
$i ||= 0
|
134
|
-
path = "
|
135
|
-
|
136
|
-
|
146
|
+
path = Tempfile.new(['graph', ".png"]).path
|
147
|
+
dot = 'dot'
|
148
|
+
if find_executable dot
|
149
|
+
`echo "#{@dot.gsub('"', '\\"')}" | #{dot} -Tpng > #{path}`
|
150
|
+
$i += 1
|
151
|
+
end
|
137
152
|
path
|
138
153
|
end
|
139
154
|
def render
|
@@ -218,13 +233,14 @@ module TermSlide
|
|
218
233
|
slide.render
|
219
234
|
end
|
220
235
|
else
|
236
|
+
print `clear`
|
221
237
|
@slides[@args[0].to_i].render
|
222
238
|
end
|
223
239
|
return
|
224
240
|
end
|
225
241
|
while true
|
226
|
-
|
227
|
-
puts "#{i + 1}/#{@slides.size}"
|
242
|
+
print `clear`
|
243
|
+
puts "\u202e#{i + 1}/#{@slides.size}"
|
228
244
|
@slides[i].render
|
229
245
|
s = read_char
|
230
246
|
if s == "q"
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: term-slides
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yazgoo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -124,6 +124,9 @@ files:
|
|
124
124
|
- Rakefile
|
125
125
|
- bin/console
|
126
126
|
- bin/setup
|
127
|
+
- examples/basic.rb
|
128
|
+
- examples/basic_capture.gif
|
129
|
+
- examples/cat.jpg
|
127
130
|
- lib/term-slides.rb
|
128
131
|
- lib/version.rb
|
129
132
|
- release.sh
|