class Forger::Hook
Public Class Methods
new(options={})
click to toggle source
# File lib/forger/hook.rb, line 5 def initialize(options={}) @options = options end
run(name, options={})
click to toggle source
# File lib/forger/hook.rb, line 29 def self.run(name, options={}) Hook.new(options).run(name.to_s) end
Public Instance Methods
hooks()
click to toggle source
# File lib/forger/hook.rb, line 17 def hooks hooks_path = "#{Forger.root}/config/hooks.yml" data = File.exist?(hooks_path) ? YAML.load_file(hooks_path) : {} data ? data : {} # in case the file is empty end
run(name)
click to toggle source
# File lib/forger/hook.rb, line 9 def run(name) return if @options[:noop] return unless hooks[name] command = hooks[name] puts "Running hook #{name}: #{command}" sh(command) end
sh(command)
click to toggle source
# File lib/forger/hook.rb, line 23 def sh(command) puts "=> #{command}".color(:green) success = system(command) abort("Command failed") unless success end