Class: Hubeye::Server::Strategy::LoadHook

Inherits:
Object
  • Object
show all
Defined in:
lib/server/hubeye_server.rb

Instance Method Summary collapse

Instance Method Details

#callObject



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/server/hubeye_server.rb', line 235

def call
  if @options[:internal]
    @silent = @options[:internal]
  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
    @session.hooks.merge!(new_hooks)
    unless @silent
      @socket.puts("Loaded #{@matches[1]} #{@matches[2]}")
    end
  else
    unless @silent
      @socket.puts("No #{@matches[1]} file to load from")
    end
  end
end