wstrip 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/wstrip +7 -1
- metadata +1 -1
data/bin/wstrip
CHANGED
@@ -9,9 +9,11 @@ class WStrip < TerminalRunner
|
|
9
9
|
option "--help", 0, "", "Shows this help file."
|
10
10
|
option "--recursive", 0, "", "Recursively get files from directories."
|
11
11
|
option "--extension", 1, "<extension_list>", "Only apply to files with the specified extensions."
|
12
|
+
option "--remove-tabs", 1, "<amount>", "Replaces all tabs by the specified number of spaces."
|
12
13
|
|
13
14
|
option_alias "--recursive", "-r"
|
14
15
|
option_alias "--extension", "-e"
|
16
|
+
option_alias "--remove-tabs", "-t"
|
15
17
|
|
16
18
|
help <<EOS
|
17
19
|
Removes all extra whitespace from the end of lines.
|
@@ -61,7 +63,11 @@ EOS
|
|
61
63
|
puts "Fixing #{file}"
|
62
64
|
lines = []
|
63
65
|
File.open(file, 'r').each_line do |line|
|
64
|
-
|
66
|
+
new_line = line.rstrip
|
67
|
+
if @@options.include?("--remove-tabs")
|
68
|
+
new_line = new_line.gsub(/\t/, " " * @@options["--remove-tabs"][0].to_i)
|
69
|
+
end
|
70
|
+
lines << new_line
|
65
71
|
end
|
66
72
|
File.open(file, 'w') do |f|
|
67
73
|
lines.each do |line|
|