Class: Bringit::Hook
- Inherits:
-
Object
- Object
- Bringit::Hook
- Defined in:
- lib/bringit/hook.rb
Constant Summary collapse
- GL_PROTOCOL =
'web'.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#repo_path ⇒ Object
readonly
Returns the value of attribute repo_path.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(name, repo_path) ⇒ Hook
constructor
A new instance of Hook.
- #trigger(user_id, oldrev, newrev, ref) ⇒ Object
Constructor Details
#initialize(name, repo_path) ⇒ Hook
Returns a new instance of Hook.
8 9 10 11 12 |
# File 'lib/bringit/hook.rb', line 8 def initialize(name, repo_path) @name = name @repo_path = repo_path @path = File.join(repo_path.strip, 'hooks', name) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/bringit/hook.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/bringit/hook.rb', line 6 def path @path end |
#repo_path ⇒ Object (readonly)
Returns the value of attribute repo_path.
6 7 8 |
# File 'lib/bringit/hook.rb', line 6 def repo_path @repo_path end |
Instance Method Details
#exists? ⇒ Boolean
14 15 16 |
# File 'lib/bringit/hook.rb', line 14 def exists? File.exist?(path) end |
#trigger(user_id, oldrev, newrev, ref) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bringit/hook.rb', line 18 def trigger(user_id, oldrev, newrev, ref) return [true, nil] unless exists? Bundler.with_clean_env do case name when "pre-receive", "post-receive" call_receive_hook(user_id, oldrev, newrev, ref) when "update" call_update_hook(user_id, oldrev, newrev, ref) end end end |