Class: Hubeye::Server::Strategies::LoadHook

Inherits:
Object
  • Object
show all
Defined in:
lib/hubeye/server/strategies/load_hook.rb

Instance Method Summary collapse

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hubeye/server/strategies/load_hook.rb', line 8

def call
  if _t = @options[:internal]
    @silent = _t
  end
  hookfile = "#{ENV['HOME']}/.hubeye/hooks/#{@matches[2]}.yml"
  new_hooks = nil
  if File.exists?(hookfile)
    File.open(hookfile) do |f|
      new_hooks = YAML.load(f)
    end
    # need to fix this to check if there are already commands for that
    # repo
    session.hooks.merge!(new_hooks)
    unless @silent
      socket.deliver "Loaded #{@matches[1]} #{@matches[2]}"
    end
  else
    unless @silent
      socket.deliver "No #{@matches[1]} file to load from"
    end
  end
end