Class: Norikra::WebUI::Handler

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/norikra/webui/handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine=(engine) ⇒ Object



24
25
26
# File 'lib/norikra/webui/handler.rb', line 24

def self.engine=(engine)
  @@engine = engine
end

Instance Method Details

#engineObject



57
# File 'lib/norikra/webui/handler.rb', line 57

def engine; @@engine; end

#loggerObject



22
# File 'lib/norikra/webui/handler.rb', line 22

def logger ; Norikra::Log.logger ; end

#logging(type, handler, args = [], opts = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/norikra/webui/handler.rb', line 28

def logging(type, handler, args=[], opts={})
  if type == :manage
    debug "WebUI", :handler => handler.to_s, :args => args
  else
    trace "WebUI", :handler => handler.to_s, :args => args
  end

  begin
    yield
  rescue Norikra::ClientError => e
    logger.info "WebUI #{e.class}: #{e.message}"
    if opts[:on_error_hook]
      opts[:on_error_hook].call(e.class, e.message)
    else
      halt 400, e.message
    end
  rescue => e
    logger.error "WebUI #{e.class}: #{e.message}"
    e.backtrace.each do |t|
      logger.error "  " + t
    end
    if opts[:on_error_hook]
      opts[:on_error_hook].call(e.class, e.message)
    else
      halt 500, e.message
    end
  end
end

#norikra_versionObject



20
# File 'lib/norikra/webui/handler.rb', line 20

def norikra_version; Norikra::VERSION ; end

#targetsObject



59
60
61
# File 'lib/norikra/webui/handler.rb', line 59

def targets
  engine.targets.map(&:name)
end