tty_slides 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -9,20 +9,28 @@ gem install tty_slides
9
9
  ```
10
10
 
11
11
  ## Usage
12
+ Create a startup file (e.g. `start.rb`)
12
13
  ```ruby
14
+ #! /usr/bin/env ruby
15
+
16
+ require "tty_slides"
17
+
13
18
  # define the BASE_PATH and SLIDES
14
- class SlideList
15
- BASE_PATH = Pathname.new(ROOT) + ".." + "slides"
19
+ class TtySlides::SlideList
20
+ BASE_PATH = Pathname.new(__FILE__) + ".." + "slides"
16
21
 
17
22
  SLIDES = [
18
- "introduction",
19
- "covermymeds",
23
+ "introduction"
20
24
  ]
21
25
  end
26
+
27
+ # call `.start`
28
+ TtySlides.start
22
29
  ```
23
30
 
31
+ Start the presentation:
24
32
  ``bash
25
-
33
+ bundle exec ruby start.rb
26
34
  ```
27
35
 
28
36
  ## Adding Slides
data/lib/slide_list.rb CHANGED
@@ -1,4 +1,4 @@
1
- class SlideList
1
+ class TtySlides::SlideList
2
2
  attr_reader :current
3
3
 
4
4
  def initialize(start = 0)
@@ -1,3 +1,3 @@
1
1
  module TtySlides
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/tty_slides.rb CHANGED
@@ -1,51 +1,50 @@
1
- # lazy options parsing:
2
- # ARGV[0] - the slide you want to start on
3
- # ARGV[1] - the q and q server hostname
4
- # ARGV[2] - the q and q server port
5
- require 'curses'
6
- require 'io/console'
7
-
8
- ROOT = File.dirname(__FILE__)
9
-
10
- require 'tty_slides/version'
11
- require 'helpers/helper'
12
- require 'cml/cml'
13
- require 'main_window'
14
- require 'q_and_a_window'
15
- require 'q_and_a_client'
16
- require 'slide_list'
17
- require 'options'
18
-
19
- options = Options.parse!
20
-
21
- Curses.init_screen
22
- Curses.noecho
23
- Curses.curs_set(0) # no cursor please
24
-
25
- height = Curses.lines
26
- width = Curses.cols
27
- main_window = MainWindow.new(Curses::Window.new height - 5, width, 0, 0)
28
- q_and_a = QandAWindow.new(Curses::Window.new 5, width, main_window.maxy, 0)
29
- slides = SlideList.new(options.start_at)
30
-
31
- q_a_client = QandAClient.new(q_and_a, options.host, options.port)
32
- if !q_a_client.connected?
33
- main_window.resize height, width
34
- Curses.refresh
35
- end
36
-
37
- CML.new(main_window, File.read(slides.next)).render
38
-
39
- at_exit { puts "Last Slide: #{slides.current}" if $!.kind_of?(StandardError) }
40
- at_exit { Curses.close_screen }
1
+ module TtySlides
2
+ require 'curses'
3
+ require 'io/console'
4
+
5
+ require 'tty_slides/version'
6
+ require 'helpers/helper'
7
+ require 'cml/cml'
8
+ require 'main_window'
9
+ require 'q_and_a_window'
10
+ require 'q_and_a_client'
11
+ require 'slide_list'
12
+ require 'options'
13
+
14
+ @options = Options.parse!
15
+
16
+ Curses.init_screen
17
+ Curses.noecho
18
+ Curses.curs_set(0) # no cursor please
19
+
20
+ @height = Curses.lines
21
+ @width = Curses.cols
22
+ @main_window = MainWindow.new(Curses::Window.new @height - 5, @width, 0, 0)
23
+ @q_and_a = QandAWindow.new(Curses::Window.new 5, @width, @main_window.maxy, 0)
24
+ @slides = SlideList.new(@options.start_at)
25
+
26
+ @q_a_client = QandAClient.new(@q_and_a, @options.host, @options.port)
27
+ if !@q_a_client.connected?
28
+ @main_window.resize @height, @width
29
+ Curses.refresh
30
+ end
41
31
 
42
- loop do
43
- case STDIN.getch
44
- when /b/i
45
- CML.new(main_window, File.read(slides.previous)).render
46
- when /q/i
47
- exit
48
- else
49
- CML.new(main_window, File.read(slides.next)).render
32
+ at_exit { puts "Last Slide: #{@slides.current}" if $!.kind_of?(StandardError) }
33
+ at_exit { Curses.close_screen }
34
+
35
+ def self.start
36
+ CML.new(@main_window, File.read(@slides.next)).render
37
+
38
+ loop do
39
+ case STDIN.getch
40
+ when /b/i
41
+ CML.new(@main_window, File.read(@slides.previous)).render
42
+ when /q/i
43
+ exit
44
+ else
45
+ CML.new(@main_window, File.read(@slides.next)).render
46
+ end
47
+ end
50
48
  end
49
+
51
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty_slides
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: