tp 0.6.2 → 0.7.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +0 -1
- data/.travis.yml +1 -2
- data/Gemfile +4 -7
- data/Guardfile +1 -1
- data/Rakefile +5 -1
- data/lib/screen.rb +20 -3
- data/lib/tp/presenter.rb +2 -2
- data/lib/tp/renderer.rb +1 -5
- data/lib/tp/slide/paragraph.rb +5 -1
- data/lib/tp/version.rb +1 -1
- data/spec/lib/screen_spec.rb +51 -0
- data/spec/lib/string_spec.rb +8 -0
- data/spec/lib/tp/renderer_spec.rb +27 -0
- data/spec/lib/tp/slide/paragraph_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -5
- data/tp.gemspec +11 -11
- metadata +10 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9813a862d681061c6eae802d73fa465781b9c552
|
4
|
+
data.tar.gz: 5e7e87045104c9d1fc27f81578428f53abc1c30a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac5aeb3b0295ed94721d33e443699ced0e4dbd9f1db6832bec02203e4efe7427fafff37b2a39f0543055da71712048bac43363c9bd597b22d49e8dca884ebe54
|
7
|
+
data.tar.gz: 2d420ed3e99cda9fbaf6a4993977cf3777e32f0af987e8a1cf6c0f29bd2feb9046b6c43814847b03850754eba732b44f715bb9d7411a4dfee8e719e0038ee900
|
data/.cane
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -2,11 +2,8 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem 'rb-fsevent'
|
10
|
-
gem 'growl'
|
11
|
-
end
|
5
|
+
group :development do
|
6
|
+
gem 'guard'
|
7
|
+
gem 'guard-cane'
|
8
|
+
gem 'guard-rspec'
|
12
9
|
end
|
data/Guardfile
CHANGED
data/Rakefile
CHANGED
data/lib/screen.rb
CHANGED
@@ -1,26 +1,43 @@
|
|
1
1
|
module Screen
|
2
2
|
extend self
|
3
3
|
|
4
|
+
X_GUTTER = 2
|
5
|
+
Y_GUTTER = 1
|
6
|
+
|
7
|
+
def add_gutter(text)
|
8
|
+
text = text.lines.map { |line|
|
9
|
+
line == "\n" ? line : " " * X_GUTTER + line
|
10
|
+
}.join
|
11
|
+
text = "\n" * Y_GUTTER + text
|
12
|
+
text
|
13
|
+
end
|
14
|
+
|
4
15
|
def clear!
|
5
16
|
print "\e[2J\e[f"
|
6
17
|
end
|
7
18
|
|
8
19
|
def hide_cursor
|
9
|
-
print "\e[#{height};#{width}H"
|
20
|
+
print "\e[#{height};#{width + X_GUTTER * 2}H"
|
10
21
|
end
|
11
22
|
|
12
23
|
def height
|
13
24
|
`tput lines`.to_i
|
14
25
|
end
|
15
26
|
|
27
|
+
def print(text)
|
28
|
+
Kernel.print text
|
29
|
+
end
|
30
|
+
|
16
31
|
def suggest(x, y)
|
32
|
+
Y_GUTTER.times { print "x" * (x + X_GUTTER * 2) + "\n" }
|
17
33
|
y.times do |n|
|
18
34
|
print "\n" if n.nonzero?
|
19
|
-
print "\u2588" * x
|
35
|
+
print "x" * X_GUTTER + "\u2588" * x + "x" * X_GUTTER
|
20
36
|
end
|
37
|
+
Y_GUTTER.times { print "\n" + "x" * (x + X_GUTTER * 2) }
|
21
38
|
end
|
22
39
|
|
23
40
|
def width
|
24
|
-
`tput cols`.to_i
|
41
|
+
`tput cols`.to_i - X_GUTTER * 2
|
25
42
|
end
|
26
43
|
end
|
data/lib/tp/presenter.rb
CHANGED
@@ -22,9 +22,9 @@ module TP
|
|
22
22
|
Renderer.new(slide_deck.current_frame).render
|
23
23
|
|
24
24
|
case Keyboard.read
|
25
|
-
when :right, :down, :space, :return, 'l', '
|
25
|
+
when :right, :down, :space, :return, 'l', 'j', 'd', 's'
|
26
26
|
slide_deck.next
|
27
|
-
when :left, :up, :backspace, 'h', '
|
27
|
+
when :left, :up, :backspace, 'h', 'k', 'a', 'w'
|
28
28
|
slide_deck.previous
|
29
29
|
when 'q'
|
30
30
|
break
|
data/lib/tp/renderer.rb
CHANGED
data/lib/tp/slide/paragraph.rb
CHANGED
data/lib/tp/version.rb
CHANGED
data/spec/lib/screen_spec.rb
CHANGED
@@ -3,10 +3,33 @@ require 'screen'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Screen do
|
6
|
+
describe ".add_gutter" do
|
7
|
+
subject(:add_gutter) { klass.add_gutter(text) }
|
8
|
+
|
9
|
+
let(:text) { " Header " }
|
10
|
+
|
11
|
+
before do
|
12
|
+
klass.stub width: 10
|
13
|
+
end
|
14
|
+
|
15
|
+
it "adds a gutter on the top and left" do
|
16
|
+
expect(add_gutter).to eq("\n Header ")
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with a paragraph slide" do
|
20
|
+
let(:text) { " Header \n\nAbc" }
|
21
|
+
it "indents the text and leaves a space on the right" do
|
22
|
+
expect(add_gutter).to eq("\n Header \n\n Abc")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
6
27
|
describe ".clear!" do
|
7
28
|
subject(:clear!) { klass.clear! }
|
8
29
|
|
9
30
|
it "clears the screen" do
|
31
|
+
Screen.unstub :clear!
|
32
|
+
|
10
33
|
Screen.should_receive(:print).with("\e[2J\e[f")
|
11
34
|
|
12
35
|
clear!
|
@@ -21,6 +44,34 @@ describe Screen do
|
|
21
44
|
end
|
22
45
|
end
|
23
46
|
|
47
|
+
describe ".hide_cursor" do
|
48
|
+
before do
|
49
|
+
klass.unstub :print
|
50
|
+
end
|
51
|
+
|
52
|
+
it "prints to the bottom right of the screen" do
|
53
|
+
expect(Kernel).to receive(:print) do |string|
|
54
|
+
string.match(/\\\e\[\d+;\d+/)
|
55
|
+
end
|
56
|
+
|
57
|
+
klass.hide_cursor
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe ".print" do
|
62
|
+
let(:text) { "foo" }
|
63
|
+
|
64
|
+
before do
|
65
|
+
klass.unstub :print
|
66
|
+
end
|
67
|
+
|
68
|
+
it "prints to the screen" do
|
69
|
+
expect(Kernel).to receive(:print).with(text)
|
70
|
+
|
71
|
+
klass.print text
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
24
75
|
describe ".width" do
|
25
76
|
subject(:width) { klass.width }
|
26
77
|
|
data/spec/lib/string_spec.rb
CHANGED
@@ -6,5 +6,13 @@ describe String do
|
|
6
6
|
|
7
7
|
it { string.wrap(1).should == "One\ntwo\nthree\nfour\nfive" }
|
8
8
|
it { string.wrap(10).should == "One two\nthree four\nfive" }
|
9
|
+
|
10
|
+
context "with multiple lines" do
|
11
|
+
let(:string) { "One two\nthree four\nfive" }
|
12
|
+
|
13
|
+
it { string.wrap(1).should == "One\ntwo\nthree\nfour\nfive" }
|
14
|
+
it { string.wrap(10).should == "One two\nthree four\nfive" }
|
15
|
+
it { string.wrap(100).should == string }
|
16
|
+
end
|
9
17
|
end
|
10
18
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TP::Renderer do
|
4
|
+
let(:renderer) { described_class.new(text) }
|
5
|
+
let(:text) { "foo" }
|
6
|
+
|
7
|
+
before do
|
8
|
+
renderer.stub :print
|
9
|
+
renderer.stub testing?: false
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
subject(:render) { renderer.render }
|
14
|
+
|
15
|
+
it "clears the screen" do
|
16
|
+
expect(Screen).to receive(:clear!)
|
17
|
+
|
18
|
+
render
|
19
|
+
end
|
20
|
+
|
21
|
+
it "prints the text to the screen" do
|
22
|
+
expect(Screen).to receive(:print).with(Screen.add_gutter(text))
|
23
|
+
|
24
|
+
render
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -13,6 +13,15 @@ describe TP::Slide::Paragraph do
|
|
13
13
|
its(:width) { should == 15 }
|
14
14
|
its(:height) { should == 3 }
|
15
15
|
|
16
|
+
context "when text is wrapped" do
|
17
|
+
before do
|
18
|
+
Screen.stub width: 10
|
19
|
+
end
|
20
|
+
|
21
|
+
its(:width) { should == 10 }
|
22
|
+
its(:height) { should == 4 }
|
23
|
+
end
|
24
|
+
|
16
25
|
describe "#render_terminal" do
|
17
26
|
subject(:lines) { slide.render_terminal.lines.to_a }
|
18
27
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,10 +4,8 @@ require 'support/klass'
|
|
4
4
|
|
5
5
|
puts RUBY_DESCRIPTION
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
SimpleCov.start
|
10
|
-
end
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
11
9
|
|
12
10
|
require 'tp'
|
13
11
|
|
@@ -16,5 +14,8 @@ RSpec.configure do |config|
|
|
16
14
|
config.run_all_when_everything_filtered = true
|
17
15
|
config.filter_run :focus
|
18
16
|
config.order = :random
|
19
|
-
end
|
20
17
|
|
18
|
+
config.before do
|
19
|
+
Screen.stub clear!: nil, print: nil
|
20
|
+
end
|
21
|
+
end
|
data/tp.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.summary = "Terminal Presenter"
|
14
14
|
gem.description = "Presents Markdown slides in your terminal"
|
15
15
|
gem.homepage = "https://github.com/justincampbell/tp"
|
16
|
+
gem.license = "MIT"
|
16
17
|
|
17
18
|
gem.post_install_message = File.read('WELCOME')
|
18
19
|
|
@@ -21,15 +22,14 @@ Gem::Specification.new do |gem|
|
|
21
22
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
23
|
gem.require_paths = ["lib"]
|
23
24
|
|
24
|
-
gem.
|
25
|
-
|
26
|
-
gem.add_dependency
|
27
|
-
|
28
|
-
gem.
|
29
|
-
|
30
|
-
gem.add_development_dependency
|
31
|
-
gem.add_development_dependency
|
32
|
-
gem.add_development_dependency
|
33
|
-
gem.add_development_dependency
|
34
|
-
gem.add_development_dependency "simplecov" if RUBY_DESCRIPTION.start_with? "ruby"
|
25
|
+
gem.required_ruby_version = '>= 1.9.3'
|
26
|
+
|
27
|
+
gem.add_dependency 'coderay', '~> 1.0'
|
28
|
+
gem.add_dependency 'prawn', '~> 0.12'
|
29
|
+
gem.add_dependency 'thor', '~> 0.17'
|
30
|
+
|
31
|
+
gem.add_development_dependency 'cane'
|
32
|
+
gem.add_development_dependency 'rake'
|
33
|
+
gem.add_development_dependency 'rspec'
|
34
|
+
gem.add_development_dependency 'simplecov'
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderay
|
@@ -66,48 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: guard
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: guard-rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: guard-cane
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
69
|
- !ruby/object:Gem::Dependency
|
112
70
|
name: rake
|
113
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,6 +152,7 @@ files:
|
|
194
152
|
- spec/lib/tp/coderay/prawn_encoder_spec.rb
|
195
153
|
- spec/lib/tp/presenter_spec.rb
|
196
154
|
- spec/lib/tp/publisher/pdf_spec.rb
|
155
|
+
- spec/lib/tp/renderer_spec.rb
|
197
156
|
- spec/lib/tp/slide/bulleted_spec.rb
|
198
157
|
- spec/lib/tp/slide/code_spec.rb
|
199
158
|
- spec/lib/tp/slide/header_only_spec.rb
|
@@ -206,7 +165,8 @@ files:
|
|
206
165
|
- spec/support/klass.rb
|
207
166
|
- tp.gemspec
|
208
167
|
homepage: https://github.com/justincampbell/tp
|
209
|
-
licenses:
|
168
|
+
licenses:
|
169
|
+
- MIT
|
210
170
|
metadata: {}
|
211
171
|
post_install_message: |2+
|
212
172
|
|
@@ -242,15 +202,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
202
|
requirements:
|
243
203
|
- - '>='
|
244
204
|
- !ruby/object:Gem::Version
|
245
|
-
version:
|
205
|
+
version: 1.9.3
|
246
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
207
|
requirements:
|
248
|
-
- - '
|
208
|
+
- - '>'
|
249
209
|
- !ruby/object:Gem::Version
|
250
|
-
version:
|
210
|
+
version: 1.3.1
|
251
211
|
requirements: []
|
252
212
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.0.
|
213
|
+
rubygems_version: 2.0.14
|
254
214
|
signing_key:
|
255
215
|
specification_version: 4
|
256
216
|
summary: Terminal Presenter
|
@@ -262,6 +222,7 @@ test_files:
|
|
262
222
|
- spec/lib/tp/coderay/prawn_encoder_spec.rb
|
263
223
|
- spec/lib/tp/presenter_spec.rb
|
264
224
|
- spec/lib/tp/publisher/pdf_spec.rb
|
225
|
+
- spec/lib/tp/renderer_spec.rb
|
265
226
|
- spec/lib/tp/slide/bulleted_spec.rb
|
266
227
|
- spec/lib/tp/slide/code_spec.rb
|
267
228
|
- spec/lib/tp/slide/header_only_spec.rb
|