Class: Jerakia

Inherits:
Object
  • Object
show all
Defined in:
lib/jerakia.rb,
lib/jerakia/cli.rb,
lib/jerakia/util.rb,
lib/jerakia/error.rb,
lib/jerakia/answer.rb,
lib/jerakia/policy.rb,
lib/jerakia/server.rb,
lib/jerakia/request.rb,
lib/jerakia/version.rb,
lib/jerakia/launcher.rb,
lib/jerakia/cli/token.rb,
lib/jerakia/cli/lookup.rb,
lib/jerakia/cli/server.rb,
lib/jerakia/datasource.rb,
lib/jerakia/dsl/lookup.rb,
lib/jerakia/dsl/policy.rb,
lib/jerakia/server/auth.rb,
lib/jerakia/server/rest.rb,
lib/jerakia/policy/registry.rb,
lib/jerakia/server/auth/token.rb,
lib/jerakia/lookup/plugin_config.rb

Overview

Jerakia::Lookup::PluginConfig

This class is a simple wrapper class to expose configuration options from the global configuration file to lookup plugins. It’s exposed to the lookup as the config method. Eg: config

Direct Known Subclasses

Log, Response

Defined Under Namespace

Modules: Dsl, Util Classes: Answer, CLI, Cache, Config, Datasource, Error, FileParseError, Launcher, Log, Lookup, Policy, PolicyError, Request, Response, Schema, SchemaError, Scope, Server

Constant Summary collapse

VERSION =

Public API to retrieve the latest released version of the code

This should be updated when a new gem is released and it is read from the gemspec file

'1.2.1'.freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Jerakia

Returns a new instance of Jerakia.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jerakia.rb', line 27

def initialize(options = {})
  @options = options

  load_config
  load_log_handler

  if config[:plugindir]
    $LOAD_PATH << config[:plugindir] unless $LOAD_PATH.include?(config[:plugindir])
  end

  log.debug('Jerakia initialized')
  Jerakia.log.verbose("Jerakia started. Version #{Jerakia::VERSION}")
end

Class Attribute Details

.configObject

Returns the value of attribute config.



20
21
22
# File 'lib/jerakia.rb', line 20

def config
  @config
end

.logObject

Returns the value of attribute log.



21
22
23
# File 'lib/jerakia.rb', line 21

def log
  @log
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/jerakia.rb', line 17

def options
  @options
end

Class Method Details

.fatal(msg, e) ⇒ Object



49
50
51
52
53
54
# File 'lib/jerakia.rb', line 49

def self.fatal(msg, e)
  stacktrace = e.backtrace.join("\n")
  Jerakia.log.fatal msg
  Jerakia.log.fatal "Full stacktrace output:\n#{$!}\n\n#{stacktrace}"
  raise e
end

Instance Method Details

#configObject



57
58
59
# File 'lib/jerakia.rb', line 57

def config
  self.class.config
end

#logObject



61
62
63
# File 'lib/jerakia.rb', line 61

def log
  self.class.log
end

#lookup(request) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/jerakia.rb', line 41

def lookup(request)
  lookup_instance = Jerakia::Launcher.new(request)
  lookup_instance.invoke_from_file
  lookup_instance.answer
rescue Jerakia::Error => e
  Jerakia.fatal(e.message, e)
end