rabbitt-githooks 1.3.0 → 1.3.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 (39) hide show
  1. checksums.yaml +5 -13
  2. data/Gemfile.lock +29 -19
  3. data/Rakefile +20 -0
  4. data/bin/githooks +2 -1
  5. data/bin/githooks-runner +10 -2
  6. data/lib/githooks.rb +11 -7
  7. data/lib/githooks/action.rb +67 -53
  8. data/lib/githooks/cli.rb +9 -6
  9. data/lib/githooks/commands/config.rb +26 -19
  10. data/lib/githooks/core_ext.rb +2 -1
  11. data/lib/githooks/core_ext/array/extract_options.rb +5 -1
  12. data/lib/githooks/core_ext/array/min_max.rb +4 -4
  13. data/lib/githooks/core_ext/array/select_with_index.rb +1 -1
  14. data/lib/githooks/core_ext/colorize.rb +30 -0
  15. data/lib/githooks/core_ext/object.rb +8 -0
  16. data/lib/githooks/core_ext/pathname.rb +7 -6
  17. data/lib/githooks/core_ext/string.rb +1 -1
  18. data/lib/githooks/core_ext/string/sanitize.rb +51 -0
  19. data/lib/githooks/error.rb +1 -0
  20. data/lib/githooks/hook.rb +21 -26
  21. data/lib/githooks/repository.rb +31 -35
  22. data/lib/githooks/repository/config.rb +16 -24
  23. data/lib/githooks/repository/diff_index_entry.rb +3 -2
  24. data/lib/githooks/repository/file.rb +14 -7
  25. data/lib/githooks/runner.rb +38 -36
  26. data/lib/githooks/section.rb +13 -19
  27. data/lib/githooks/system_utils.rb +132 -47
  28. data/lib/githooks/version.rb +1 -1
  29. data/lib/tasks/dev.task +14 -0
  30. data/rabbitt-githooks.gemspec +18 -15
  31. metadata +58 -33
  32. data/.gitignore +0 -34
  33. data/.hooks/commit-messages.rb +0 -29
  34. data/.hooks/formatting.rb +0 -44
  35. data/.rubocop.yml +0 -87
  36. data/lib/githooks/core_ext/process.rb +0 -9
  37. data/lib/githooks/core_ext/string/strip_empty_lines.rb +0 -9
  38. data/lib/githooks/terminal_colors.rb +0 -62
  39. data/thoughts.txt +0 -56
@@ -18,5 +18,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
18
18
  =end
19
19
 
20
20
  module GitHooks
21
- VERSION = '1.3.0'
21
+ VERSION = '1.3.2'
22
22
  end
@@ -0,0 +1,14 @@
1
+ desc 'Start IRB with githooks environment loaded'
2
+ task :console do
3
+ require 'pathname'
4
+ require 'bundler'
5
+ Bundler.setup(:default, :development)
6
+
7
+ lib_path = Pathname.new(__FILE__).join('../../../lib').realpath
8
+ $LOAD_PATH.unshift(lib_path.to_s)
9
+
10
+ ARGV.clear
11
+ require 'irb'
12
+ require 'irb/completion'
13
+ IRB.start
14
+ end
@@ -17,34 +17,37 @@ with this program; if not, write to the Free Software Foundation, Inc.,
17
17
  =end
18
18
 
19
19
  # coding: utf-8
20
-
21
- lib = File.expand_path('../lib', __FILE__)
22
- $:.unshift(lib) unless $:.include?(lib)
20
+ require 'pathname'
21
+ $:.unshift(Pathname.new(__FILE__).dirname.join('lib').to_s)
23
22
  require 'githooks'
24
23
 
25
24
  Gem::Specification.new do |spec|
26
- spec.name = "rabbitt-githooks"
25
+ spec.name = 'rabbitt-githooks'
27
26
  spec.version = GitHooks::VERSION
28
27
  spec.authors = GitHooks::AUTHOR.scan(/,?\s*([^<]+)<([^>]+)>\s*,?/).collect(&:first).collect(&:strip)
