logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

CPAN::Requirements::Dynamic - Dynamic prerequisites in meta files

Author

       Leon Timmermans <fawaka@gmail.com>

Description

       This module implements a format for describing dynamic prerequisites of a distribution.

Methods

new(%options)
       This constructor takes two (optional but recommended) named arguments

       •   config

           This is an ExtUtils::Config (compatible) object for reading configuration.

       •   pureperl_only

           This should be the value of the "pureperl-only" flag.

   evaluate(%options)
       This takes a hash with two named arguments: "version" and "expressions". The former is the version of the
       format, it currently defaults to 1. The latter is a list of hashes that can contain the following keys:

       •   condition

           The  condition  of  the dynamic requirement. This is an array with a name as first values and zero or
           more arguments following it. The semantics are described below under "Conditions"

       •   prereqs

           The prereqs is a hash with modules for keys and the required  version  as  values  (e.g.  "{  Foo  =>
           '1.234' }").

       •   phase

           The  phase  of  the  requirements. This defaults to 'runtime'. Other valid values include 'build' and
           'test'.

       •   relation

           The relation of the requirements. This  defaults  to  'requires',  but  other  valid  values  include
           'recommends', 'suggests' and 'conflicts'.

       •   error

           It  will  die  with this error if set. The two messages "No support for OS" and "OS unsupported" have
           special meaning to CPAN Testers and are generally encouraged  for  situations  that  indicate  not  a
           failed build but an impossibility to build.

       "condition" and one of "prereqs" or "error" are mandatory.

   evaluate_file($filename)
       This takes a filename, that can be either a YAML file or a JSON file, and evaluates it.

   Conditionscan_run($command)

       Returns true if a $command can be run.

       config_defined($variable)

       This returns true if a specific configuration variable is defined.

       has_env($variable)

       This returns true if the environmental variable with the name in $variable is true.

       has_perl($version)

       Returns true if the perl version satisfies $version. $version is interpreted exactly as in the CPAN::Meta
       spec (e.g. 1.2 equals '>= 1.2').

       is_extended

       Returns true if extended testing is asked for.

       is_os(@systems)

       Returns true if the OS name equals any of @systems.

       is_os_type($type)

       Returns true if the OS type equals $type. Typical values of $type are 'Unix' or 'Windows'.

       is_smoker

       Returns true when running on a smoker.

       has_env

       This returns true if the given environmental variable is true.

       want_xs

       This returns true if a compiler appears to be available, and the "pureperl_only" option has not been set.

       not

       This takes an expression and negates its value.

       or

       This  takes  list of arrayrefs, each containing a condition expression. If at least one of the conditions
       is true this will also return true.

       and

       This takes a list of arrayrefs, each containing a condition expression. If all of the conditions are true
       this will also return true.

Name

       CPAN::Requirements::Dynamic - Dynamic prerequisites in meta files

Synopsis

        my $result = $dynamic->evaluate({
          expressions => [
            {
              condition => [ 'has_perl' => 'v5.20.0' ],
              prereqs => { Bar => "1.3" },
            },
            {
              condition => [ is_os => 'linux' ],
              prereqs => { Baz => "1.4" },
            },
            {
              condition => [ config_defined => 'usethreads' ],
              prereqs => { Quz => "1.5" },
            },
            {
              condition => [ and =>
                [ config_defined => 'usethreads' ],
                [ is_os => 'openbsd' ],
              ],
              prereqs => { Euz => "1.7" },
            },
            {
              condition => [ not => is_os_type => 'Unix'],
              error => 'OS unsupported',
            },
          ],
        });

Version

       version 0.002

See Also