Perl::PrereqScanner::NotQuiteLite::Context(3pm) | User Contributed Perl Documentation | Perl::PrereqScanner::NotQuiteLite::Context(3pm) |
Perl::PrereqScanner::NotQuiteLite::Context
This is typically used to keep callbacks, an eval state, and found prerequisites for a processing file.
$c->add($module); $c->add($module => $minimum_version);
adds a module with/without a minimum version as a requirement or a suggestion, depending on the eval state. You can add a module with different versions as many times as you wish. The actual minimum version for the module is calculated inside (by CPAN::Meta::Requirements).
$c->register_keyword_parser( 'func_name', [$parser_class, 'parser_for_the_func', $used_module], ); $c->remove_keyword_parser('func_name'); $c->register_method_parser( 'method_name', [$parser_class, 'parser_for_the_method', $used_module], );
If you find a module that can export a loader function is actually "use"d (such as Moose that can export an "extends" function that will load a module internally), you might also register the loader function as a custom keyword dynamically so that the scanner can also run a callback for the function to parse its argument tokens.
You can also remove the keyword when you find the module is "no"ed (and when the module supports "unimport").
You can also register a method callback on the fly (but you can't remove it).
If you always want to check some functions/methods when you load a plugin, just register them using a "register" method in the plugin.
returns a CPAN::Meta::Requirements object for requirements.
returns a CPAN::Meta::Requirements object for suggestions (requirements in "eval"s), or undef when it is not expected to parse tokens in "eval".
creates an instance. You usually don't need to call this because it's automatically created in the scanner.
next unless $c->has_callbacks('use'); next unless $c->has_callbacks_for('use', 'base'); $c->run_callbacks_for('use', 'base', $tokens);
"has_callbacks" returns true if a callback for "use", "no", "keyword", or "method" is registered. "has_callbacks_for" returns true if a callback for the module/keyword/method is registered. "run_callbacks_for" is to run the callback.
returns true if a module has already been added as a requirement or a suggestion. Only useful for the ::UniversalVersion plugin.
Kenichi Ishigaki, <ishigaki@cpan.org>
This software is copyright (c) 2015 by Kenichi Ishigaki.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2020-10-21 | perl v5.30.3 |