Class: Kamaze::Project::Tools::Git::Hooks
- Inherits:
-
Util
show all
- Extended by:
- Concern::Helper
- Defined in:
- lib/kamaze/project/tools/git/hooks.rb,
lib/kamaze/project/tools/git.rb,
lib/kamaze/project/tools/git/hooks/base_hook.rb,
lib/kamaze/project/tools/git/hooks/pre_commit.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Classes: BaseHook, PreCommit
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(repository) ⇒ Hooks
Returns a new instance of Hooks.
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 40
def initialize(repository)
@hooks = {}
@repository = repository
[:pre_commit].each { |n| self.class.register(n) }
self.class
.registered_hooks
.each { |name, klass| @hooks[name] = klass.new(repository) }
end
|
Class Attribute Details
.registered_hooks ⇒ Object
Returns the value of attribute registered_hooks.
20
21
22
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 20
def registered_hooks
@registered_hooks
end
|
Instance Attribute Details
65
66
67
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 65
def repository
@repository
end
|
Class Method Details
.register(name, klass = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 22
def register(name, klass = nil)
klass ||= proc do
cname = helper.get(:inflector).classify(name.to_s)
require_relative "hooks/#{name}"
helper.get(:inflector).constantize("#{self.name}::#{cname}")
end.call
@registered_hooks ||= {}
@registered_hooks[name] = klass
self
end
|
Instance Method Details
#[](key) ⇒ nil|Array<Hook>
58
59
60
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 58
def [](key)
to_h[key]
end
|
#to_h ⇒ Hash
52
53
54
|
# File 'lib/kamaze/project/tools/git/hooks.rb', line 52
def to_h
@hooks.freeze
end
|