NAME
Crane::Config - Configuration manager
SYNOPSIS
use Crane::Config;
my $filename = config->{'log'}->{'filename'};
DESCRIPTION
Configuration manager which operates with YAML configurations. Settings are available as a hash reference returned by config function.
You can specify default configuration and filename by passing it to config function when first call (see description below).
EXPORTED FUNCTIONS
- config ($config, @filenames)
-
Returns link to current configuration.
At first call you can specify default configuration $config and/or list of config file names @filenames.
FUNCTIONS
- merge_config ($original, $config)
-
Merge two configs ($config to $original).
- read_config ($filename)
-
Reads confugration from file named $filename.
- write_config ($config, $filename)
-
Saves configuration $config to file named $filename.
- load_config ($config, @filenames)
-
Load configurations from files named @filenames and merges them to configuration $config and default configuration.
ERRORS
- Incorrect syntax in '%s': %s
-
Where %s is file name and %s is error message.
Invalid YAML configuration file.
- Unable to read config '%s': %s
-
Where %s is file name and %s is error message.
Fires when unable to open configuration for read.
- Unable to write config '%s': %s
-
Where %s is file name and %s is error message.
Fires when unable to open configuration for write.
- YAML error while writing '%s': %s
-
Where %s is file name and %s is error message.
- Configuration should be a hash reference
-
Fires when function required hash reference as a configuration.
- No filename given
-
Fires when function required name of file but it is undefined.
EXAMPLES
Configuration file
domain: "production"
log:
level: 0
filename: "/var/log/example/messages.log"
error_filename: "/var/log/example/errors.log"
servers:
- "127.0.0.1:3001"
- "127.0.0.1:3002"
Which results to hash reference:
{
'domain' => 'production',
'log' => {
'level' => '0',
'filename' => '/var/log/example/messages.log',
'error_filename' => '/var/log/example/errors.log',
},
'servers' => [
'127.0.0.1:3001',
'127.0.0.1:3002',
],
}
ENVIRONMENT
See Crane::Base.
FILES
BUGS
Please report any bugs or feature requests to https://rt.cpan.org/Public/Bug/Report.html?Queue=Crane or to https://github.com/temoon/crane/issues.
AUTHOR
Tema Novikov, <novikov.tema@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2013-2014 Tema Novikov.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.
SEE ALSO
RT Cpan
Github
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 210:
You forgot a '=back' before '=head1'