githooks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3-p194@githooks
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in githooks.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yu Zhang
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Githooks
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'githooks'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install githooks
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/githooks ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.dirname($0)
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+
5
+ require 'optparse'
6
+ require 'fileutils'
7
+ require 'githooks'
8
+
9
+ banner = <<-BANNER
10
+ Usage: githooks [options]
11
+
12
+ Description:
13
+
14
+ Initializtion and helper script for githooks
15
+
16
+ BANNER
17
+
18
+ options = OptionParser.new do |opts|
19
+ opts.banner = banner.gsub(/^ {6}/, '')
20
+
21
+ opts.separator ''
22
+ opts.separator 'Options:'
23
+
24
+ opts.on('-i', '--install', 'Install githooks for the current project') do
25
+ exit unless system("git rev-parse")
26
+ git_root = `git rev-parse --show-toplevel`.chop
27
+ gem_root = File.expand_path "..", File.dirname($0)
28
+ FileUtils.cp_r(Dir["#{gem_root}/gems/githooks-#{Githooks::VERSION}/lib/hooks/*"], "#{git_root}/.git/hooks")
29
+ end
30
+
31
+ opts.on( '-l', '--list', 'List supported git hooks') do
32
+ puts Githooks::HookNames
33
+ exit
34
+ end
35
+
36
+ opts.on( '-h', '--help', 'Display this help.' ) do
37
+ puts opts
38
+ exit
39
+ end
40
+ end
41
+
42
+ options.parse!
43
+
44
+ puts options and exit if ARGV[0].nil?
data/githooks.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'githooks/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "githooks"
8
+ gem.version = Githooks::VERSION
9
+ gem.authors = ["Yu Zhang"]
10
+ gem.email = ["ian7zy@gmail.com"]
11
+ gem.description = %q{git hooks framework in Ruby}
12
+ gem.summary = %q{A framework to manage git hooks with your source code}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,54 @@
1
+ class String
2
+ def underscore
3
+ word = self.dup
4
+ word.gsub!(/::/, '/')
5
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
6
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
7
+ word.tr!("-", "_")
8
+ word.downcase!
9
+ word
10
+ end
11
+ end
12
+
13
+ module Githooks
14
+ HookNames = %w[applypatch_msg pre_applypatch post_applypatch
15
+ pre_commit prepare_commit_msg commit_msg post_commit
16
+ pre_rebase
17
+ post_checkout
18
+ post_merge
19
+ pre_receive post_receive update post_update
20
+ pre_auto_gc
21
+ post_rewrite]
22
+ class Base
23
+ def execute
24
+ lambda {
25
+ hooks = []
26
+ Kernel.send :define_method, self.class.name.underscore do |&block|
27
+ hooks << block
28
+ end
29
+
30
+ Kernel.send :define_method, :each_hook do |&block|
31
+ hooks.each do |hook|
32
+ block.call hook
33
+ end
34
+ end
35
+
36
+ Kernel.send :define_method, :method_missing do |method, *args|
37
+ super(method, args) unless Githooks::HookNames.include? method.to_s
38
+ end
39
+ }.call
40
+
41
+ git_root = `git rev-parse --show-toplevel`.chop
42
+
43
+ Dir.glob("#{git_root}/**/*_githooks.rb").each do |file|
44
+ load file
45
+ end
46
+
47
+ env = Object.new
48
+ each_hook do |hook|
49
+ env.instance_eval &hook
50
+ end
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module Githooks
2
+ VERSION = "0.0.1"
3
+ end
data/lib/githooks.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "githooks/version"
2
+ require "githooks/base"
3
+
4
+ module Githooks
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class ApplypatchMsg < Githooks::Base
6
+ end
7
+
8
+ ApplypatchMsg.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class CommitMsg < Githooks::Base
6
+ end
7
+
8
+ CommitMsg.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostApplypatch < Githooks::Base
6
+ end
7
+
8
+ PostApplypatch.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostCheckout < Githooks::Base
6
+ end
7
+
8
+ PostCheckout.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostCommit < Githooks::Base
6
+ end
7
+
8
+ PostCommit.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostMerge < Githooks::Base
6
+ end
7
+
8
+ PostMerge.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostReceive < Githooks::Base
6
+ end
7
+
8
+ PostReceive.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostRewrite < Githooks::Base
6
+ end
7
+
8
+ PostRewrite.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PostUpdate < Githooks::Base
6
+ end
7
+
8
+ PostUpdate.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PreApplypatch < Githooks::Base
6
+ end
7
+
8
+ PreApplypatch.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PreAutoGc < Githooks::Base
6
+ end
7
+
8
+ PreAutoGc.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PreCommit < Githooks::Base
6
+ end
7
+
8
+ PreCommit.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PreRebase < Githooks::Base
6
+ end
7
+
8
+ PreRebase.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PreReceive < Githooks::Base
6
+ end
7
+
8
+ PreReceive.new.execute
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class PrepareCommitMsg < Githooks::Base
6
+ end
7
+
8
+ PrepareCommitMsg.new.execute
data/lib/hooks/update ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'githooks'
4
+
5
+ class Update < Githooks::Base
6
+ end
7
+
8
+ Update.new.execute
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: githooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yu Zhang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: git hooks framework in Ruby
15
+ email:
16
+ - ian7zy@gmail.com
17
+ executables:
18
+ - githooks
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - .rvmrc
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/githooks
29
+ - githooks.gemspec
30
+ - lib/githooks.rb
31
+ - lib/githooks/base.rb
32
+ - lib/githooks/version.rb
33
+ - lib/hooks/applypatch-msg
34
+ - lib/hooks/commit-msg
35
+ - lib/hooks/post-applypatch
36
+ - lib/hooks/post-checkout
37
+ - lib/hooks/post-commit
38
+ - lib/hooks/post-merge
39
+ - lib/hooks/post-receive
40
+ - lib/hooks/post-rewrite
41
+ - lib/hooks/post-update
42
+ - lib/hooks/pre-applypatch
43
+ - lib/hooks/pre-auto-gc
44
+ - lib/hooks/pre-commit
45
+ - lib/hooks/pre-rebase
46
+ - lib/hooks/pre-receive
47
+ - lib/hooks/prepare-commit-msg
48
+ - lib/hooks/update
49
+ homepage: ''
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.24
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: A framework to manage git hooks with your source code
73
+ test_files: []