matthewtodd-git-whitespace 0.2.2

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.
Files changed (6) hide show
  1. data/CHANGELOG +21 -0
  2. data/README +1 -0
  3. data/TODO +2 -0
  4. data/bin/git-whitespace +6 -0
  5. data/lib/whitespace.rb +32 -0
  6. metadata +64 -0
data/CHANGELOG ADDED
@@ -0,0 +1,21 @@
1
+ == 0.2.2
2
+ * Add gemspec for publishing on GitHub.
3
+
4
+ == 0.2.1
5
+ * Bugfix: detect spaces at the end of any line, not just blank ones.
6
+
7
+ == 0.2.0
8
+ * Automatically ignore .git and vendor directories.
9
+ * Use pure ruby to find files to examine.
10
+
11
+ == 0.1.3
12
+ * Include haml files.
13
+
14
+ == 0.1.2
15
+ * Only run find twice.
16
+
17
+ == 0.1.1
18
+ * Ignore pkg dir.
19
+
20
+ == 0.1.0
21
+ * Initial release.
data/README ADDED
@@ -0,0 +1 @@
1
+ Not yet.
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ * Instead of hardcoding file extensions, somehow use git to tell me which file to process. Except git doesn't care if a file's binary, right?
2
+ * Feature Request: give me a flag (or make it default?) to only process the files that I've modified. I have another project I'm working on that I don't want to do the mass cleanup on, but certainly everytime I check files in, I want to keep them clean. If you haven't seen it yet, checkout ruby-git for a Ruby git library. Of course, the pre-commit hook has an example of how to get the diffs in a shell script.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'whitespace')
4
+
5
+ files = Finder.new.files(Dir.pwd)
6
+ exec "ruby", "-pi", "-e", "gsub(/ +$/, '')", *files
data/lib/whitespace.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'find'
2
+
3
+ class Finder
4
+ def initialize
5
+ @directories_to_prune = %w[.git vendor]
6
+ @extensions = %w[builder css erb haml html icalendar js rake rb yml] + ['']
7
+ end
8
+
9
+ def files(directory)
10
+ files = []
11
+
12
+ Find.find directory do |path|
13
+ if FileTest.directory? path
14
+ Find.prune if should_prune?(path)
15
+ else
16
+ files.push(path) if should_include?(path)
17
+ end
18
+ end
19
+
20
+ files
21
+ end
22
+
23
+ private
24
+
25
+ def should_include?(path)
26
+ @extensions.include?(File.extname(path).sub(/^\./, ''))
27
+ end
28
+
29
+ def should_prune?(path)
30
+ @directories_to_prune.include?(File.basename(path))
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matthewtodd-git-whitespace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Todd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-10 00:00:00 -07:00
13
+ default_executable: git-whitespace
14
+ dependencies: []
15
+
16
+ description:
17
+ email: matthew.todd@gmail.com
18
+ executables:
19
+ - git-whitespace
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGELOG
25
+ - TODO
26
+ files:
27
+ - CHANGELOG
28
+ - README
29
+ - TODO
30
+ - bin/git-whitespace
31
+ - lib/whitespace.rb
32
+ has_rdoc: true
33
+ homepage:
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --main
37
+ - README
38
+ - --title
39
+ - git-whitespace-0.2.2
40
+ - --inline-source
41
+ - --line-numbers
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: Squashes whitespace from text files in the current project.
63
+ test_files: []
64
+