Class: GitHook::Runner
- Inherits:
-
Object
- Object
- GitHook::Runner
- Defined in:
- lib/git_hook/runner.rb
Class Method Summary collapse
Class Method Details
.context ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/git_hook/runner.rb', line 28 def self.context dsl = GitHook::DSL.eval('.githooks') repository = Git.open('.') GitHook.io.tty = `git config --get color.ui 2> #{GitHook::NULL}`.strip == 'true' ? Thor::Shell::Color.new : Thor::Shell::Basic.new return Hashr.new({ config: dsl, repository: repository, io: GitHook.io }) end |
.invoke(timing, hook_name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/git_hook/runner.rb', line 19 def self.invoke(timing, hook_name) ctx = self.context ctx.config.hooks[timing.to_sym].each do | hook | if hook[:class].name == hook_name return hook[:class].new(ctx.repository, timing.to_sym, hook[:options] || {}).invoke end end end |
.run(timing) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/git_hook/runner.rb', line 8 def self.run(timing) ctx = self.context result = ctx.config.hooks[timing.to_sym].inject(true) do | result, hook | result && hook[:class].new(ctx.repository, timing.to_sym, hook[:options] || {}).invoke end unless result exit(1) end end |