Thorium::Conf - Configuration class
version 0.510
Extending:
package Some::App::Conf; use Moose; extends 'Thorium::Conf'; has '+component_name' => ('default' => 'someapp'); has '+component' => ('default' => [ '/file1.yaml', '/file2.yaml' ]); 1;
But you may also use it directly:
use Thorium::Conf; my $conf = Thorium::Conf->new('from' => '/that/app.yaml'); print $conf->data('some.key'); ...
Thorium::Conf is an extendable class for handling configuration data in YAML http://yaml.org format through YAML::XS.
Data is accessed through a string interface that maps directly to the key names of a hash. Data is loaded in the order of (first to last): global, system, component, env_var, from. With each overriding data from the previous, e.g. component's a key would override systems's a key. All data is marked read-only to prevent accidental modification, but there is an interface to control this.
In nearly all cases you should sub-class and override the component_name and component attributes. See the "SYNOPSIS" for an example. component maps to the base file name that will be found in the system location (as set by _system_directory_root). Therefore, if your component name is someapp, then you'd expect the system wide file to reside in /etc/thorium/conf/someapp.yaml.
component_name
component
system
_system_directory_root
someapp
/etc/thorium/conf/thorium.yaml is the universally global file all Thorium::Conf and sub-classed objects read (when it exists).
Thorium::Roles::Logging
_system_directory_root (ro, Str) - Directory root where global files are located. Changing this is not recommended. Defaults to '/etc/thorium/conf'.
component (ro, Maybe[ArrayRef|Str]) - Component specific file(s) to read from. Extended classes should set this.
component_name (ro, Str) - File name base that might be stored in the _system_directory_root. When extending please provide this.
env_var (ro, Maybe[Str]) - Full path to the environmental set file.
env_var_name (ro, Maybe[Str]) - Name of the environment variable. Defaults to 'THORIUM_CONF_FILE'.
from (ro, Maybe[ArrayRef|Str]) - A string or list containing the full path of files to read from.
global (ro, Maybe[Str]) - Global configuration file read by all configuration objects. Defaults to '/etc/thorium/conf/thorium.yaml'.
system (ro, Maybe[Str]) - Full path to the components system wide file.
data([ $key ])
If $key is specified, return that specific data, otherwise return all data.
$key
Note: by default all configuration data is marked read only and can not be changed.
reload()
Re-reads all data from files.
save($filename)
Writes the data to the full file path from $filename.
set($key, $value)
Change $key to $value. $key is the same format as data().
data()
Adam Flott <adam@npjh.com>
This software is copyright (c) 2011 by Adam Flott <adam@npjh.com>, CIDC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Thorium, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thorium
CPAN shell
perl -MCPAN -e shell install Thorium
For more information on module installation, please visit the detailed CPAN module installation guide.