NAME

CPAN::Testers::Common::Client::Config - basic configuration for CPAN Testers clients

WARNING!!!

C:T:C:C:Config is a *very* early module and a *highly* EXPERIMENTAL one for that matter. The API WILL CHANGE. We're still moving stuff around, so please only use it if you understand and accept the consequences.

If you have any questions, please contact the author.

SYNOPSIS

    my $config = CPAN::Testers::Common::Client::Config->new(
        prompt => \&IO::Prompt::Tiny::prompt,
    );

    if ( -e $config->get_config_filename ) {
        $config->read or return;
    }
    else {
        print "CPAN Testers config file not found. Creating...";
        $config->setup;
    }

    ## perform your test logging according to $config's data

    ## send the report!
    my $reporter = Test::Reporter->new(
        from           => $config->email_from,
        transport      => $config->transport_name,
        transport_args => $config->transport_args,
        ...
    );

METHODS

new

Instantiates a new CPAN::Testers::Common::Client::Config object. It may receive the following (optional) parameters:

  • warn => \&my_warn_function

    Inject your own warning function. Defaults to CORE::warn.

  • print => \&my_print_function

    Inject your own printing function. Defaults to sub { print @_ }.

  • prompt => \&my_prompt_function

    Inject your own prompt function. Does not have a default. The function is expected to receive two values: ( $question, $default_value ), and return a scalar containing the answer. Take a look at IO::Prompt::Tiny and ExtUtils::MakeMaker's prompt() functions for suitable candidates.

    If you plan on calling "setup", make sure you pass the 'prompt' argument to new().

read

Reads and parses the existing CPAN Tester's configuration file (usually $HOME/.cpanreporter/config.ini into the main object.

setup

Prompts the user and sets up the CPAN Tester's configuration file (usually $HOME/.cpanreporter/config.ini). This method requires you to have set a proper prompt function when you instantiated the object.

get_config_dir()

The base directory in which your 'config.ini' and other files reside. Defaults to the '.cpanreporter' directory under your home directory (if you're using Linux or OS X) or under the 'my documents' folder (if you're running Windows).

get_config_filename()

Returns the full path for the 'config.ini' file.

CONFIGURATION AND ENVIRONMENT

  • PERL_CPAN_REPORTER_DIR

    Overrides the value for get_config_dir().

  • PERL_CPAN_REPORTER_CONFIG

    Overrides the value for get_config_filename().

Other methos & accessors

This class also provides some semi-public methods and accessors that most likely will move around even more than the others, but that are listed here for completeness sake. You should really not use nor rely on those:

  • edit_report - accessor for the 'edit_report' setting.

  • email_from - accessor for the 'email_from' setting.

  • myprint - accessor for the print function.

  • myprompt - accessor for the prompt function.

  • mywarn - accessor for the warn function.

  • send_duplicates - accessor for the 'send_duplicates' setting.

  • send_report - accessor for the 'send_report' setting.

  • transport - accessor for the 'transport' setting.

  • transport_name - returns the transport name.

  • transport_args - returns the transport arguments.