Class: HookManager

Inherits:
Object
  • Object
show all
Defined in:
lib/sfb_scripts/hook_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ HookManager

Returns a new instance of HookManager.



9
10
11
12
# File 'lib/sfb_scripts/hook_manager.rb', line 9

def initialize(env)
  @shell = env[:shell]
  @repo = env[:repo]
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



7
8
9
# File 'lib/sfb_scripts/hook_manager.rb', line 7

def repo
  @repo
end

#shellObject (readonly)

Returns the value of attribute shell.



7
8
9
# File 'lib/sfb_scripts/hook_manager.rb', line 7

def shell
  @shell
end

Class Method Details

.install!(env) ⇒ Object



3
4
5
# File 'lib/sfb_scripts/hook_manager.rb', line 3

def self.install!(env)
  new(env).install!
end

Instance Method Details

#install!Object



18
19
20
21
22
23
# File 'lib/sfb_scripts/hook_manager.rb', line 18

def install!
  return if is_installed?

  create_file
  make_executable
end

#is_installed?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sfb_scripts/hook_manager.rb', line 14

def is_installed?
  File.file?('.git/hooks/pre-push')
end