Class: Hubeye::Server::Strategies::ListHooks

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

def call
  hooks = session.hooks
  if hooks.empty?
    socket.deliver "No hooks"
    return
  end
  pwd = File.expand_path('.')
  format_string = ""
  hooks.each do |repo, hash|
    local_dir = nil
    command = nil
    hash.each do |dir,cmd|
      if dir.nil?
        local_dir = pwd
        command = cmd.join("\n" + (' ' * 8))
      else
        command = cmd
        local_dir = dir
      end
    end
    format_string << <<EOS
remote: #{repo}
dir:    #{local_dir}
cmds:   #{command}\n
EOS
  end
  socket.deliver format_string
end