29
28
  spec.email = GitHooks::AUTHOR.scan(/,?\s*([^<]+)<([^>]+)>\s*,?/).collect(&:last).collect(&:strip)
30
- spec.description = "GitHooks provides a framework for building tests that can be used with git hooks"
31
- spec.homepage = "http://github.com/rabbitt/githooks"
32
- spec.summary = "framework for building git hooks tests"
33
- spec.license = "GPLv2"
34
- spec.rubygems_version = "2.0.14"
29
+ spec.description = 'GitHooks provides a framework for building tests that can be used with git hooks'
30
+ spec.homepage = 'http://github.com/rabbitt/githooks'
31
+ spec.summary = 'framework for building git hooks tests'
32
+ spec.license = 'GPLv2'
33
+ spec.rubygems_version = '2.0.14'
35
34
 
36
- spec.files = `git ls-files`.split($/)
35
+ spec.files = %x{ git ls-files }.split($/).grep(%r{^([A-Z]+|lib|bin|.+\.gemspec)})
37
36
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
38
37
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
39
- spec.require_paths = ["lib"]
40
- spec.extra_rdoc_files = ["README.md", 'LICENSE.txt']
38
+ spec.require_paths = ['lib']
39
+ spec.extra_rdoc_files = ['README.md', 'LICENSE.txt']
41
40
 
42
- spec.add_dependency 'colorize', '~> 0.5.8'
41
+ spec.add_dependency 'colorize', '~> 0.7.0'
43
42
  spec.add_dependency 'thor', '~> 0.18'
44
43
 
45
44
  spec.add_development_dependency 'rake', '~> 10.1'
46
- spec.add_development_dependency 'rspec', '~> 2.14'
47
45
  spec.add_development_dependency 'bundler', '~> 1.3'
46
+
47
+ spec.add_development_dependency 'yard', '~> 0.7'
48
+ spec.add_development_dependency 'rspec', '~> 2.14'
49
+ spec.add_development_dependency 'simplecov', '~> 0.9'
50
+
48
51
  spec.add_development_dependency 'rubocop', '~> 0.18'
49
- spec.add_development_dependency 'ruby-lint', '~> 2.0.1'
52
+ spec.add_development_dependency 'ruby-lint', '~> 2.0'
50
53
  end
metadata CHANGED
@@ -1,113 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitt-githooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl P. Corliss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.8
19
+ version: 0.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.8
26
+ version: 0.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.18'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.18'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rspec
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - ~>
87
+ - - "~>"
60
88
  - !ruby/object:Gem::Version
61
89
  version: '2.14'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - ~>
94
+ - - "~>"
67
95
  - !ruby/object:Gem::Version
68
96
  version: '2.14'
69
97
  - !ruby/object:Gem::Dependency
70
- name: bundler
98
+ name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - ~>
101
+ - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '1.3'
103
+ version: '0.9'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - ~>
108
+ - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '1.3'
110
+ version: '0.9'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rubocop
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - ~>
115
+ - - "~>"
88
116
  - !ruby/object:Gem::Version
89
117
  version: '0.18'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - ~>
122
+ - - "~>"
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0.18'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: ruby-lint
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - ~>
129
+ - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: 2.0.1
131
+ version: '2.0'
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ~>
136
+ - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: 2.0.1
138
+ version: '2.0'
111
139
  description: GitHooks provides a framework for building tests that can be used with
112
140
  git hooks
113
141
  email:
@@ -120,10 +148,6 @@ extra_rdoc_files:
120
148
  - README.md
121
149
  - LICENSE.txt
122
150
  files:
123
- - .gitignore
124
- - .hooks/commit-messages.rb
125
- - .hooks/formatting.rb
126
- - .rubocop.yml
127
151
  - Gemfile
128
152
  - Gemfile.lock
129
153
  - LICENSE.txt
@@ -140,14 +164,15 @@ files:
140
164
  - lib/githooks/core_ext/array/extract_options.rb
141
165
  - lib/githooks/core_ext/array/min_max.rb
