Class: TailorHook::Hook

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

Instance Method Summary collapse

Constructor Details

#initialize(path, ignore_list = []) ⇒ Hook

Returns a new instance of Hook.



3
4
5
6
# File 'lib/tailor-hook/hook.rb', line 3

def initialize(path, ignore_list=[])
  @git_repo = GitRepo.new(path)
  @ignore_list = ignore_list.map { |path| File.expand_path(path) }
end

Instance Method Details

#hook!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tailor-hook/hook.rb', line 8

def hook!
  @errors = []

  files_to_check.each do |path|
    check_file(path)
  end


  if @errors.empty?
    result = 0
  else
    @errors.each { |e| print e }
    result = 1
  end

  result
end