Name
Class::Usul - A base class providing config, locking, logging, and l10n
Version
Describes Class::Usul version v0.54.$Rev: 1 $
Synopsis
use Class::Usul;
use Class::Usul::Constants qw( FALSE );
use Class::Usul::Functions qw( find_apphome get_cfgfiles );
my $attr = { config => {}, debug => $ENV{DEBUG} // FALSE };
my $conf = $attr->{config};
$conf->{appclass } or die "Application class not specified";
$attr->{config_class} //= $conf->{appclass}.'::Config';
$conf->{home } = find_apphome $conf->{appclass};
$conf->{cfgfiles } = get_cfgfiles $conf->{appclass}, $conf->{home};
return Class::Usul->new( $attr );
Description
These modules provide a set of base classes for Perl modules and applications. It provides configuration file loading Class::Usul::Config, locking to single thread processes IPC::SRLock, logging Class::Usul::Log and localisation Class::Usul::L10N
The class Class::Usul::Programs is a base class for command line interfaces
Interprocess communication is handled by Class::Usul::IPC
Class::Usul::File makes the functionality of File::DataClass available
Configuration and Environment
Defines the following attributes;
- config
-
The
config
attribute should be a hash reference that may define key / value pairs that provide filesystem paths for the temporary directory etc. - config_class
-
Defaults to Class::Usul::Config and is of type
LoadableClass
. An instance of this class is loaded and instantiated using the hash reference in theconfig
attribute. It provides accessor methods with symbol inflation and smart defaults. Add configuration attributes by subclassing this class - debug
-
Defaults to false
- encoding
-
Decode input and encode output. Defaults to
$self->config->encoding
which defaults to toUTF-8
- l10n
-
An instance of Class::Usul::L10N
- lock
-
An instance of IPC::SRLock
- log
-
An instance of Class::Usul::Log
Subroutines/Methods
dumper
$self->dumper( $some_var );
Use Data::Printer to dump arguments for development purposes
Diagnostics
Setting the debug attribute to true causes messages to be logged at the debug level
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Author
Peter Flanigan, <pjfl@cpan.org>
Acknowledgements
Larry Wall - For the Perl programming language
License and Copyright
Copyright (c) 2015 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