Class: Hooks::Command
- Inherits:
-
Object
- Object
- Hooks::Command
- Defined in:
- lib/hooks/executer.rb
Defined Under Namespace
Classes: NoHookError
Class Method Summary collapse
-
.execute(commands, options = {}) ⇒ Object
options include the directory to execute the command (that’s it for now, will add more functionality later).
Class Method Details
.execute(commands, options = {}) ⇒ Object
options include the directory to execute the command (that’s it for now, will add more functionality later)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hooks/executer.rb', line 8 def self.execute(commands, ={}) opts = {:directory => nil, :repo => nil}.merge() dir = opts[:directory] repo = opts[:repo] begin commands.each do |cmd| if dir Dir.chdir(File.(dir)) do ::Kernel.system cmd end else ::Kernel.system cmd end end rescue ArgumentError raise NoHookError.new "There aren't any hook commands for the repository #{repo}" end end |