File Coverage

inc/My/Module/Recommend.pm
Criterion Covered Total %
statement 12 21 57.1
branch 0 6 0.0
condition n/a
subroutine 4 6 66.6
pod 2 2 100.0
total 18 35 51.4


line stmt bran cond sub pod time code
1             package My::Module::Recommend;
2              
3 1     1   6 use strict;
  1         1  
  1         33  
4 1     1   3 use warnings;
  1         1  
  1         27  
5              
6 1     1   3 use Carp;
  1         1  
  1         71  
7 1     1   391 use My::Module::Recommend::Any qw{ __any };
  1         3  
  1         179  
8              
9             my @optionals = (
10             __any( 'PPIx::Regexp' => <<'EOD' ),
11             This module is needed to find variables inside nested regular
12             expressions.
13             EOD
14             );
15              
16             sub optionals {
17 0     0 1   return ( map { $_->modules() } @optionals );
  0            
18             }
19              
20             sub recommend {
21 0     0 1   my $need_some;
22 0           foreach my $mod ( @optionals ) {
23 0 0         defined( my $msg = $mod->recommend() )
24             or next;
25 0 0         $need_some++
26             or warn <<'EOD';
27              
28             The following optional modules were not available:
29             EOD
30 0           warn "\n$msg";
31             }
32             $need_some
33 0 0         and warn <<'EOD';
34              
35             It is not necessary to install these now. If you decide to install them
36             later, this software will make use of them when it finds them.
37              
38             EOD
39              
40 0           return;
41             }
42              
43             1;
44              
45             =head1 NAME
46              
47             My::Module::Recommend - Recommend modules to install.
48              
49             =head1 SYNOPSIS
50              
51             use lib qw{ inc };
52             use My::Module::Recommend;
53             My::Module::Recommend->recommend();
54              
55             =head1 DETAILS
56              
57             This package generates the recommendations for optional modules. It is
58             intended to be called by the build system. The build system's own
59             mechanism is not used because we find its output on the Draconian side.
60              
61             =head1 METHODS
62              
63             This class supports the following public methods:
64              
65             =head2 optionals
66              
67             say for My::Module::Recommend->optionals();
68              
69             This static method simply returns the names of the optional modules.
70              
71             =head2 recommend
72              
73             My::Module::Recommend->recommend();
74              
75             This static method examines the current Perl to see which optional
76             modules are installed. If any are not installed, a message is printed to
77             standard error explaining the benefits to be gained from installing the
78             module, and any possible problems with installing it.
79              
80             =head1 SUPPORT
81              
82             Support is by the author. Please file bug reports at
83             L or in
84             electronic mail to the author.
85              
86             =head1 AUTHOR
87              
88             Thomas R. Wyant, III F
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             Copyright (C) 2014-2022, 2026 by Thomas R. Wyant, III
93              
94             This program is free software; you can redistribute it and/or modify it
95             under the same terms as Perl 5.10.0. For more details, see the full text
96             of the licenses in the files F and F.
97              
98             This program is distributed in the hope that it will be useful, but
99             without any warranty; without even the implied warranty of
100             merchantability or fitness for a particular purpose.
101              
102             =cut
103              
104             __END__