142
166
  - lib/githooks/core_ext/array/select_with_index.rb
167
+ - lib/githooks/core_ext/colorize.rb
143
168
  - lib/githooks/core_ext/numbers.rb
144
169
  - lib/githooks/core_ext/numbers/infinity.rb
170
+ - lib/githooks/core_ext/object.rb
145
171
  - lib/githooks/core_ext/pathname.rb
146
- - lib/githooks/core_ext/process.rb
147
172
  - lib/githooks/core_ext/string.rb
148
173
  - lib/githooks/core_ext/string/git_option_path_split.rb
149
174
  - lib/githooks/core_ext/string/inflections.rb
150
- - lib/githooks/core_ext/string/strip_empty_lines.rb
175
+ - lib/githooks/core_ext/string/sanitize.rb
151
176
  - lib/githooks/error.rb
152
177
  - lib/githooks/hook.rb
153
178
  - lib/githooks/repository.rb
@@ -158,10 +183,9 @@ files:
158
183
  - lib/githooks/runner.rb
159
184
  - lib/githooks/section.rb
160
185
  - lib/githooks/system_utils.rb
161
- - lib/githooks/terminal_colors.rb
162
186
  - lib/githooks/version.rb
187
+ - lib/tasks/dev.task
163
188
  - rabbitt-githooks.gemspec
164
- - thoughts.txt
165
189
  homepage: http://github.com/rabbitt/githooks
166
190
  licenses:
167
191
  - GPLv2
@@ -172,12 +196,12 @@ require_paths:
172
196
  - lib
173
197
  required_ruby_version: !ruby/object:Gem::Requirement
174
198
  requirements:
175
- - - ! '>='
199
+ - - ">="
176
200
  - !ruby/object:Gem::Version
177
201
  version: '0'
178
202
  required_rubygems_version: !ruby/object:Gem::Requirement
179
203
  requirements:
180
- - - ! '>='
204
+ - - ">="
181
205
  - !ruby/object:Gem::Version
182
206
  version: '0'
183
207
  requirements: []
@@ -187,3 +211,4 @@ signing_key:
187
211
  specification_version: 4
188
212
  summary: framework for building git hooks tests
189
213
  test_files: []
