Class: GitPrecommit::PrecommitTasks
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- GitPrecommit::PrecommitTasks
- Defined in:
- lib/git-precommit/precommit_tasks.rb
Constant Summary collapse
- TEMPLATE_PATH =
File. File.join( File.dirname(__FILE__), '..', '..', 'git-hooks' )
Instance Attribute Summary collapse
-
#template_path ⇒ Object
Returns the value of attribute template_path.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize {|_self| ... } ⇒ PrecommitTasks
constructor
A new instance of PrecommitTasks.
Constructor Details
#initialize {|_self| ... } ⇒ PrecommitTasks
Returns a new instance of PrecommitTasks.
11 12 13 14 15 16 |
# File 'lib/git-precommit/precommit_tasks.rb', line 11 def initialize() yield self if block_given? @template_path ||= TEMPLATE_PATH define end |
Instance Attribute Details
#template_path ⇒ Object
Returns the value of attribute template_path.
9 10 11 |
# File 'lib/git-precommit/precommit_tasks.rb', line 9 def template_path @template_path end |
Instance Method Details
#define ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/git-precommit/precommit_tasks.rb', line 18 def define() desc "Install the git pre-commit hook" file ".git/hooks/pre-commit" => "#{template_path}/pre-commit" do |t| warn "Git pre-commit hook missing, setting up…" copy t.prerequisites.first, t.name chmod 0755, t.name end desc "Install the git post-commit hook" file ".git/hooks/post-commit" => "#{template_path}/post-commit" do |t| copy t.prerequisites.first, t.name chmod 0755, t.name end namespace :git do desc "Install the git pre-commit hook" task :precommit => ".git/hooks/pre-commit" desc "Install the git post-commit hook" task :postcommit => ".git/hooks/post-commit" end end |