Method: Evertils::Router#pre_exec

Defined in:
lib/evertils/router.rb

#pre_execObject

Prepare for routing



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/evertils/router.rb', line 11

def pre_exec
  @request = Request.new

  begin
    update_config if uses_local_configuration?

    require "evertils/controllers/#{@request.controller}" unless uses_local_configuration?

    # perform all required checks
    must_pass = Helper::Results.new
    @config.get(:required).each do |key, _|
      must_pass.add(send("verify_#{key}"))
    end

    raise RequiredCheckException unless must_pass.should_eval_to(true)
  rescue YubikeyException
    Notify.error('Check failed: Yubikey is not inserted')
  rescue GpgException
    Notify.error('Check failed: GPG key not found or not imported into your keychain')
  rescue RequiredCheckException
    Notify.error('One or more required checks failed')
  rescue LoadError => e
    Notify.error(e || "Controller not found: #{@request.controller}")
  end
end