214
+ has_rdoc:
data/.gitignore DELETED
@@ -1,34 +0,0 @@
1
- # rcov generated
2
- coverage
3
- coverage.data
4
-
5
- # rdoc generated
6
- rdoc
7
-
8
- # yard generated
9
- doc
10
- .yardoc
11
- _yard
12
-
13
- # bundler
14
- .bundle
15
-
16
- # jeweler generated
17
- pkg
18
-
19
- .DS_Store
20
-
21
- *.gem
22
- *.rbc
23
- .bundle
24
- .config
25
- InstalledFiles
26
- lib/bundler/man
27
- pkg
28
- rdoc
29
- spec/reports
30
- test/tmp
31
- test/version_tmp
32
- tmp
33
- test.rb
34
- t.rb
@@ -1,29 +0,0 @@
1
- require 'githooks'
2
-
3
- SIMPLE_MESSAGES = /^\s*(blah|\.+|foo|bar|baz|nits?|)\s*$/
4
-
5
- GitHooks::Hook.register 'commit-msg' do
6
- section 'Commit Message' do
7
- action 'Message Length > 5 characters' do
8
- on_argv do |args|
9
- if args.empty?
10
- $stderr.puts 'No commit message file passed in - are we executing in the commit-msg phase??'
11
- return false
12
- end
13
-
14
- IO.read(args.first).size > 5 unless args.empty?
15
- end
16
- end
17
-
18
- action 'Verify no simple commit messages' do
19
- on_argv do |args|
20
- if args.empty?
21
- $stderr.puts 'No commit message file passed in - are we executing in the commit-msg phase??'
22
- return false
23
- end
24
- # make sure there is at least one line that isn't a simple message
25
- IO.read(args.first).split(/\n/).any? { |line| line !~ SIMPLE_MESSAGES }
26
- end
27
- end
28
- end
29
- end
data/.hooks/formatting.rb DELETED
@@ -1,44 +0,0 @@
1
- require 'githooks'
2
-
3
- RUBY_FILE_REGEXP = %r{^((app|lib)/.+\.rb|bin/.+)$}.freeze
4
-
5
- GitHooks::Hook.register 'pre-commit' do
6
- commands :ruby, :rubocop
7
-
8
- section 'Standards' do
9
- action 'Validate Ruby Syntax' do
10
- limit(:type).to :modified, :added, :untracked, :tracked
11
- limit(:path).to RUBY_FILE_REGEXP
12
-
13
- on_each_file do |file|
14
- ruby '-c', file.path, prefix_output: file.path
15
- end
16
- end
17
-
18
- action 'Validate Ruby Standards' do
19
- limit(:type).to :modified, :added, :untracked, :tracked
20
- limit(:path).to RUBY_FILE_REGEXP
21
-
22
- on_all_files do |files|
23
- rubocop '-D', '--format', 'clang', files.collect(&:path), strip_empty_lines: true
24
- end
25
- end
26
-
27
- action 'No Leading Tabs in Ruby files' do
28
- limit(:type).to :modified, :added, :untracked, :tracked
29
- limit(:path).to RUBY_FILE_REGEXP
30
-
31
- on_each_file do |file|
32
- file.grep(/^[ ]*(\t+)/).tap do |matches|
33
- matches.each do |line_number, line_text|
34
- line_text.gsub!(/^[ ]*(\t+)/) do
35
- underscores = '_' * $1.size
36
- color_bright_red(underscores)
37
- end
38
- $stderr.printf "%s:%#{matches.last.first.to_s.size}d: %s\n", file.path, line_number, line_text
39
- end
40
- end.empty?
41
- end
42
- end
43
- end
44
- end
data/.rubocop.yml DELETED
@@ -1,87 +0,0 @@
1
- AllCops:
2
- Include:
3
- - Rakefile
4
- Exclude:
5
- - test.rb
6
- - bin/**
7
-
8
-
9
- SpecialGlobalVars:
10
- Enabled: false
11
-
12
- PerlBackrefs:
13
- Enabled: false
14
-
15
- Documentation:
16
- Enabled: false
17
-
18
- BlockComments:
19
- Enabled: false
20
-
21
- Encoding:
22
- Enabled: false
23
-
24
- MultilineBlockChain:
25
- Enabled: false
26
-
27
- Blocks:
28
- Enabled: false
29
-
30
- RegexpLiteral:
31
- Enabled: false
32
-
33
- # dots at the end of lines are okay
34
- DotPosition:
35
- Enabled: false
36
-
37
- Style/MethodLength:
38
- CountComments: false
39
- Max: 20
40
-
41
- ParameterLists:
42
- Max: 5
43
- CountKeywordArgs: true
44
-
45
- BlockNesting:
46
- Max: 4
47
-
48
- CollectionMethods:
49
- PreferredMethods:
50
- map: 'collect'
51
- map!: 'collect!'
52
- reduce: 'inject'
53
- detect: 'find'
54
- find_all: 'select'
55
-
56
- CaseIndentation:
57
- IndentWhenRelativeTo: end
58
- IndentOneStep: true
59
-
60
- LineLength:
61
- Enabled: false
62
-
63
- # Personally, I prefer to outdent public/protected/private, as it makes
64
- # it easier to see the different sections of code.
65
- AccessModifierIndentation:
66
- EnforcedStyle: outdent
67
-
68
- EmptyLinesAroundAccessModifier:
69
- Enabled: true
70
-
71
- EndAlignment:
72
- AlignWith: variable
73
-
74
- Style/DoubleNegation:
75
- Enabled: false
76
-
77
- Style/PercentLiteralDelimiters:
78
- Enabled: false
79
-
80
- Style/FormatString:
81
- Enabled: false
82
-
83
- Lint/UnusedMethodArgument:
84
- Enabled: false
85
-
86
- Style/EachWithObject:
87
- Enabled: false