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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -6
  3. data/bin/ww +16 -2
  4. data/lib/word_wrap/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd20368f51ab97ab2130a5314dfef7110eeec1de
4
- data.tar.gz: 2515235374c12afce9687ab692eafd1cb1d407ee
3
+ metadata.gz: e1a70d32334b66e7ff236e50a9760340b8cba324
4
+ data.tar.gz: 9f4045c589881e6b5c2dfc0193a6403eff6a9cfe
5
5
  SHA512:
6
- metadata.gz: 0f2c8e7ac8f3bae457a2097141c77e198131e1c649de5de10297f825ce2986968488f6b9e2d206f3bcf82f716f3c8545b300f2787314e5ffb9ce4188a6a13fe5
7
- data.tar.gz: 77dc5abc16756f9480656227e0c220789670667169135fdb7f441e8e48dce7870a6e39e160ff25c401f04a8b0f2a7668aea3243ebb7559b23bd95a3b11b97b94
6
+ metadata.gz: acc7097f0cd8d3d363a97ed348db10d244d559d7aaf560847b98443a7bd38afcf9a84288d6a8b8d9583ebe1614cbff61b3bfda5df45ed5e9851c01c3fb1e1939
7
+ data.tar.gz: efbef2079ef2de68025e1a6f46ba102641aafb9f4960b0bc280bb53bc349bc64c3f19c902157699acc1cf4e89317229c782761a11d928f5296edb85a2fc9e544
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # WordWrap
2
2
 
3
- This gem is a extremely simple tool to word-wrap texts, which is the one an
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 -w20 hip.txt
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 -w20
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 -w20 -f
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
- options = {:width => 80, :fit => false}
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
- print WordWrap::ww f.read, options[:width], options[:fit]
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]
@@ -1,3 +1,3 @@
1
1
  module WordWrap
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.2
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-01-24 00:00:00.000000000 Z
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler