Class: Hooke::Linker

Inherits:
Object
  • Object
show all
Defined in:
lib/hooke/linker.rb

Overview

Link .git_hooks directory to .git/hooks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLinker

Returns a new instance of Linker.



7
8
9
# File 'lib/hooke/linker.rb', line 7

def initialize
  @app_dir = File.expand_path(Bundler.root)
end

Instance Attribute Details

#app_dirObject (readonly)

Returns the value of attribute app_dir.



5
6
7
# File 'lib/hooke/linker.rb', line 5

def app_dir
  @app_dir
end

Instance Method Details



11
12
13
14
15
16
17
18
# File 'lib/hooke/linker.rb', line 11

def symlink
  fail_with_link_error unless linkable?
  install_status = Dir.chdir(app_dir) do
    backup_directory('./.git/hooks')
    File.symlink("#{app_dir}/git_hooks", "#{app_dir}/.git/hooks")
  end
  install_status
end