Module: Hookshot

Defined in:
lib/hookshot.rb,
lib/hookshot/hook.rb,
lib/hookshot/version.rb,
lib/hookshot/git_hook.rb,
lib/hookshot/hooks_directory.rb,
lib/hookshot/git_hooks_directory.rb

Defined Under Namespace

Modules: GitHooksDirectory, HooksDirectory Classes: GitHook, Hook

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.current_working_directoryObject



29
30
31
32
# File 'lib/hookshot.rb', line 29

def self.current_working_directory
  path = @current_working_directory || Dir.pwd
  Pathname.new(path)
end


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hookshot.rb', line 14

def self.link(current_working_directory: nil)
  @current_working_directory = current_working_directory

  HooksDirectory.create_with_default_hooks unless HooksDirectory.exists?

  HooksDirectory.hooks.each do |hook|
    git_hook = GitHook.new(name: hook.name)

    next if git_hook.symlink?
    git_hook.backup if git_hook.file?

    git_hook.symlink(to: hook)
  end
end

.with_captured_stdoutObject



34
35
36
37
38
39
40
41
# File 'lib/hookshot.rb', line 34

def self.with_captured_stdout
  old_stdout = $stdout
  $stdout = StringIO.new
  yield
  $stdout.string
ensure
  $stdout = old_stdout
end