class Configurate::Provider::TOML

This provider tries to open a TOML file and does nested lookups in it.

Constants

PARSER

Public Class Methods

new(file, namespace: nil, required: true, raise_on_missing: false) click to toggle source

@param file [String] the path to the file @param namespace [String] optionally set this as the root @param required [Boolean] whether or not to raise an error if

the file or the namespace, if given, is not found. Defaults to +true+.

@param raise_on_missing [Boolean] whether to raise {Configurate::MissingSetting}

if a setting can't be provided. Defaults to +false+.

@raise [ArgumentError] if the namespace isn’t found in the file @raise [Errno:ENOENT] if the file isn’t found

Calls superclass method Configurate::Provider::StringHash::new
# File lib/configurate/provider/toml.rb, line 26
def initialize file, namespace: nil, required: true, raise_on_missing: false
  super(PARSER.load_file(file),
    namespace:        namespace,
    required:         required,
    raise_on_missing: raise_on_missing,
    source:           file
  )
rescue Errno::ENOENT => e
  warn "WARNING: Configuration file #{file} not found, ensure it's present"
  raise e if required
end