class TailorHook::Hook
Public Class Methods
new(path, ignore_list=[])
click to toggle source
# 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
Public Instance Methods
hook!()
click to toggle source
# 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
Private Instance Methods
check_file(path)
click to toggle source
# File lib/tailor-hook/hook.rb, line 28 def check_file(path) output = `tailor #{path}` unless $?.success? @errors << output end end
files_to_check()
click to toggle source
# File lib/tailor-hook/hook.rb, line 36 def files_to_check staged_files - @ignore_list end
staged_files()
click to toggle source
# File lib/tailor-hook/hook.rb, line 40 def staged_files @git_repo.staged_ruby_files end