NAME
Module::FeaturesUtil::Get - Get a feature from a module (following Module::Features specification)
VERSION
This document describes version 0.005 of Module::FeaturesUtil::Get (from Perl distribution Module-FeaturesUtil-Get), released on 2021-07-31.
SYNOPSIS
use Module::FeaturesUtil::Get qw(
get_features_decl
get_feature_val
module_declares_feature
);
# Get features declaration:
my $features_decl = get_features_decl('Text::Table::Tiny');
# Get value of a feature:
if (!get_feature_val('Text::Table::Tiny', 'TextTable', 'align_cell_containing_color_codes')) {
# strip color codes first
for ($str1, $str2) { s/\e\[[0-9;]+m/sg }
}
push @rows, [$str1, $str2];
# Check whether a module declares a feature:
if (module_declares_feature('Text::Table::Tiny', 'TextTable', 'speed')) {
...
}
DESCRIPTION
See "GLOSSARY" in Module::Features for terminology.
FUNCTIONS
get_feature_set_spec
Usage:
my $feature_set_spec = get_feature_set_spec($feature_set_name);
Feature set specification will be retrieved from the Module::Features::$feature_set_name
module. The module will NOT be loaded by this routine; you will need to load the module yourself.
This module will also NOT check the validity of feature set specification.
get_features_decl
Usage:
my $features_decl = get_features_decl($module_name);
Features declaration is first looked up from proxy module's %FEATURES
package variable, then from the module's %FEATURES
. Proxy module is $module_name
::_ModuleFeatures. You have to load the modules yourself; this routine will not load the modules for you.
This routine will also NOT check the validity of features declaration.
get_feature_val
Usage:
my $val = get_feature_val($module_name, $feature_set_name, $feature_name);
Example:
if (!get_feature_val('Text::Table::Tiny', 'TextTable', 'align_cell_containing_color_codes')) {
# strip color codes first
for ($str1, $str2) { s/\e\[[0-9;]+m/sg }
}
push @rows, [$str1, $str2];
Get the value of a feature from a module's features declaration.
Features declaration is retrieved using "get_features_decl".
This routine will also NOT check the validity of feature value against the specification's schema.
module_declares_feature
Usage:
my $bool = module_declares_feature($module_name, $feature_set_name, $feature_name);
Check whether module declares a feature.
Features declaration is retrieved using "get_features_decl".
This routine will also NOT check the feature set specification.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Module-FeaturesUtil-Get.
SOURCE
Source repository is at https://github.com/perlancar/perl-Module-FeaturesUtil-Get.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Module-FeaturesUtil-Get
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
SEE ALSO
This module does not check whether a feature declaration is valid or whether a feature set specification is valid. To do that, use Module::FeaturesUtil::Check's check_features_decl
and check_feature_set_spec
.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.