word_wrap 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/bin/ww +16 -2
- data/lib/word_wrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1a70d32334b66e7ff236e50a9760340b8cba324
|
4
|
+
data.tar.gz: 9f4045c589881e6b5c2dfc0193a6403eff6a9cfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acc7097f0cd8d3d363a97ed348db10d244d559d7aaf560847b98443a7bd38afcf9a84288d6a8b8d9583ebe1614cbff61b3bfda5df45ed5e9851c01c3fb1e1939
|
7
|
+
data.tar.gz: efbef2079ef2de68025e1a6f46ba102641aafb9f4960b0bc280bb53bc349bc64c3f19c902157699acc1cf4e89317229c782761a11d928f5296edb85a2fc9e544
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# WordWrap
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/word_wrap.png)](http://badge.fury.io/rb/word_wrap)
|
4
|
+
|
5
|
+
This gem is a extremely simple tool to word-wrap texts, which is the one and
|
4
6
|
only thing it can do. It comes with a script called `ww` that you can use
|
5
7
|
in the command line. And of course, you can get the functionality from within
|
6
8
|
Ruby as well.
|
@@ -43,6 +45,7 @@ only two arguments:
|
|
43
45
|
#### Examples
|
44
46
|
|
45
47
|
The example file looks like this:
|
48
|
+
|
46
49
|
```bash
|
47
50
|
$ cat hip.txt
|
48
51
|
Forage Shoreditch disrupt Pitchfork meh.
|
@@ -52,7 +55,7 @@ vinyl.
|
|
52
55
|
```
|
53
56
|
|
54
57
|
```bash
|
55
|
-
$ ww -
|
58
|
+
$ ww -w 20 hip.txt
|
56
59
|
Forage Shoreditch
|
57
60
|
disrupt Pitchfork
|
58
61
|
meh.
|
@@ -64,8 +67,9 @@ vinyl.
|
|
64
67
|
```
|
65
68
|
|
66
69
|
But you can also use stdin:
|
70
|
+
|
67
71
|
```bash
|
68
|
-
$ cat hip | ww -
|
72
|
+
$ cat hip | ww -w 20
|
69
73
|
Forage Shoreditch
|
70
74
|
disrupt Pitchfork
|
71
75
|
meh.
|
@@ -77,16 +81,16 @@ vinyl.
|
|
77
81
|
```
|
78
82
|
|
79
83
|
Note the difference at end of the second paragraph:
|
84
|
+
|
80
85
|
```bash
|
81
|
-
$ cat hip | ww -
|
86
|
+
$ cat hip | ww -w 20 -f
|
82
87
|
Forage Shoreditch
|
83
88
|
disrupt Pitchfork
|
84
89
|
meh.
|
85
90
|
|
86
91
|
Mustache 3 wolf moon
|
87
92
|
gluten-free whatever
|
88
|
-
master burn
|
89
|
-
vinyl.
|
93
|
+
master burn vinyl.
|
90
94
|
```
|
91
95
|
|
92
96
|
### Ruby library
|
data/bin/ww
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
require 'optparse'
|
7
7
|
require 'word_wrap'
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
options = {:width => 80, :fit => false, :inplace => false}
|
10
11
|
OptionParser.new do |opts|
|
11
12
|
opts.banner = "Usage: ww [OPTIONS] [input-file]"
|
12
13
|
|
@@ -17,11 +18,24 @@ OptionParser.new do |opts|
|
|
17
18
|
opts.on("-w", "--width COLUMNS", "Set line width (defaults to 80)") do |w|
|
18
19
|
options[:width] = w.to_i
|
19
20
|
end
|
21
|
+
|
22
|
+
opts.on("-i", "--in-place", "Edit the input file in-place") do |i|
|
23
|
+
options[:inplace] = true
|
24
|
+
end
|
20
25
|
end.parse!
|
21
26
|
|
22
27
|
if ARGV.length > 0
|
28
|
+
result = nil
|
23
29
|
File.open(ARGV[0], "r") do |f|
|
24
|
-
|
30
|
+
result = WordWrap::ww f.read, options[:width], options[:fit]
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:inplace]
|
34
|
+
File.open(ARGV[0], "w") do |f|
|
35
|
+
f.print result
|
36
|
+
end
|
37
|
+
else
|
38
|
+
print result
|
25
39
|
end
|
26
40
|
else
|
27
41
|
print WordWrap::ww STDIN.read, options[:width], options[:fit]
|
data/lib/word_wrap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radek Pazdera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|