The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Perl::PrereqScanner::NotQuiteLite::Context

DESCRIPTION

This is typically used to keep callbacks, an eval state, and found prerequisites for a processing file.

METHODS

add

  $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).

register_keyword_parser, remove_keyword_parser, register_method_parser, register_sub_parser

  $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 used (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 noed (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.

requires

returns a CPAN::Meta::Requirements object for requirements.

suggests

returns a CPAN::Meta::Requirements object for suggestions (requirements in evals), or undef when it is not expected to parse tokens in eval.

METHODS MOSTLY FOR INTERNAL USE

new

creates an instance. You usually don't need to call this because it's automatically created in the scanner.

has_callbacks, has_callback_for, run_callback_for

  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.

has_added

returns true if a module has already been added as a requirement or a suggestion. Only useful for the ::UniversalVersion plugin.

AUTHOR

Kenichi Ishigaki, <ishigaki@cpan.org>

COPYRIGHT AND LICENSE

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.