NAME
Module::FeaturesUtil::Get - Get a feature from a module (following Module::Features specification)
VERSION
This document describes version 0.006 of Module::FeaturesUtil::Get (from Perl distribution Module-FeaturesUtil-Get), released on 2023-11-11.
SYNOPSIS
use Module::FeaturesUtil::Get qw(
get_features_decl
get_feature_val
get_feature_defhash
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.
get_feature_defhash
Usage:
my $defhash = get_feature_defhash($module_name, $feature_set_name, $feature_name);
Example:
$defhash = get_feature_defhash('Text::Table::Sprintf', 'TextTable', 'can_halign'; # => {value=>1, summary=>'Only support l (left) and r (right), not c (center)'}
Get a single feature declaration defhash.
Features declaration is retrieved using "get_features_decl".
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.
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>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2023, 2021 by perlancar <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.
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.