white 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/Gemfile +13 -0
  2. data/Gemfile.lock +16 -0
  3. data/Rakefile +12 -2
  4. data/VERSION +1 -1
  5. data/lib/white.rb +19 -4
  6. data/white.gemspec +53 -0
  7. metadata +42 -10
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ # gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ # gem "rcov", ">= 0"
13
+ end
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.0.0)
16
+ jeweler (~> 1.6.4)
data/Rakefile CHANGED
@@ -1,8 +1,19 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
2
12
  require 'rake'
3
13
 
4
14
  require 'jeweler'
5
15
  Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
6
17
  gem.name = "white"
7
18
  gem.homepage = "http://github.com/andreyvit/white"
8
19
  gem.license = "MIT"
@@ -10,7 +21,6 @@ Jeweler::Tasks.new do |gem|
10
21
  gem.description = %Q{Run from your project folder before committing to Git to avoid whitespace errors}
11
22
  gem.email = "andreyvit@gmail.com"
12
23
  gem.authors = ["Andrey Tarantsov"]
24
+ # dependencies defined in Gemfile
13
25
  end
14
26
  Jeweler::RubygemsDotOrgTasks.new
15
-
16
- task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.1
@@ -3,13 +3,14 @@ require 'optparse'
3
3
  class White
4
4
 
5
5
  def self.run args
6
- extensions = %w/rb java xml md coffee js html css less yml php info install module h m txt/
6
+ extensions = %w/rb java xml md markdown coffee js eco html haml css less styl yml php info install module h m c txt/
7
7
  names = %w/Rakefile Cakefile/
8
8
  default_tab_size = nil
9
9
  tab_sizes = {
10
10
  }
11
- exclusions = ['**/.git/**']
11
+ exclusions = ['**/.git/**', '**/node_modules/**/*']
12
12
  verbose = false
13
+ dry_run = false
13
14
 
14
15
  opts = OptionParser.new do |opts|
15
16
  opts.banner = "Usage: white [options]"
@@ -28,13 +29,17 @@ class White
28
29
  extensions << v
29
30
  end
30
31
 
31
- opts.on("-n", "--name=NAME", "Include files with the given name (e.g. -n Cakefile)") do |v|
32
+ opts.on("-i", "--name=NAME", "Include files with the given name (e.g. -n Cakefile)") do |v|
32
33
  names << v
33
34
  end
34
35
 
35
36
  opts.separator ""
36
37
  opts.separator "Common options:"
37
38
 
39
+ opts.on("-n", "--dry-run", "Don't actually change anything on disk") do
40
+ dry_run = true
41
+ end
42
+
38
43
  opts.on("-v", "--verbose", "Show a full list of processed files") do
39
44
  verbose = true
40
45
  end
@@ -54,6 +59,8 @@ class White
54
59
  files -= Dir[exclusion]
55
60
  end
56
61
 
62
+ files -= Dir['**/.keepwhitespace'].map { |f| Dir[File.join(File.dirname(f), '**/*')] }.flatten
63
+
57
64
  files_with_tabs = []
58
65
 
59
66
  files.each do |file|
@@ -65,10 +72,18 @@ class White
65
72
  text = File.read(file)
66
73
  original = text.dup
67
74
 
75
+ prev = text.dup
76
+ text.gsub! /\r/, ''
77
+ errors << "Windows line breaks" if text != prev
78
+
68
79
  prev = text.dup
69
80
  text.gsub! /[ \t]+$/, ''
70
81
  errors << "trailing whitespace" if text != prev
71
82
 
83
+ prev = text.dup
84
+ text.gsub! /\r/, ''
85
+ errors << "Windows line breaks" if text != prev
86
+
72
87
  if text =~ /^ *?\t[\t ]*/
73
88
  if default_tab_size == nil
74
89
  files_with_tabs << file unless files_with_tabs.include?(file)
@@ -89,7 +104,7 @@ class White
89
104
 
90
105
  if text != original
91
106
  puts "#{file} (#{errors.join(', ')})"
92
- File.open(file, 'w') { |f| f.write text }
107
+ File.open(file, 'w') { |f| f.write text } unless dry_run
93
108
  else
94
109
  puts "#{file} OK" if verbose
95
110
  end
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{white}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Andrey Tarantsov}]
12
+ s.date = %q{2011-12-15}
13
+ s.description = %q{Run from your project folder before committing to Git to avoid whitespace errors}
14
+ s.email = %q{andreyvit@gmail.com}
15
+ s.executables = [%q{white}]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/white",
29
+ "lib/white.rb",
30
+ "white.gemspec"
31
+ ]
32
+ s.homepage = %q{http://github.com/andreyvit/white}
33
+ s.licenses = [%q{MIT}]
34
+ s.require_paths = [%q{lib}]
35
+ s.rubygems_version = %q{1.8.6}
36
+ s.summary = %q{Fix whitespace errors before committing to Git}
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
43
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
44
+ else
45
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
46
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
51
+ end
52
+ end
53
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: white
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 2
8
9
  - 1
9
- - 0
10
- version: 0.1.0
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrey Tarantsov
@@ -15,10 +15,40 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-09 00:00:00 +07:00
19
- default_executable: white
20
- dependencies: []
21
-
18
+ date: 2011-12-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ hash: 23
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :development
33
+ requirement: *id001
34
+ prerelease: false
35
+ name: bundler
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 7
43
+ segments:
44
+ - 1
45
+ - 6
46
+ - 4
47
+ version: 1.6.4
48
+ type: :development
49
+ requirement: *id002
50
+ prerelease: false
51
+ name: jeweler
22
52
  description: Run from your project folder before committing to Git to avoid whitespace errors
23
53
  email: andreyvit@gmail.com
24
54
  executables:
@@ -30,13 +60,15 @@ extra_rdoc_files:
30
60
  - README.md
31
61
  files:
32
62
  - .document
63
+ - Gemfile
64
+ - Gemfile.lock
33
65
  - LICENSE.txt
34
66
  - README.md
35
67
  - Rakefile
36
68
  - VERSION
37
69
  - bin/white
38
70
  - lib/white.rb
39
- has_rdoc: true
71
+ - white.gemspec
40
72
  homepage: http://github.com/andreyvit/white
41
73
  licenses:
42
74
  - MIT
@@ -66,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
98
  requirements: []
67
99
 
68
100
  rubyforge_project:
69
- rubygems_version: 1.3.7
101
+ rubygems_version: 1.8.6
70
102
  signing_key:
71
103
  specification_version: 3
72
104
  summary: Fix whitespace errors before committing to Git