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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bc40a80f2e01cc477cc4e56a70f9997d5fbaa0a74195e8e2bc3c052a51fa5ce
4
- data.tar.gz: 65c402714ea5638ef86e981d2d666c961d47f96952e46f6b84aa6b45922460b6
3
+ metadata.gz: 138b7b4ed7cfc89de8f0a18695dd9a3436f2ec1defd645f1d7f677fae06f5870
4
+ data.tar.gz: 3732abab645f4e8f96802fafb051fd2c43e5b3855a0cdbd5c4fc029596d43cdf
5
5
  SHA512:
6
- metadata.gz: c769c602d962c2bb54e466181a5376d6ad086cde69bbd14fad322f067db0b87f8510d3eb38d135dab3aeceeaf31122df5e034ec7e1ef345cf42a89c0cbef2e8f
7
- data.tar.gz: 3af9c2a382800951dcbaa81e8ee9856d17663ec53e14a5e51664486206efea8d378fb660622db13370e2d29ab839bcf88e73c2537339a226bd056d4b458cffff
6
+ metadata.gz: c314a3e436de1a74a87c25029c6271f3af3903eba3732ad809caa58a8d6f691abf701c5d3a1087ab2e0c1040d98f5a6c016e6d5ef035f08a524e60c0e3b04eed
7
+ data.tar.gz: c008f47f52c08297f2250d108fefaf58147f69ca1c36a4fd22a17c6d09d63eb500af0023820838b5bdbdc815b3dd641ff10693d16fb1cdcf9463273c2d6b167f
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  *.gem
10
+ mkmf.log
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # Term::Slides
1
+ # TermSlides
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/term/slides`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This is a DSL to make your own presentations in the shel in the shell.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Here is an example:
6
+
7
+ ![Example](examples/basic_capture.gif)
6
8
 
7
9
  ## Installation
8
10
 
@@ -22,7 +24,7 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
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 Term::Slides 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).
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 TermSlide
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 = "code.#{code.format}"
19
+ path = Tempfile.new(['code', ".#{code.format}"]).path
13
20
  File.write(path, code.content)
14
- out, err = TTY::Command.new(pty: true, printer: :null).run('vimcat', path)
15
- puts out
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 = "graph#{$i}.png"
135
- `echo "#{@dot.gsub('"', '\\"')}" | dot -Tpng > #{path}`
136
- $i += 1
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
- puts `clear`
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
@@ -1,5 +1,5 @@
1
1
  module Term
2
2
  module Slides
3
- VERSION = "0.10.0"
3
+ VERSION = "0.11.0"
4
4
  end
5
5
  end
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.10.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-08 00:00:00.000000000 Z
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