class SuperHooks::Installer::Global

A handler to deal with global hooks

Public Instance Methods

run() click to toggle source

Execute the installer

This will create the files needed for SuperHooks to work

# File lib/super_hooks/installer.rb, line 11
def run
  create_git_global_template_folder
  Git.command "config --global init.templatedir #{template_directory}"
end

Private Instance Methods

create_git_global_template_folder() click to toggle source
# File lib/super_hooks/installer.rb, line 22
def create_git_global_template_folder
  return if File.exist? template_directory
  FileUtils.mkdir_p(template_directory + '/hooks/')
  Hook::LIST.each do |hook|
    file_name = File.join(template_directory, 'hooks', hook)
    File.open(file_name, 'w', 0755) do |f|
      f.write(template_file)
    end
  end
end
template_directory() click to toggle source
# File lib/super_hooks/installer.rb, line 18
def template_directory
  ENV['HOME'] + '/.git_global_templates'
end
template_file() click to toggle source
# File lib/super_hooks/installer.rb, line 33
def template_file
  @template_file ||= begin
    orig_file = File.read(ROOT.join('templates', 'global_install_hook.erb'))
    ERB.new(orig_file).result(binding)
  end
end