Class::Usul::Config - Configuration class with sensible attribute defaults
use Class::Usul::Constants qw( TRUE ); use Class::Usul::Types qw( ConfigType HashRef LoadableClass ); use Moo; has 'config' => is => 'lazy', isa => ConfigType, builder => sub { $_[ 0 ]->config_class->new( $_[ 0 ]->_config_attr ) }, init_arg => undef; has '_config_attr' => is => 'ro', isa => HashRef, builder => sub { {} }, init_arg => 'config'; has 'config_class' => is => 'ro', isa => LoadableClass, coerce => TRUE, default => 'Class::Usul::Config';
Defines the configuration object. Attributes have sensible defaults that can be overridden by values in configuration files which are loaded on request
Pathnames passed in the "cfgfiles" attribute are loaded and their contents merged with the values passed to the configuration class constructor
Defines the following list of attributes;
appclass
Required string. The classname of the application for which this is the configuration class
appldir
Directory. Defaults to the application's install directory
binsdir
Directory. Defaults to the application's bin directory. Prefers "appldir"/bin but defaults to Configs installsitebin attribute
installsitebin
cfgfiles
An array reference of non empty simple strings. The list of configuration files to load when instantiating an instance of the configuration class. Defaults to an empty list
ctlfile
File in the ctrldir directory that contains this programs control data The default filename is comprised of "name" and "extension"
ctrldir
Directory containing the per program configuration files. Prefers var/etc, then "appldir"/etc defaulting to /usr/local/etc
datadir
Directory containing data files used by the application. Prefers var/data but defaults to "tempdir"
encoding
String default to the constant DEFAULT_ENCODING
DEFAULT_ENCODING
extension
String defaults to the constant CONFIG_EXTN
CONFIG_EXTN
home
Directory containing the config file. Defaults to the constant DEFAULT_CONFHOME
DEFAULT_CONFHOME
l10n_attributes
Hash reference of attributes used to construct a Class::Usul::L10N object. By default contains one key, domains. The filename(s) used to translate messages into different languages
domains
l10n_domains
An array reference which defaults to the constant DEFAULT_L10N_DOMAIN and the applications configuration name. Merged into l10n_attributes as the domains attribute
DEFAULT_L10N_DOMAIN
locale
The locale for language translation of text. Defaults to the constant LANG
LANG
localedir
Directory containing the GNU Gettext portable object files used to translate messages into different languages. Prefers var/locale but defaults to either the first existing directory in the list provided by the LOCALE_DIRS constant or failing that "tempdir"
LOCALE_DIRS
locales
Array reference containing the list of supported locales. The default list contains only the constant LANG
lock_attributes
Hash reference of attributes used to construct an IPC::SRLock object
log_attributes
Hash reference of attributes used to construct a Class::Usul::Log object
logfile
File in the logsdir to which this program will log. Defaults to "name".log
logsdir
Directory containing the application log files. Prefers var/logs but defaults to "tempdir"
name
String. Derived from the "pathname". It is either; the last component of the program name when split on underscores or dashes, or the program name itself if it contains no underscores or dashes
no_thrash
Integer default to 3. Number of seconds to sleep in a polling loop to avoid processor thrash
pathname
File defaults to the absolute path to the PROGRAM_NAME system constant
PROGRAM_NAME
phase
Integer. Phase number indicates the type of install, e.g. 1 live, 2 test, 3 development
prefix
String. Program prefix. Defaults to the last component of the "appclass" lower cased
root
Directory. Path to the web applications document root. Prefers var/root but defaults to "tempdir"
rundir
Directory. Contains a running programs PID file. Prefers var/run but defaults to "tempdir"
salt
String. This applications salt for passwords as set by the administrators . It is used to perturb the encryption methods. Defaults to the "prefix" attribute value
sessdir
Directory. The session directory. Prefers var/session but defaults to "tempdir"
sharedir
Directory containing assets used by the application. Prefers var/share but defaults to "tempdir"
shell
File. The default shell used to create new OS users. Defaults to the environment variable SHELL. If that is not set tries (in order); /bin/ksh, /bin/bash. which 'sh', and finally defaults to /bin/sh. If the selected file does not exist then the type constraint on the attribute will throw
SHELL
suid
File. Name of the setuid root program in the "binsdir" directory. Defaults to "prefix"-admin
tempdir
Directory. It is the location of any temporary files created by the application. Prefers var/tmp but defaults to the File::Spec tempdir
vardir
Directory. Contains all of the non program code directories. Prefers var but defaults to "appldir"
Loads the configuration files if specified in the cfgfiles attribute. Calls "inflate_symbol" and "inflate_path" as required
Inflates the __symbol( relative_path )__ values to their actual runtime values
__symbol( relative_path )__
Calls "inflate_path" for each of the matching values in the hash that was passed as argument
Inflates the __SYMBOL__ values to their actual runtime values
__SYMBOL__
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2016 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install Class::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Usul
CPAN shell
perl -MCPAN -e shell install Class::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.