Method: MyPKI::Configuration#initialize

Defined in:
lib/mypki/configuration.rb

#initialize(path, **options) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mypki/configuration.rb', line 9

def initialize path, **options
  @options = options
  @path = File.expand_path path
  @loaders = loaders.map{|loader| loader.new options}
  
  if File.exist? @path        
    begin 
      merge! MultiJson.load(File.read(@path))
      @loaders.each {|l| l.load self}
    rescue => ex
      raise "Bad MyPKI configuration (#{ex.message})"
    end
  else      
    retriable on_retry: proc { warn $! } do
      clear 
      create
    end
  end
end