whitespace 1.0.0
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.
- data/README +17 -0
- data/bin/whitespace +40 -0
- metadata +68 -0
data/README
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# whitespace
|
2
|
+
|
3
|
+
Strips whitespace in files modified by git.
|
4
|
+
|
5
|
+
## USAGE
|
6
|
+
|
7
|
+
Run it:
|
8
|
+
|
9
|
+
$ whitespace
|
10
|
+
|
11
|
+
You can also use it to strip whitespace from all files:
|
12
|
+
|
13
|
+
$ whitespace --all
|
14
|
+
|
15
|
+
That's pretty much it.
|
16
|
+
|
17
|
+
(c) Copyright 2011 Pat Nakajima. All Rights Reserved.
|
data/bin/whitespace
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# script/whitespace
|
4
|
+
#
|
5
|
+
# Strips whitespace from any files modified in git
|
6
|
+
# Also:
|
7
|
+
# - converts tabs to spaces
|
8
|
+
# - ensures a single newline at the end
|
9
|
+
class WhitespaceProcessor
|
10
|
+
def self.process(code)
|
11
|
+
result = []
|
12
|
+
code.each do |line|
|
13
|
+
line.gsub!(/(\s+)$/, "\n")
|
14
|
+
line.gsub!(/\t/, ' ')
|
15
|
+
result << line
|
16
|
+
end
|
17
|
+
|
18
|
+
while result.last =~ /^$/
|
19
|
+
result.pop
|
20
|
+
end
|
21
|
+
|
22
|
+
unless result.last =~ /\n$/
|
23
|
+
result << "\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
code = result.join
|
27
|
+
code.gsub!(/\A\n*/, '')
|
28
|
+
code
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
puts "* Stripping whitespace from modified files."
|
33
|
+
`git status`.split("\n").each do |line|
|
34
|
+
next unless line =~ /^#\tmodified:/
|
35
|
+
line = line.split(':').last.strip
|
36
|
+
puts " processing #{line}..."
|
37
|
+
code = File.read(line)
|
38
|
+
File.open(line, 'w+') { |f| f << (WhitespaceProcessor.process(code)) }
|
39
|
+
end
|
40
|
+
puts "* DONE"
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whitespace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pat Nakajima
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-19 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: patnakajima@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- README
|
32
|
+
- bin/whitespace
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: https://github.com/nakajima/whitespace
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.4.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Strips whitespace from files modified by git
|
67
|
+
test_files: []
|
68
|
+
|