Class: GitTracker::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/git_tracker/hook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_fileObject (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

.initObject



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

#writeObject



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