code-cleaner 0.7 → 0.8
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.textile +1 -1
- data/bin/code-cleaner +1 -1
- data/code-cleaner.gemspec +1 -1
- data/support/pre-commit.erb +6 -2
- data/tasks.rb +1 -1
- data/tasks/code-cleaner.nake +1 -1
- metadata +2 -3
data/README.textile
CHANGED
@@ -24,7 +24,7 @@ Default behaviour is to ignore everything from vendor and gems directories and f
|
|
24
24
|
You can change this behaviour by setting environment variables @BLACKLIST@ and @WHITELIST@. What you pass to these variables will be treated as a regular expression. The default behaviour respond to @BLACKLIST='/(vendor|gems)/'@ and @WHITELIST='\.(rb|rake|task|thor)$'@. Here's an example how you can use it:
|
25
25
|
|
26
26
|
<pre>
|
27
|
-
WHITELIST=''^(Rakefile|Thorfile|.+\.(rb|rake|nake|thor|task))$'' BLACKLIST='/(vendor|gems)/' code-cleaner .
|
27
|
+
WHITELIST=''^(Rakefile|Thorfile|.+\.(rb|rake|nake|thor|task|gemspec))$'' BLACKLIST='/(vendor|gems)/' code-cleaner .
|
28
28
|
</pre>
|
29
29
|
|
30
30
|
Note that these rules aren't applied for explicit arguments, so if you run @code-cleaner README.textile@, your readme actually will be normalized. It's because blacklisting and whitelisting rules are applied just on directories, so if you run @code-cleaner .@, your readme will stay untouched. Because of this reason @code-cleaner .@ and @code-cleaner *@ will be different.
|
data/bin/code-cleaner
CHANGED
@@ -24,7 +24,7 @@ require "find"
|
|
24
24
|
|
25
25
|
$-i = "" # Windows compatibility
|
26
26
|
|
27
|
-
WHITELIST = Regexp.new(ENV["WHITELIST"] || '^(Rakefile|Thorfile|.+\.(rb|rake|nake|thor|task))$')
|
27
|
+
WHITELIST = Regexp.new(ENV["WHITELIST"] || '^(Rakefile|Thorfile|.+\.(rb|rake|nake|thor|task|gemspec))$')
|
28
28
|
BLACKLIST = Regexp.new(ENV["BLACKLIST"] || '/(vendor|gems)/')
|
29
29
|
|
30
30
|
def permitted?(file)
|
data/code-cleaner.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "code-cleaner"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.8"
|
7
7
|
s.authors = ["Jakub Šťastný aka Botanicus"]
|
8
8
|
s.homepage = "http://github.com/botanicus/code-cleaner"
|
9
9
|
s.summary = "Remove trailing whitespace, append missing \\n and replace tabs by two spaces"
|
data/support/pre-commit.erb
CHANGED
@@ -48,7 +48,6 @@ if which code-cleaner &> /dev/null; then
|
|
48
48
|
exit 1
|
49
49
|
elif [ $exitstatus -eq 0 ] ; then
|
50
50
|
printf "[\e[33mDONE\e[0m]\n"
|
51
|
-
git add "$file" # so the changes will be committed immediately
|
52
51
|
sleep=true # otherwise it might not work
|
53
52
|
else
|
54
53
|
abort "Unexpected exit status $?"
|
@@ -58,9 +57,14 @@ if which code-cleaner &> /dev/null; then
|
|
58
57
|
fi
|
59
58
|
fi
|
60
59
|
done
|
60
|
+
|
61
|
+
# otherwise it doesn't work time to time
|
62
|
+
$sleep && sleep 0.8
|
63
|
+
for file in $files; do
|
64
|
+
test -f "$file" && git add "$file" # so the changes will be committed immediately
|
65
|
+
done
|
61
66
|
else
|
62
67
|
abort "You have to have code-cleaner installed and the code-cleaner script has to be in your \$PATH ($PATH)"
|
63
68
|
fi
|
64
69
|
|
65
|
-
$sleep && sleep 0.1 # otherwise it might not work
|
66
70
|
exit 0
|
data/tasks.rb
CHANGED
@@ -9,5 +9,5 @@ end
|
|
9
9
|
Nake::Task["hooks:whitespace:install"].tap do |task|
|
10
10
|
task.config[:path] = "bin"
|
11
11
|
task.config[:encoding] = "utf-8"
|
12
|
-
task.config[:whitelist] = '(bin/[^/]+|.+\.(rb|rake|nake|thor|task))$'
|
12
|
+
task.config[:whitelist] = '(bin/[^/]+|.+\.(rb|rake|nake|thor|task|gemspec))$'
|
13
13
|
end
|
data/tasks/code-cleaner.nake
CHANGED
@@ -32,7 +32,7 @@ Nake::Task.new("hooks:whitespace:install") do |task|
|
|
32
32
|
options[:blacklist] = task.config[:blacklist] unless options[:blacklist]
|
33
33
|
|
34
34
|
if File.exist?(".git/hooks/pre-commit")
|
35
|
-
abort "
|
35
|
+
abort "The hook .git/hooks/pre-commit already exists. Run this task with --force if you want to overwrite it."
|
36
36
|
else
|
37
37
|
begin
|
38
38
|
puts "Installing .git/hooks/pre-commit ..."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code-cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.8"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
|
-
date:
|
11
|
+
date: 2010-01-08 00:00:00 +01:00
|
12
12
|
default_executable: code-cleaner
|
13
13
|
dependencies: []
|
14
14
|
|
@@ -22,7 +22,6 @@ extra_rdoc_files: []
|
|
22
22
|
|
23
23
|
files:
|
24
24
|
- bin/code-cleaner
|
25
|
-
- code-cleaner-0.7.gem
|
26
25
|
- code-cleaner.gemspec
|
27
26
|
- LICENSE
|
28
27
|
- README.textile
|