class SentiaGitHooks::Cli
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/sentia_git_hooks/cli.rb, line 8 def initialize(*args) super @scripts_dir = Pathname.new File.expand_path("../../scripts", __FILE__) @sentia_dir = Pathname.new("~/.sentia/").expand_path @sentia_hooks_dir = @sentia_dir + "git-hooks" @new_hooks_dir = Pathname.new(Dir.pwd) + ".git/hooks" end
Public Instance Methods
install()
click to toggle source
# File lib/sentia_git_hooks/cli.rb, line 29 def install script_files = Dir.entries @sentia_hooks_dir script_files.delete(".") script_files.delete("..") script_files.each do |file| existing_script = @sentia_hooks_dir + file new_hook = File.expand_path file, @new_hooks_dir begin FileUtils.ln_s existing_script, new_hook exit 0 rescue puts "Failed If a hook file already exists then we refuse to clobber it, you'll have to delete it manually, or have it call the functionality in our hook." exit 1 end end end
update()
click to toggle source
# File lib/sentia_git_hooks/cli.rb, line 20 def update FileUtils.mkdir_p @sentia_dir FileUtils.rm_f @sentia_hooks_dir FileUtils.ln_s @scripts_dir, @sentia_hooks_dir, force: true end