Class: Jerakia::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jerakia/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
# File 'lib/jerakia/config.rb', line 11

def initialize(config = {})
  config_with_defaults = defaults.merge(config)
  @policydir = config_with_defaults['policydir']
  @server_url = config_with_defaults['server_url']
  @configdata = config_with_defaults
end

Instance Attribute Details

#policydirObject (readonly)

Returns the value of attribute policydir.



4
5
6
# File 'lib/jerakia/config.rb', line 4

def policydir
  @policydir
end

#server_urlObject (readonly)

Returns the value of attribute server_url.



5
6
7
# File 'lib/jerakia/config.rb', line 5

def server_url
  @server_url
end

Class Method Details

.load_from_file(file = '/etc/jerakia/jerakia.yaml') ⇒ Object



7
8
9
# File 'lib/jerakia/config.rb', line 7

def self.load_from_file(file = '/etc/jerakia/jerakia.yaml')
  new YAML.load_file(file)
end

Instance Method Details

#[](key) ⇒ Object



27
28
29
# File 'lib/jerakia/config.rb', line 27

def [](key)
  @configdata[key.to_s]
end

#defaultsObject



18
19
20
21
22
23
24
25
# File 'lib/jerakia/config.rb', line 18

def defaults
  {
    'policydir'     => '/etc/jerakia/policy.d',
    'logfile'       => '/var/log/jerakia.log',
    'loglevel'      => 'info',
    'enable_schema' => true,
  }
end