whiteout 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/whiteout +0 -0
- data/lib/whiteout/version.rb +1 -1
- data/lib/whiteout.rb +17 -4
- metadata +3 -3
data/bin/whiteout
CHANGED
File without changes
|
data/lib/whiteout/version.rb
CHANGED
data/lib/whiteout.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require "whiteout/version"
|
2
2
|
require "optparse"
|
3
|
+
require "tempfile"
|
4
|
+
require "fileutils"
|
3
5
|
|
4
6
|
module Whiteout
|
5
7
|
def self.execute(*args)
|
6
8
|
recurse = false
|
9
|
+
verbose = false
|
7
10
|
|
8
11
|
opts = OptionParser.new do |opts|
|
9
12
|
opts.banner = "Usage: whiteout file1 [...]"
|
@@ -16,6 +19,10 @@ module Whiteout
|
|
16
19
|
opts.on('-r', '--recursive', 'Clean all files under each directory, recursively') do
|
17
20
|
recurse = true
|
18
21
|
end
|
22
|
+
|
23
|
+
opts.on('-v', '--verbose', 'Be verbose, naming files as they are being processed') do
|
24
|
+
verbose = true
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
28
|
begin
|
@@ -30,11 +37,17 @@ module Whiteout
|
|
30
37
|
abort opts.to_s if args.empty?
|
31
38
|
|
32
39
|
self.input_list(args, recurse).each do |file|
|
33
|
-
|
40
|
+
File.open(file) do |infile|
|
41
|
+
puts file if verbose
|
42
|
+
|
43
|
+
outfile = Tempfile.new('whiteout')
|
44
|
+
|
45
|
+
infile.each do |line|
|
46
|
+
outfile.write(self.clean(line))
|
47
|
+
end
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
f.write(self.clean(contents))
|
49
|
+
outfile.close
|
50
|
+
FileUtils.mv(outfile, infile)
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiteout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-14 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70106106751060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70106106751060
|
25
25
|
description: ! ' Removes trailing whitespace from standard input or from named files.
|
26
26
|
|
27
27
|
'
|