tp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/string.rb ADDED
@@ -0,0 +1,11 @@
1
+ class String
2
+ def wrap(width)
3
+ self.split("\n").collect { |line|
4
+ if line.length > width
5
+ line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip
6
+ else
7
+ line
8
+ end
9
+ } * "\n"
10
+ end
11
+ end
data/lib/tp/presenter.rb CHANGED
@@ -49,7 +49,10 @@ module TP
49
49
  buffer << "\n\n"
50
50
 
51
51
  if slide.paragraph
52
- buffer << slide.paragraph.center(Screen.width)
52
+ paragraph = slide.paragraph.wrap Screen.width
53
+ paragraph = paragraph.center Screen.width if paragraph.lines.one?
54
+
55
+ buffer << paragraph
53
56
  else
54
57
  slide.bullets.each { |string| buffer << "#{bullet}#{string}\n" }
55
58
  end
data/lib/tp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TP
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/tp.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'keyboard'
2
2
  require 'screen'
3
+ require 'string'
3
4
 
4
5
  require 'tp/presenter'
5
6
  require 'tp/slide'
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ describe "#wrap" do
5
+ let(:string) { "One two three four five" }
6
+
7
+ it { string.wrap(1).should == "One\ntwo\nthree\nfour\nfive" }
8
+ it { string.wrap(10).should == "One two\nthree four\nfive" }
9
+ end
10
+ end
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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-11 00:00:00.000000000 Z
12
+ date: 2012-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard-rspec
@@ -94,6 +94,7 @@ files:
94
94
  - bin/tp
95
95
  - lib/keyboard.rb
96
96
  - lib/screen.rb
97
+ - lib/string.rb
97
98
  - lib/tp.rb
98
99
  - lib/tp/presenter.rb
99
100
  - lib/tp/slide.rb
@@ -101,6 +102,7 @@ files:
101
102
  - lib/tp/version.rb
102
103
  - spec/lib/keyboard_spec.rb
103
104
  - spec/lib/screen_spec.rb
105
+ - spec/lib/string_spec.rb
104
106
  - spec/lib/tp/presenter_spec.rb
105
107
  - spec/lib/tp/slide_spec.rb
106
108
  - spec/lib/tp_spec.rb
@@ -134,6 +136,7 @@ summary: tp
134
136
  test_files:
135
137
  - spec/lib/keyboard_spec.rb
136
138
  - spec/lib/screen_spec.rb
139
+ - spec/lib/string_spec.rb
137
140
  - spec/lib/tp/presenter_spec.rb
138
141
  - spec/lib/tp/slide_spec.rb
139
142
  - spec/lib/tp_spec.rb