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

CTK::Configuration - Configuration of CTK

VERSION

Version 1.01

SYNOPSIS

    use CTK::Configuration;

    my $config = CTK::Configuration->new(
            config  => "foo.conf",
            confdir => "conf",
            options => {... Config::General options ...},
        );

DESCRIPTION

The module works with the configuration

new

    my $config = CTK::Configuration->new(
            config  => "/path/to/config/file.conf",
            confdir => "/path/to/config/directory",
            options => {... Config::General options ...},
        );

Example foo.conf file:

    Foo     1
    Bar     test
    Flag    true

Example of the "conf" structure of $config object:

    print Dumper($config->{conf});
    $VAR1 = {
        'foo' => 1
        'bar' => 'test',
        'flag' => 1,
    }
config
    config => "/etc/myapp/myapp.conf"

Specifies absolute or relative path to config-file.

confdir, dir
    confdir => "/etc"

Specifies absolute or relative path to config-dir.

no_autoload
    no_autoload => 1

Disables auto loading configuration files. Default: false (loading is enabled)

options
    options => { ... }

Options of Config::General

METHODS

error
    my $error = $config->error;

Returns error string if occurred any errors while creating the object or reading the configuration file

conf
    my $value = $config->conf( 'key' );

Gets value from config structure by key

    my $config_hash = $config->conf;

Returns config hash structure

get
    my $value = $config->get( 'key' );

Gets value from config structure by key

getall
    my $config_hash = $config->getall;

Returns config hash structure

load
    my $config = $config->load;

Loading config files

reload
    my $config = $config->reload;

Reloading config files. All the previous config options will be flushes

set
    $config->set( 'key', 'value' );

Sets value to config structure by key. Returns setted value

status
    print $config->error unless $config->status;

Returns boolean status of loading config file

HISTORY

1.00 Mon Apr 29 10:36:06 MSK 2019

Init version

See Changes file

DEPENDENCIES

Config::General, Try::Tiny

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

Config::General

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/