NAME

Config::YAML::Modern - Modern YAML-based config loader from file or directory.

VERSION

Version 0.25

SYNOPSIS

Config::YAML::Modern created to get dial with yaml-based configuration. Its possible to load single file, or all files in one directory (without recursion search). Data from many files was be merged properly (almost), also filename was be converted to top-level hash keys. Filename like 'file.data.yaml' was be converted to { file => { data => $file_content } }. Also module provide perfect dive() interface form Data::Diver. It may be used like

	my $file_content = $conf_object->dive(qw/file data/);

Simply usage for file load

use Config::YAML::Modern;

my $config = Config::YAML::Modern->new();

my $filename = 'test.yaml';

$config->file_load($filename);

my $data = $config->config();

More complicated for directory-based loading

my $config2 = Config::YAML::Modern->new( key_conversion => 'ucfirst' );

my $directory = '/etc/my_app/';

# slurp all data to hashref
my $data2 = $config2->dir_load($directory)->config();

# but exist more sophisticated path
my @list_of_key = (qw/Model Message 0 author/);
my $data3 = $config2->dive(@list_of_key);

# $data3 == $data2->{Model}{Message}[0]{author}

SUBROUTINES/METHODS

new

new( [ list of args ] ) - create Config::YAML::Modern object and return it.

my $config = Config::YAML::Modern->new();

The options currently supported are:

merge_behavior behavior on merge data, see Hash::Merge docs. 'LEFT_PRECEDENT' by default.
file_suffix File suffix, used in search files in directory for matching. '.yaml' by default.
key_conversion Rule for conversion parts of filename to hash keys. Available [undef, uc, ucfirst, lc, lcfirst]. No conversion 'undef' by default.
i_dont_use_suffix Set to true if you not use suffix on config files. Suffix used by default - 'undef'.
__force_return_data If setted to true, methods: file_load, dir_load, hash_add, file_add and die_add returns dataset instead of $self, returned by default - 'undef'. !!! important - in this case loaded or added data are NOT BE STORED in object, use it well

file_load

file_load($filename) - load data from yaml-contained file

$config->file_load($filename);

config

config() - return all config data from object

my $data = $config->config();

dir_load

dir_load($directory) - get files from directory, load data and merge it together

$config2->dir_load($directory);

dive

dive(@list_of_key) - return data from object by @list_of_key patch resolution

my $data3 = $config2->dive(@list_of_key);

Just wrapper ontop of "DiveDie" in Data::Diver

hash_add

hash_add($hash_ref, $behavior? ) - add data to object from hash with $behavior resolution, or use default behavior.

my $data3 = $config2->hash_add( $hash_ref, 'RIGHT_PRECEDENT' );

Just wrapper ontop of "merge" in Hash::Merge

file_add

file_add($filename, $behavior? ) - add data to object from file with $behavior resolution, or use default behavior.

my $data3 = $config2->file_add( $filename3, 'RIGHT_PRECEDENT' );

dir_add

file_add($dir_name, $behavior? ) - add data to object from directory with $behavior resolution, or use default behavior.

my $data3 = $config2->dir_add( $dir_name2, 'RETAINMENT_PRECEDENT' );

EXPORT

Nothing by default.

AUTHOR

Meettya, <meettya at cpan.org>

BUGS

Please report any bugs or feature requests to bug-config-yaml-modern at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-YAML-Modern. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Config::YAML::Modern

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Meettya.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.