NAME

    CTK - CTK ToolKit library (CTKlib)

VERSION

    Version 2.09

NOTE

    The 2.00+ versions of this library is not compatible with earlier
    versions

SYNOPSIS

        use CTK;
    
        my $ctk = CTK->new;
        my $ctk = CTK->new (
            project => 'MyApp',
            configfile  => '/path/to/conf/file.conf',
            logfile     => '/path/to/log/file.log',
        );

DESCRIPTION

    CTKlib - is library that provides "extended-features" (utilities) for
    your robots written on Perl. Most of the functions and methods this
    module written very simple language and easy to understand. To work
    with CTKlib, you just need to start using it!

 new

        my $ctk = CTK->new;
        my $ctk = CTK->new (
            project    => 'MyApp',
            configfile => '/path/to/conf/file.conf',
            logfile    => '/path/to/log/file.log',
        );

    Main constructor. All the params are optional

    configfile

          configfile => '/etc/myapp/myapp.conf'

      Path to the configuration file of the your project

      Default: /etc/<PREFIX>/<PREFIX>.conf

    datadir

          datadir => '/path/to/your/data/dir'

      Directory for application data storing

      Default: <getcwd()> (current directory)

    debug

          debug => 1
          debug => 'on'
          debug => 'yes'

      Debug mode

      Default: 0

    ident

          ident => "test"

      Ident string for logs and debugging

      Default: ""

    log

          log => 1
          log => 'on'
          log => 'yes'

      Log mode

      Default: 0

    logdir

          logdir => '/var/log/myapp'

      Log directory of project

      Default: /var/log/<PREFIX>

    logfile

          logfile => '/var/log/myapp/myapp.log'

      Full path to the log file

      Default: /var/log/<PREFIX>/<PREFIX>.log

    options

          options => {foo => 'bar'}

      Command-line options, hash-ref structure. See Getopt::Long

      Default: {}

    plugins

          plugins => [qw/ test /]
          plugins => "test"

      Array ref of plugin list or plugin name as scalar:

      Default: []

    prefix

          prefix => "myapp"

      Prefix of the Your project

      Default: lc(<PROJECT>)

    project

          project => "MyApp"
          name => "MyApp"

      Project name

      Default: $FindBin::Script without file extension

    root

          root => "/etc/myapp"

      Root dir of project

      Default: /etc/<PREFIX>

    suffix

          suffix => "devel"
          suffix => "alpha"
          suffix => "beta"
          suffix => ".dev"

      Suffix of the your project. Can use in plugins

      Default: ""

    tempdir

          tempdir => "/tmp/myapp"

      Temp directory of project

      Default: /tmp/<PREFIX>

    tempfile

          tempfile => "/tmp/myapp/myapp.tmp"

      Temp file of project

      Default: /tmp/<PREFIX>/<PREFIX>.tmp

    test

          test => 1
          test => 'on'
          test => 'yes'

      Test mode

      Default: 0

    verbose

          verbose => 1
          verbose => 'on'
          verbose => 'yes'

      Verbose mode

      Default: 0

 again

    For internal use only (plugins). Please not call this method

 configfile

        my $configfile = $ctk->configfile;
        $ctk->configfile("/path/to/config/file.conf");

    Gets and sets configfile value

 datadir

        my $datadir = $ctk->datadir;
        $ctk->datadir("/path/to/data/dir");

    Gets and sets datadir value

 debug

        $ctk->debug( "Message" );

    Prints debug information on STDOUT if is set debug mode. Also sends
    message to log if log mode is enabled

 debugmode

        $ctk->debugmode;

    Returns debug flag. 1 - on, 0 - off

 error

        my $error = $ctk->error;

    Returns error string if occurred any errors while creating the object

        $ctk->error("error text");

    Sets new error message and returns it. Also prints message on STDERR if
    is set debug mode and sends message to log if log mode is enabled

 exedir

        my $exedir = $ctk->exedir;

    Gets exedir value

 load

        $ctk->load("My::Foo::Package");

    Internal method for loading modules.

    Returns loading status: 0 - was not loaded; 1 - was loaded

 load_plugins

        my $summary_status = $self->load_plugins( @plugins );

    Loads list of plugins and returns summary status

 logdir

        my $logdir = $ctk->logdir;
        $ctk->logdir("/path/to/log/dir");

    Gets and sets logdir value

 logfile

        my $logfile = $ctk->logfile;
        $ctk->logfile("/path/to/log/file.log");

    Gets and sets logfile value

 logmode

        $ctk->logmode;

    Returns log flag. 1 - on, 0 - off

 origin

        my $args = $ctk->origin();

    Returns hash-ref structure to all origin arguments

 option

        my $value = $ctk->option("key");

    Returns option value by key

        my $options = $ctk->option;

    Returns hash-ref structure to all options

    See "options"

 project, prefix, suffix

        my $project_name = $ctk->projtct;
        my $prefix = $ctk->prefix;
        my $suffix = $ctk->suffix;

    Returns project, prefix and suffix values

 revision

        my $revision = $ctk->revision;

    Returns SVN revision number. Please not use it for your projects

 root

        my $my_root = $ctk->root; # /etc/<PREFIX>

    Gets my root dir value

 silentmode

        $ctk->silentmode;

    Returns the verbose flag in the opposite value. 0 - verbose, 1 -
    silent.

    See "verbosemode"

 status

        my $status = $ctk->status;

    Returns boolean status of creating and using the object

        my $status = $ctk->status( 1 );

    Sets new status and just returns it

 tempfile

        my $tempfile = $ctk->tempfile;
        $ctk->tempfile("/path/to/temp/file.tmp");

    Gets and sets tempfile value

 tempdir

        my $tempdir = $ctk->tempdir;
        $ctk->tempdir("/path/to/temp/dir");

    Gets and sets tempdir value

 testmode

        $ctk->testmode;

    Returns test flag. 1 - on, 0 - off

 tms

        print $ctk->tms; # +0.0080 sec

    Returns formatted timestamp

        print $ctk->tms(1); # 0.008000

    Returns NOT formatted timestamp

 verbosemode

        $ctk->verbosemode;

    Returns verbose flag. 1 - on, 0 - off

    See "silentmode"

VARIABLES

        use CTK qw/ WIN NULL TONULL ERR2OUT PREFIX /;
        use CTK qw/ :constants /

    ERR2OUT

      Returns string:

          2>&1

    NULL

      Returns NULL device path or name for Windows platforms

    %PLUGIN_ALIAS_MAP

      This hash is using for sets aliases of plugins, e.g.:

          use CTK qw/ %PLUGIN_ALIAS_MAP /;
          $PLUGIN_ALIAS_MAP{myplugin} = "My::Custom::Plugin::Module";

    PREFIX

      Return default prefix: ctk

    TONULL

      Returns string:

          >/dev/null 2>&1

    WIN

      Returns 1 if Windows platform

TAGS

    :constants

      Will be exported following variables:

          WIN, NULL, TONULL, ERR2OUT, PREFIX

    :variables

      Will be exported following variables:

          %PLUGIN_ALIAS_MAP

HISTORY

    1.00 / 18.06.2012

      Init version

    2.00 Mon Apr 29 10:36:06 MSK 2019

      New edition of the library

    See Changes file

DEPENDENCIES

    Config::General, JSON, JSON::XS, List::Util, MIME::Lite, Perl::OSType,
    Sys::Syslog, Term::ANSIColor, Text::SimpleTable, Time::Local,
    Try::Tiny, URI, XML::Simple, YAML, YAML::XS

TO DO

    See TODO file

BUGS

    * none noted

SEE ALSO

    perl

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

