tp 0.3.1 → 0.4.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.
- data/Readme.md +11 -1
- data/lib/string.rb +1 -1
- data/lib/tp.rb +7 -2
- data/lib/tp/presenter.rb +3 -3
- data/lib/tp/renderer.rb +9 -22
- data/lib/tp/slide.rb +17 -23
- data/lib/tp/slide/bulleted.rb +33 -0
- data/lib/tp/slide/code.rb +40 -0
- data/lib/tp/slide/header_only.rb +9 -0
- data/lib/tp/slide/paragraph.rb +18 -0
- data/lib/tp/slide_deck.rb +7 -20
- data/lib/tp/slide_factory.rb +20 -0
- data/lib/tp/version.rb +1 -1
- data/slides.md +11 -1
- data/spec/lib/tp/slide/bulleted_spec.rb +47 -0
- data/spec/lib/tp/slide/code_spec.rb +46 -0
- data/spec/lib/tp/slide/header_only_spec.rb +25 -0
- data/spec/lib/tp/slide/paragraph_spec.rb +38 -0
- data/spec/lib/tp/slide_deck_spec.rb +3 -3
- data/spec/lib/tp/slide_factory_spec.rb +31 -0
- data/spec/lib/tp/slide_spec.rb +3 -78
- data/tp.gemspec +4 -2
- metadata +34 -3
data/Readme.md
CHANGED
@@ -20,7 +20,7 @@ Terminal Presenter
|
|
20
20
|
|
21
21
|
# tp
|
22
22
|
|
23
|
-
Presents Markdown in your terminal
|
23
|
+
Presents Markdown slides in your terminal
|
24
24
|
|
25
25
|
# Installation
|
26
26
|
|
@@ -52,6 +52,16 @@ There can also be...
|
|
52
52
|
|
53
53
|
...multiple paragraphs.
|
54
54
|
|
55
|
+
# Code
|
56
|
+
|
57
|
+
\```rb
|
58
|
+
class And
|
59
|
+
def it
|
60
|
+
highlights(:code)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
\```
|
64
|
+
|
55
65
|
#
|
56
66
|
|
57
67
|
Headers can also be blank
|
data/lib/string.rb
CHANGED
data/lib/tp.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
require 'coderay'
|
2
|
+
|
1
3
|
require 'keyboard'
|
2
4
|
require 'screen'
|
3
5
|
require 'string'
|
4
|
-
|
5
6
|
require 'tp/presenter'
|
6
7
|
require 'tp/renderer'
|
7
8
|
require 'tp/slide'
|
9
|
+
require 'tp/slide/bulleted'
|
10
|
+
require 'tp/slide/code'
|
11
|
+
require 'tp/slide/header_only'
|
12
|
+
require 'tp/slide/paragraph'
|
8
13
|
require 'tp/slide_deck'
|
14
|
+
require 'tp/slide_factory'
|
9
15
|
require 'tp/version'
|
10
|
-
|
data/lib/tp/presenter.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module TP
|
2
2
|
class Presenter
|
3
|
-
|
3
|
+
attr_reader :markdown
|
4
4
|
|
5
5
|
def initialize(markdown)
|
6
|
-
|
6
|
+
@markdown = markdown
|
7
7
|
end
|
8
8
|
|
9
9
|
def present
|
@@ -33,7 +33,7 @@ module TP
|
|
33
33
|
result.reject! &:empty?
|
34
34
|
result.map! { |string| string.prepend "#" }
|
35
35
|
|
36
|
-
result.map { |string|
|
36
|
+
result.map { |string| SlideFactory.from_markdown string }
|
37
37
|
end
|
38
38
|
|
39
39
|
def slide_deck
|
data/lib/tp/renderer.rb
CHANGED
@@ -1,36 +1,23 @@
|
|
1
1
|
module TP
|
2
2
|
class Renderer
|
3
|
-
|
3
|
+
attr_reader :text
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(slide)
|
8
|
-
self.slide = slide
|
5
|
+
def initialize(text)
|
6
|
+
@text = text
|
9
7
|
end
|
10
8
|
|
11
9
|
def render
|
12
10
|
Screen.clear!
|
13
11
|
|
14
|
-
return unless
|
15
|
-
|
16
|
-
buffer = slide.header.center Screen.width
|
17
|
-
|
18
|
-
if slide.body
|
19
|
-
buffer << "\n\n"
|
20
|
-
|
21
|
-
if slide.paragraph
|
22
|
-
paragraph = slide.paragraph.wrap Screen.width
|
23
|
-
paragraph = paragraph.center Screen.width if paragraph.lines.one?
|
12
|
+
return unless text
|
24
13
|
|
25
|
-
|
26
|
-
else
|
27
|
-
slide.bullets.each { |string| buffer << "#{BULLET}#{string}\n" }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
print buffer unless ENV['RUBY_ENV'] == 'test'
|
14
|
+
print text unless testing?
|
32
15
|
|
33
16
|
true
|
34
17
|
end
|
18
|
+
|
19
|
+
def testing?
|
20
|
+
ENV['RUBY_ENV'] == 'test'
|
21
|
+
end
|
35
22
|
end
|
36
23
|
end
|
data/lib/tp/slide.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module TP
|
2
2
|
class Slide
|
3
|
-
|
3
|
+
attr_reader :markdown
|
4
4
|
|
5
5
|
def initialize(markdown)
|
6
|
-
|
6
|
+
@markdown = markdown.strip
|
7
7
|
end
|
8
8
|
|
9
9
|
def header
|
@@ -11,40 +11,34 @@ module TP
|
|
11
11
|
line[1, line.length - 1].to_s.strip
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def centered_header
|
15
|
+
header.center Screen.width
|
16
|
+
end
|
17
|
+
|
18
|
+
def content
|
15
19
|
result = lines[2, lines.count - 2]
|
16
20
|
|
17
|
-
result.join
|
21
|
+
result.join if result
|
18
22
|
end
|
19
23
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
result = body.scan(/^\*\s+(.+)/).flatten
|
24
|
+
def frames
|
25
|
+
[render]
|
26
|
+
end
|
24
27
|
|
25
|
-
|
28
|
+
def lines
|
29
|
+
markdown.lines.to_a
|
26
30
|
end
|
27
31
|
|
28
|
-
def
|
29
|
-
|
32
|
+
def render
|
33
|
+
raise NotImplementedError
|
30
34
|
end
|
31
35
|
|
32
36
|
def width
|
33
|
-
|
34
|
-
|
35
|
-
(body.lines.to_a.collect(&:length) + [header.length]).max
|
37
|
+
raise NotImplementedError
|
36
38
|
end
|
37
39
|
|
38
40
|
def height
|
39
|
-
|
40
|
-
|
41
|
-
body.lines.count + 2
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def lines
|
47
|
-
markdown.lines.to_a
|
41
|
+
lines.count
|
48
42
|
end
|
49
43
|
end
|
50
44
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class TP::Slide::Bulleted < TP::Slide
|
2
|
+
BULLET = "\u2022 "
|
3
|
+
|
4
|
+
def render
|
5
|
+
frames.last
|
6
|
+
end
|
7
|
+
|
8
|
+
def width
|
9
|
+
header_length = header.length
|
10
|
+
longest_bullet = bullets.collect(&:length).max + 2
|
11
|
+
[header_length, longest_bullet].max
|
12
|
+
end
|
13
|
+
|
14
|
+
def bullets
|
15
|
+
content.lines.to_a.map { |line| line.gsub(/^\*\s/, "").strip }
|
16
|
+
end
|
17
|
+
|
18
|
+
def frames
|
19
|
+
return @frames if @frames
|
20
|
+
|
21
|
+
buffer = centered_header
|
22
|
+
buffer << "\n\n"
|
23
|
+
|
24
|
+
@frames = [buffer.dup]
|
25
|
+
|
26
|
+
bullets.each do |bullet|
|
27
|
+
buffer << "#{BULLET} #{bullet}\n"
|
28
|
+
@frames << buffer.dup
|
29
|
+
end
|
30
|
+
|
31
|
+
@frames
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class TP::Slide::Code < TP::Slide
|
2
|
+
def render
|
3
|
+
centered_header +
|
4
|
+
"\n\n" +
|
5
|
+
highlighted_code
|
6
|
+
end
|
7
|
+
|
8
|
+
def height
|
9
|
+
code.lines.count + 2
|
10
|
+
end
|
11
|
+
|
12
|
+
def width
|
13
|
+
lines.collect { |line| line.rstrip.length }.max
|
14
|
+
end
|
15
|
+
|
16
|
+
def code
|
17
|
+
content.lines.to_a.reject { |line| line.start_with? "```" }.join
|
18
|
+
end
|
19
|
+
|
20
|
+
def highlighted_code
|
21
|
+
CodeRay.encode(code, language, :terminal)
|
22
|
+
end
|
23
|
+
|
24
|
+
def raw_language
|
25
|
+
match = lines[2].match(/^\`{3}(\w+)/)
|
26
|
+
|
27
|
+
match[1] if match
|
28
|
+
end
|
29
|
+
|
30
|
+
def language
|
31
|
+
case raw_language
|
32
|
+
when nil then "text"
|
33
|
+
when "clj" then "clojure"
|
34
|
+
when "objc" then "cpp"
|
35
|
+
when "rb" then "ruby"
|
36
|
+
else
|
37
|
+
raw_language
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TP::Slide::Paragraph < TP::Slide
|
2
|
+
def render
|
3
|
+
centered_header +
|
4
|
+
"\n\n" +
|
5
|
+
paragraph
|
6
|
+
end
|
7
|
+
|
8
|
+
def paragraph
|
9
|
+
buffer = content.wrap Screen.width
|
10
|
+
buffer = buffer.center Screen.width if buffer.lines.one?
|
11
|
+
|
12
|
+
buffer
|
13
|
+
end
|
14
|
+
|
15
|
+
def width
|
16
|
+
content.length
|
17
|
+
end
|
18
|
+
end
|
data/lib/tp/slide_deck.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module TP
|
2
2
|
class SlideDeck
|
3
|
-
|
3
|
+
attr_reader :cursor, :slides
|
4
4
|
|
5
5
|
def initialize(slides)
|
6
|
-
|
7
|
-
|
6
|
+
@cursor = 0
|
7
|
+
@slides = slides
|
8
8
|
end
|
9
9
|
|
10
10
|
def [](index)
|
@@ -26,39 +26,26 @@ module TP
|
|
26
26
|
@frames = []
|
27
27
|
|
28
28
|
slides.each do |slide|
|
29
|
-
|
30
|
-
buffer = "# #{slide.header}"
|
31
|
-
|
32
|
-
@frames << Slide.new(buffer)
|
33
|
-
|
34
|
-
buffer << "\n"
|
35
|
-
|
36
|
-
slide.bullets.each do |bullet|
|
37
|
-
buffer << "\n* #{bullet}"
|
38
|
-
@frames << Slide.new(buffer)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
@frames << Slide.new("# #{slide.header}\n\n#{slide.body}")
|
42
|
-
end
|
29
|
+
@frames |= slide.frames
|
43
30
|
end
|
44
31
|
|
45
32
|
@frames
|
46
33
|
end
|
47
34
|
|
48
35
|
def next
|
49
|
-
|
36
|
+
@cursor += 1
|
50
37
|
|
51
38
|
current
|
52
39
|
end
|
53
40
|
|
54
41
|
def previous
|
55
|
-
|
42
|
+
@cursor -= 1
|
56
43
|
|
57
44
|
current
|
58
45
|
end
|
59
46
|
|
60
47
|
def width
|
61
|
-
slides_without_paragraphs = slides.reject
|
48
|
+
slides_without_paragraphs = slides.reject { |slide| slide.class == TP::Slide::Paragraph }
|
62
49
|
|
63
50
|
if slides_without_paragraphs.empty?
|
64
51
|
[slides.collect(&:width).max, 80].min
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TP
|
2
|
+
class SlideFactory
|
3
|
+
def self.from_markdown(markdown)
|
4
|
+
lines = markdown.lines.to_a
|
5
|
+
|
6
|
+
return Slide::HeaderOnly.new markdown if lines.count < 3
|
7
|
+
|
8
|
+
content = lines[2, lines.count - 2].join
|
9
|
+
|
10
|
+
case content.lines.first
|
11
|
+
when /^\*\s/
|
12
|
+
Slide::Bulleted.new markdown
|
13
|
+
when /^\`{3}/
|
14
|
+
Slide::Code.new markdown
|
15
|
+
else
|
16
|
+
Slide::Paragraph.new markdown
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/tp/version.rb
CHANGED
data/slides.md
CHANGED
@@ -6,7 +6,7 @@ Terminal Presenter
|
|
6
6
|
|
7
7
|
# tp
|
8
8
|
|
9
|
-
Presents Markdown in your terminal
|
9
|
+
Presents Markdown slides in your terminal
|
10
10
|
|
11
11
|
# Installation
|
12
12
|
|
@@ -38,6 +38,16 @@ There can also be...
|
|
38
38
|
|
39
39
|
...multiple paragraphs.
|
40
40
|
|
41
|
+
# Code
|
42
|
+
|
43
|
+
```rb
|
44
|
+
class And
|
45
|
+
def it
|
46
|
+
highlights(:code)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
41
51
|
#
|
42
52
|
|
43
53
|
Headers can also be blank
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::Slide::Bulleted do
|
4
|
+
subject { slide }
|
5
|
+
|
6
|
+
let(:markdown) { "# Bullets\n\n* Bullet 1\n* Bullet 2" }
|
7
|
+
let(:slide) { klass.new markdown }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Screen.stub width: 20
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:width) { should == 10 }
|
14
|
+
its(:height) { should == 4 }
|
15
|
+
|
16
|
+
describe "#render" do
|
17
|
+
subject(:lines) { slide.render.lines.to_a }
|
18
|
+
|
19
|
+
it { lines.count.should == 4 }
|
20
|
+
|
21
|
+
it "centers the header" do
|
22
|
+
lines[0].should == "Bullets".center(20) + "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "renders bullets" do
|
26
|
+
lines[2].should == "#{TP::Slide::Bulleted::BULLET} Bullet 1\n"
|
27
|
+
lines[3].should == "#{TP::Slide::Bulleted::BULLET} Bullet 2\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#frames" do
|
32
|
+
subject(:frames) { slide.frames }
|
33
|
+
|
34
|
+
its(:count) { should == 3 }
|
35
|
+
|
36
|
+
it "incrementally shows bullets" do
|
37
|
+
frames[0].should == "Bullets".center(20) + "\n\n"
|
38
|
+
|
39
|
+
frames[1].should == "Bullets".center(20) + "\n\n" +
|
40
|
+
"#{TP::Slide::Bulleted::BULLET} Bullet 1\n"
|
41
|
+
|
42
|
+
frames[2].should == "Bullets".center(20) + "\n\n" +
|
43
|
+
"#{TP::Slide::Bulleted::BULLET} Bullet 1\n" +
|
44
|
+
"#{TP::Slide::Bulleted::BULLET} Bullet 2\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::Slide::Code do
|
4
|
+
subject { slide }
|
5
|
+
|
6
|
+
let(:markdown) { "# Code\n\n```rb\nclass Thing\nend\n```" }
|
7
|
+
let(:slide) { klass.new markdown }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Screen.stub width: 20
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:width) { should == 11 }
|
14
|
+
its(:height) { should == 4 }
|
15
|
+
|
16
|
+
its(:code) { should == "class Thing\nend\n" }
|
17
|
+
its(:language) { should == "ruby" }
|
18
|
+
|
19
|
+
describe "#highlighted_code" do
|
20
|
+
subject(:highlighted_code) { slide.highlighted_code }
|
21
|
+
|
22
|
+
it "uses CodeRay" do
|
23
|
+
CodeRay.should_receive(:encode).with("class Thing\nend\n", "ruby", :terminal)
|
24
|
+
|
25
|
+
highlighted_code
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with no language" do
|
29
|
+
let(:markdown) { "# Code\n\n```\nThis is a code block\n```" }
|
30
|
+
|
31
|
+
it "doesn't raise an error" do
|
32
|
+
highlighted_code
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#render" do
|
38
|
+
subject(:render) { slide.render }
|
39
|
+
|
40
|
+
before do
|
41
|
+
slide.stub highlighted_code: "Highlighted code"
|
42
|
+
end
|
43
|
+
|
44
|
+
it { should == "Code".center(20) + "\n\n" + "Highlighted code" }
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::Slide::HeaderOnly do
|
4
|
+
subject { slide }
|
5
|
+
|
6
|
+
let(:markdown) { "# Header" }
|
7
|
+
let(:slide) { klass.new markdown }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Screen.stub width: 20
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:width) { should == 6 }
|
14
|
+
its(:height) { should == 1 }
|
15
|
+
|
16
|
+
describe "#render" do
|
17
|
+
subject(:lines) { slide.render.lines.to_a }
|
18
|
+
|
19
|
+
it { lines.count.should == 1 }
|
20
|
+
|
21
|
+
it "centers the header" do
|
22
|
+
lines[0].should == "Header".center(20)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::Slide::Paragraph do
|
4
|
+
subject { slide }
|
5
|
+
|
6
|
+
let(:markdown) { "# Paragraph\n\nShort paragraph" }
|
7
|
+
let(:slide) { klass.new markdown }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Screen.stub width: 20
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:width) { should == 15 }
|
14
|
+
its(:height) { should == 3 }
|
15
|
+
|
16
|
+
describe "#render" do
|
17
|
+
subject(:lines) { slide.render.lines.to_a }
|
18
|
+
|
19
|
+
it { lines.count.should == 3 }
|
20
|
+
|
21
|
+
it "centers the header" do
|
22
|
+
lines[0].should == "Paragraph".center(20) + "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "centers short paragraphs" do
|
26
|
+
lines[2].should == "Short paragraph".center(20)
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with long paragraphs" do
|
30
|
+
let(:markdown) { "# Paragraph\n\nThis is a very long paragraph" }
|
31
|
+
|
32
|
+
it "wraps" do
|
33
|
+
lines[2].should == "This is a very long\n"
|
34
|
+
lines[3].should == "paragraph"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -5,8 +5,8 @@ describe TP::SlideDeck do
|
|
5
5
|
|
6
6
|
let(:slides) {
|
7
7
|
[
|
8
|
-
TP::
|
9
|
-
TP::
|
8
|
+
TP::SlideFactory.from_markdown("# First Slide\n\n* Bullet 1\n* Bullet 2"),
|
9
|
+
TP::SlideFactory.from_markdown("# Second Slide\n\nThis is a paragraph")
|
10
10
|
]
|
11
11
|
}
|
12
12
|
|
@@ -15,7 +15,7 @@ describe TP::SlideDeck do
|
|
15
15
|
|
16
16
|
context "with only really long paragraphs" do
|
17
17
|
let (:slides) {
|
18
|
-
[TP::
|
18
|
+
[TP::SlideFactory.from_markdown("# First Slide\n\n#{'word ' * 100}")]
|
19
19
|
}
|
20
20
|
|
21
21
|
its(:width) { should == 80 }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::SlideFactory do
|
4
|
+
describe ".from_markdown" do
|
5
|
+
subject(:from_markdown) { klass.from_markdown markdown }
|
6
|
+
|
7
|
+
context "with only a header" do
|
8
|
+
let(:markdown) { "# Header" }
|
9
|
+
|
10
|
+
it { should be_a TP::Slide::HeaderOnly }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with a paragraph" do
|
14
|
+
let(:markdown) { "# Paragraph\n\nThis is a paragraph" }
|
15
|
+
|
16
|
+
it { should be_a TP::Slide::Paragraph }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with bullets" do
|
20
|
+
let(:markdown) { "# Bullets\n\n* Bullet" }
|
21
|
+
|
22
|
+
it { should be_a TP::Slide::Bulleted }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with a code block" do
|
26
|
+
let(:markdown) { "# Code\n\n```rb\n:test\n```" }
|
27
|
+
|
28
|
+
it { should be_a TP::Slide::Code }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/lib/tp/slide_spec.rb
CHANGED
@@ -4,86 +4,11 @@ describe TP::Slide do
|
|
4
4
|
subject(:slide) { klass.new markdown }
|
5
5
|
|
6
6
|
let(:markdown) {
|
7
|
-
"# First Slide\n\
|
7
|
+
"# First Slide\n\nThis is a slide with a paragraph"
|
8
8
|
}
|
9
9
|
|
10
10
|
its(:markdown) { should == markdown }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
"# First Slide\n\n* Bullet 1\n* Bullet 2"
|
15
|
-
}
|
16
|
-
|
17
|
-
its(:header) { should == "First Slide" }
|
18
|
-
its(:body) { should == "* Bullet 1\n* Bullet 2" }
|
19
|
-
|
20
|
-
its(:bullets) { should =~ ["Bullet 1", "Bullet 2"] }
|
21
|
-
its(:paragraph) { should be_nil }
|
22
|
-
|
23
|
-
its(:width) { should == 11 }
|
24
|
-
its(:height) { should == 4 }
|
25
|
-
end
|
26
|
-
|
27
|
-
context "with a paragraph" do
|
28
|
-
let(:markdown) {
|
29
|
-
"# First Slide\n\nThis is a paragraph of text"
|
30
|
-
}
|
31
|
-
|
32
|
-
its(:header) { should == "First Slide" }
|
33
|
-
its(:body) { should == "This is a paragraph of text" }
|
34
|
-
|
35
|
-
its(:bullets) { should be_nil }
|
36
|
-
its(:paragraph) { should == "This is a paragraph of text" }
|
37
|
-
|
38
|
-
its(:width) { should == 27 }
|
39
|
-
its(:height) { should == 3 }
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with just a header" do
|
43
|
-
let(:markdown) {
|
44
|
-
"# First Slide"
|
45
|
-
}
|
46
|
-
|
47
|
-
its(:header) { should == "First Slide" }
|
48
|
-
its(:body) { should be_nil }
|
49
|
-
|
50
|
-
its(:bullets) { should be_nil }
|
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 }
|
63
|
-
end
|
64
|
-
|
65
|
-
context "with a blank header" do
|
66
|
-
let(:markdown) {
|
67
|
-
"#\n\nFirst Slide"
|
68
|
-
}
|
69
|
-
|
70
|
-
its(:header) { should be_empty }
|
71
|
-
its(:body) { should == "First Slide" }
|
72
|
-
|
73
|
-
its(:bullets) { should be_nil }
|
74
|
-
its(:paragraph) { should == "First Slide" }
|
75
|
-
|
76
|
-
its(:width) { should == 11 }
|
77
|
-
its(:height) { should == 3 }
|
78
|
-
end
|
79
|
-
|
80
|
-
context "with trailing newlines" do
|
81
|
-
let(:markdown) {
|
82
|
-
"# First Slide\n\n* Bullet 1\n* Bullet 2\n\n"
|
83
|
-
}
|
84
|
-
|
85
|
-
it "strips whitespace" do
|
86
|
-
slide.markdown.should == "# First Slide\n\n* Bullet 1\n* Bullet 2"
|
87
|
-
end
|
88
|
-
end
|
12
|
+
its(:header) { should == "First Slide" }
|
13
|
+
its(:content) { should == "This is a slide with a paragraph" }
|
89
14
|
end
|
data/tp.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.version = TP::VERSION
|
11
11
|
gem.authors = ["Justin Campbell"]
|
12
12
|
gem.email = ["justin@justincampbell.me"]
|
13
|
-
gem.
|
14
|
-
gem.
|
13
|
+
gem.summary = "Terminal Presenter"
|
14
|
+
gem.description = "Presents Markdown slides in your terminal"
|
15
15
|
gem.homepage = "http://github.com/justincampbell/tp"
|
16
16
|
|
17
17
|
gem.files = `git ls-files`.split $/
|
@@ -19,6 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
|
22
|
+
gem.add_dependency "coderay"
|
23
|
+
|
22
24
|
gem.add_development_dependency "guard-rspec"
|
23
25
|
gem.add_development_dependency "rake"
|
24
26
|
gem.add_development_dependency "rspec"
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,6 +11,22 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coderay
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: guard-rspec
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,7 +91,7 @@ dependencies:
|
|
75
91
|
- - ! '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
78
|
-
description:
|
94
|
+
description: Presents Markdown slides in your terminal
|
79
95
|
email:
|
80
96
|
- justin@justincampbell.me
|
81
97
|
executables:
|
@@ -99,14 +115,24 @@ files:
|
|
99
115
|
- lib/tp/presenter.rb
|
100
116
|
- lib/tp/renderer.rb
|
101
117
|
- lib/tp/slide.rb
|
118
|
+
- lib/tp/slide/bulleted.rb
|
119
|
+
- lib/tp/slide/code.rb
|
120
|
+
- lib/tp/slide/header_only.rb
|
121
|
+
- lib/tp/slide/paragraph.rb
|
102
122
|
- lib/tp/slide_deck.rb
|
123
|
+
- lib/tp/slide_factory.rb
|
103
124
|
- lib/tp/version.rb
|
104
125
|
- slides.md
|
105
126
|
- spec/lib/keyboard_spec.rb
|
106
127
|
- spec/lib/screen_spec.rb
|
107
128
|
- spec/lib/string_spec.rb
|
108
129
|
- spec/lib/tp/presenter_spec.rb
|
130
|
+
- spec/lib/tp/slide/bulleted_spec.rb
|
131
|
+
- spec/lib/tp/slide/code_spec.rb
|
132
|
+
- spec/lib/tp/slide/header_only_spec.rb
|
133
|
+
- spec/lib/tp/slide/paragraph_spec.rb
|
109
134
|
- spec/lib/tp/slide_deck_spec.rb
|
135
|
+
- spec/lib/tp/slide_factory_spec.rb
|
110
136
|
- spec/lib/tp/slide_spec.rb
|
111
137
|
- spec/lib/tp_spec.rb
|
112
138
|
- spec/spec_helper.rb
|
@@ -135,13 +161,18 @@ rubyforge_project:
|
|
135
161
|
rubygems_version: 1.8.23
|
136
162
|
signing_key:
|
137
163
|
specification_version: 3
|
138
|
-
summary:
|
164
|
+
summary: Terminal Presenter
|
139
165
|
test_files:
|
140
166
|
- spec/lib/keyboard_spec.rb
|
141
167
|
- spec/lib/screen_spec.rb
|
142
168
|
- spec/lib/string_spec.rb
|
143
169
|
- spec/lib/tp/presenter_spec.rb
|
170
|
+
- spec/lib/tp/slide/bulleted_spec.rb
|
171
|
+
- spec/lib/tp/slide/code_spec.rb
|
172
|
+
- spec/lib/tp/slide/header_only_spec.rb
|
173
|
+
- spec/lib/tp/slide/paragraph_spec.rb
|
144
174
|
- spec/lib/tp/slide_deck_spec.rb
|
175
|
+
- spec/lib/tp/slide_factory_spec.rb
|
145
176
|
- spec/lib/tp/slide_spec.rb
|
146
177
|
- spec/lib/tp_spec.rb
|
147
178
|
- spec/spec_helper.rb
|