tp 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -34,7 +34,8 @@ tp slides.md
34
34
 
35
35
  * Arrow keys
36
36
  * Space/Enter/Backspace
37
- * H,J,K,L (VIM)
37
+ * H,J,K,L
38
+ * W,A,S,D
38
39
  * Q to quit
39
40
 
40
41
  # Paragraphs
@@ -45,12 +46,22 @@ Short paragraphs are centered
45
46
 
46
47
  Sometimes paragraphs are really really long and might wrap a few lines. It does its best to wrap them logically. Also, they stay left-aligned.
47
48
 
49
+ # Paragraphs
50
+
51
+ There can also be...
52
+
53
+ ...multiple paragraphs.
54
+
55
+ #
56
+
57
+ Headers can also be blank
58
+
48
59
  # Contribute
49
60
 
50
- JustinCampbell/tp
61
+ justincampbell/tp
51
62
 
52
63
  # Thanks!
53
64
 
54
- @JustinCampbell
65
+ @justincampbell
55
66
  ```
56
67
 
data/lib/tp/presenter.rb CHANGED
@@ -7,7 +7,7 @@ module TP
7
7
  end
8
8
 
9
9
  def present
10
- Screen.suggest 30, 8
10
+ Screen.suggest slide_deck.width, slide_deck.height
11
11
  Keyboard.wait_for_return
12
12
 
13
13
  loop do
data/lib/tp/slide.rb CHANGED
@@ -29,6 +29,18 @@ module TP
29
29
  body unless bullets
30
30
  end
31
31
 
32
+ def width
33
+ return header.length unless body
34
+
35
+ (body.lines.to_a.collect(&:length) + [header.length]).max
36
+ end
37
+
38
+ def height
39
+ return 1 unless body
40
+
41
+ body.lines.count + 2
42
+ end
43
+
32
44
  private
33
45
 
34
46
  def lines
data/lib/tp/slide_deck.rb CHANGED
@@ -56,5 +56,22 @@ module TP
56
56
 
57
57
  current
58
58
  end
59
+
60
+ def width
61
+ slides_without_paragraphs = slides.reject(&:paragraph)
62
+
63
+ if slides_without_paragraphs.empty?
64
+ [slides.collect(&:width).max, 80].min
65
+ else
66
+ [
67
+ slides.collect(&:header).map(&:length).max,
68
+ slides_without_paragraphs.collect(&:width).max
69
+ ].max
70
+ end
71
+ end
72
+
73
+ def height
74
+ slides.collect(&:height).max
75
+ end
59
76
  end
60
77
  end
data/lib/tp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TP
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/slides.md CHANGED
@@ -30,7 +30,13 @@ Short paragraphs are centered
30
30
 
31
31
  # Paragraphs
32
32
 
33
- Sometimes paragraphs are really really long and might wrap a few lines. It does it's best to wrap them logically. Also, they stay left-aligned.
33
+ Sometimes paragraphs are really really long and might wrap a few lines. It does its best to wrap them logically. Also, they stay left-aligned.
34
+
35
+ # Paragraphs
36
+
37
+ There can also be...
38
+
39
+ ...multiple paragraphs.
34
40
 
35
41
  #
36
42
 
@@ -10,5 +10,16 @@ describe TP::SlideDeck do
10
10
  ]
11
11
  }
12
12
 
13
+ its(:height) { should == 4 }
14
+ its(:width) { should == 12 }
15
+
16
+ context "with only really long paragraphs" do
17
+ let (:slides) {
18
+ [TP::Slide.new("# First Slide\n\n#{'word ' * 100}")]
19
+ }
20
+
21
+ its(:width) { should == 80 }
22
+ end
23
+
13
24
  it { slide_deck.frames.count.should == 4 }
14
25
  end
@@ -19,6 +19,9 @@ describe TP::Slide do
19
19
 
20
20
  its(:bullets) { should =~ ["Bullet 1", "Bullet 2"] }
21
21
  its(:paragraph) { should be_nil }
22
+
23
+ its(:width) { should == 11 }
24
+ its(:height) { should == 4 }
22
25
  end
23
26
 
24
27
  context "with a paragraph" do
@@ -31,6 +34,9 @@ describe TP::Slide do
31
34
 
32
35
  its(:bullets) { should be_nil }
33
36
  its(:paragraph) { should == "This is a paragraph of text" }
37
+
38
+ its(:width) { should == 27 }
39
+ its(:height) { should == 3 }
34
40
  end
35
41
 
36
42
  context "with just a header" do
@@ -43,6 +49,17 @@ describe TP::Slide do
43
49
 
44
50
  its(:bullets) { should be_nil }
45
51
  its(:paragraph) { should be_nil }
52
+
53
+ its(:width) { should == 11 }
54
+ its(:height) { should == 1 }
55
+ end
56
+
57
+ context "with a header longer than the paragraph" do
58
+ let(:markdown) {
59
+ "# This is a very long header\n\nand short paragraph"
60
+ }
61
+
62
+ its(:width) { should == 26 }
46
63
  end
47
64
 
48
65
  context "with a blank header" do
@@ -55,6 +72,9 @@ describe TP::Slide do
55
72
 
56
73
  its(:bullets) { should be_nil }
57
74
  its(:paragraph) { should == "First Slide" }
75
+
76
+ its(:width) { should == 11 }
77
+ its(:height) { should == 3 }
58
78
  end
59
79
 
60
80
  context "with trailing newlines" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: