code-cleaner 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -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)
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "code-cleaner"
6
- s.version = "0.7"
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"
@@ -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
@@ -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 "You must remove .git/hooks/pre-commit first!"
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.7"
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: 2009-12-31 00:00:00 +01:00
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