class FitCommit::Installer

Constants

HOOK_TEMPLATE_PATH

Public Instance Methods

install() click to toggle source
# File lib/fit_commit/installer.rb, line 7
def install
  FileUtils.mkdir_p(File.dirname(hook_path))
  FileUtils.cp(HOOK_TEMPLATE_PATH, hook_path)
  FileUtils.chmod(0755, hook_path)
  $stdout.puts "Installed hook to #{hook_path}"
end
uninstall() click to toggle source
# File lib/fit_commit/installer.rb, line 14
def uninstall
  if delete_hook
    $stdout.puts "Deleted hook at #{hook_path}"
  else
    $stdout.puts "Hook not found at #{hook_path}"
  end
end

Private Instance Methods

delete_hook() click to toggle source
# File lib/fit_commit/installer.rb, line 36
def delete_hook
  deleted_count = File.delete(hook_path)
  deleted_count > 0
rescue Errno::ENOENT
  false
end
gitdir() click to toggle source
# File lib/fit_commit/installer.rb, line 28
def gitdir
  if File.directory?(".git")
    ".git"
  else
    File.readlines(".git").first.match(/gitdir: (.*)$/)[1]
  end
end
hook_path() click to toggle source
# File lib/fit_commit/installer.rb, line 24
def hook_path
  @hook_path ||= File.join(gitdir, "hooks/commit-msg")
end