class GitSemverCop::Generator

Our generator that creates the commit hook

Public Class Methods

destination() click to toggle source
# File lib/git-semver-cop/generator.rb, line 12
def self.destination
  # For submodules which have a .git file that points to the module
  hooks_dir = "/hooks/pre-commit"

  if File.file?(".git")
    File.expand_path(submodule_git + hooks_dir, Dir.pwd)
  else
    File.expand_path(".git" + hooks_dir, Dir.pwd)
  end
end
source_root() click to toggle source
# File lib/git-semver-cop/generator.rb, line 8
def self.source_root
  File.expand_path("../../hooks", __FILE__)
end
submodule_git() click to toggle source
# File lib/git-semver-cop/generator.rb, line 23
def self.submodule_git
  File.read(".git").strip[/^(gitdir: )(.+)$/, 2]
end

Public Instance Methods

destroy() click to toggle source
# File lib/git-semver-cop/generator.rb, line 34
def destroy
  remove_file self.class.destination
end
init() click to toggle source
# File lib/git-semver-cop/generator.rb, line 28
def init
  copy_file "pre-commit", self.class.destination
  chmod self.class.destination, 0744
end