The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

     PkgForge::ConfigFile - A configuration file class for the LCFG Package Forge

VERSION

     This documentation refers to PkgForge::ConfigFile version 1.4.8

SYNOPSIS

     This is a Moose role and cannot be instantiated directly. Use it
     as shown below:

     package PkgForge::Foo;
     use Moose;

     with 'PkgForge::ConfigFile';

     # optionally, default the configfile:
     has '+configfile' => ( default => '/etc/foo.yaml' );

     ########
     ## A script that uses the class with a configfile
     ########

     my $obj = PkgForge::Foo->new_with_config(configfile => '/etc/bar.yaml',
                                              other_opt  => 'foo');

DESCRIPTION

This is a Moose role which can be applied to a class to give it the ability to set values of attributes for new instances from configuration files. The configuration file format must be YAML, multiple files can be supplied which will be loaded in sequence.

ATTRIBUTES

configfile

This attribute is provided by the base role MooseX::ConfigFromFile. You can provide a default configfile pathname like so:

         has '+configfile' => ( default => '/etc/myapp.yaml' );

You can also provide a list of files (wrapped in a sub to satisfy Moose) as a default. Given a list of files the values of attributes will come from the latest (right-most) file in which the attribute is specified. The configuration format is YAML, in most cases all that is required are simple key-value pairs separated with a colon, one per-line, for example bucket: lcfg, see YAML::Syck for more information.

SUBROUTINES/METHODS

Class Methods

get_config_from_file

This is used internally by either new_with_config or the new_with_options method provided in the MooseX::Getopt role. This uses YAML::Syck to parse the configuration files.

new_with_config

This is provided by the base role MooseX::ConfigFromFile. This acts just like a regular new(), but it also accepts an argument configfile to specify the configuration file from which to load other attributes. Explicit arguments to this method will override anything loaded from the configfile. You may also pass in a string which is the filename for the configuration file but with a plus-sign (+) prefix. This file name will then be appended to the list which comes from the default for the attribute (if any).

DEPENDENCIES

This module is powered by Moose and also uses MooseX::ConfigFromFile and YAML::Syck

SEE ALSO

PkgForge

PLATFORMS

This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

ScientificLinux5, Fedora13

BUGS AND LIMITATIONS

Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.

AUTHOR

    Stephen Quinney <squinney@inf.ed.ac.uk>

LICENSE AND COPYRIGHT

    Copyright (C) 2010-2011 University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.