word_wrap 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/word_wrap.rb +8 -0
- data/lib/word_wrap/version.rb +1 -1
- data/spec/ww_spec.rb +23 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bed1b27447155f0f5e043578f34575d1085e8ae
|
4
|
+
data.tar.gz: 09d3be25f57cc210a25d10409db9f3f37553bb9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c847775b94f223e5987a6859aba87cd4f703d28f841b4a264d9f49aba2b5dcab6935651eb495eb0e0eea13dbe41a54cd364734a2bf65bd3fe02be6643f9947
|
7
|
+
data.tar.gz: 254ab4e7b1d4cc3abaee28ffc8233dc6743732f901e0864a52df2f09f0e39c5069fdc7811bc2ad24b49f7af41eb7783fd13937ec6c306e75c585c1071622c8e5
|
data/lib/word_wrap.rb
CHANGED
@@ -18,7 +18,15 @@ class String
|
|
18
18
|
WordWrap.ww(self, width, false)
|
19
19
|
end
|
20
20
|
|
21
|
+
def wrap!(width=DEFAULT_WIDTH)
|
22
|
+
replace wrap(width)
|
23
|
+
end
|
24
|
+
|
21
25
|
def fit(width=DEFAULT_WIDTH)
|
22
26
|
WordWrap.ww(self, width, true)
|
23
27
|
end
|
28
|
+
|
29
|
+
def fit!(width=DEFAULT_WIDTH)
|
30
|
+
replace fit(width)
|
31
|
+
end
|
24
32
|
end
|
data/lib/word_wrap/version.rb
CHANGED
data/spec/ww_spec.rb
CHANGED
@@ -151,7 +151,7 @@ EOF
|
|
151
151
|
wrapped = WordWrap.ww(text, 10, true)
|
152
152
|
wrapped.should eql expected
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
it "works without breaks" do
|
156
156
|
text =<<EOF
|
157
157
|
0123456789012345678 9
|
@@ -268,5 +268,27 @@ letterpress iPhone.
|
|
268
268
|
EOF
|
269
269
|
text.fit(20).should eql expected
|
270
270
|
end
|
271
|
+
|
272
|
+
it "wraps in-place" do
|
273
|
+
text = "0123456789 01234 0123456"
|
274
|
+
expected =<<EOF
|
275
|
+
0123456789
|
276
|
+
01234
|
277
|
+
0123456
|
278
|
+
EOF
|
279
|
+
text.wrap! 10
|
280
|
+
text.should eql expected
|
281
|
+
end
|
282
|
+
|
283
|
+
it "fits in-place" do
|
284
|
+
text = "0123456789 01234 0123456"
|
285
|
+
expected =<<EOF
|
286
|
+
0123456789
|
287
|
+
01234
|
288
|
+
0123456
|
289
|
+
EOF
|
290
|
+
text.fit! 10
|
291
|
+
text.should eql expected
|
292
|
+
end
|
271
293
|
end
|
272
294
|
end
|