|
NAMECPAN::Requirements::Dynamic - Dynamic prerequisites in meta files VERSIONversion 0.002 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',
},
],
});
DESCRIPTIONThis module implements a format for describing dynamic prerequisites of a distribution. METHODSnew(%options)This constructor takes two (optional but recommended) named arguments
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" 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. AUTHORLeon Timmermans <fawaka@gmail.com> COPYRIGHT AND LICENSEThis software is copyright (c) 2023 by Leon Timmermans. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|