Class: GitTracker::Hook
- Inherits:
-
Object
- Object
- GitTracker::Hook
- Defined in:
- lib/git_tracker/hook.rb
Instance Attribute Summary collapse
-
#hook_file ⇒ Object
readonly
Returns the value of attribute hook_file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root) ⇒ Hook
constructor
A new instance of Hook.
- #write ⇒ Object
Constructor Details
#initialize(root) ⇒ Hook
Returns a new instance of Hook.
15 16 17 |
# File 'lib/git_tracker/hook.rb', line 15 def initialize(root) @hook_file = File.join(root, '.git', 'hooks', 'prepare-commit-msg') end |
Instance Attribute Details
#hook_file ⇒ Object (readonly)
Returns the value of attribute hook_file.
5 6 7 |
# File 'lib/git_tracker/hook.rb', line 5 def hook_file @hook_file end |
Class Method Details
.init ⇒ Object
7 8 9 |
# File 'lib/git_tracker/hook.rb', line 7 def self.init init_at(Repository.root) end |
.init_at(root) ⇒ Object
11 12 13 |
# File 'lib/git_tracker/hook.rb', line 11 def self.init_at(root) new(root).write end |
Instance Method Details
#write ⇒ Object
19 20 21 22 23 24 |
# File 'lib/git_tracker/hook.rb', line 19 def write File.open(hook_file, 'w') do |f| f.write(hook_body) f.chmod(0755) end end |