File Coverage

inc/My/Module/Recommend.pm
Criterion Covered Total %
statement 15 25 60.0
branch 0 6 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 22 40 55.0


line stmt bran cond sub pod time code
1             package My::Module::Recommend;
2              
3 1     1   7 use strict;
  1         2  
  1         44  
4 1     1   14 use warnings;
  1         3  
  1         101  
5              
6 1     1   9 use Carp;
  1         1  
  1         71  
7 1     1   7 use Config;
  1         1  
  1         49  
8              
9 1     1   552 use My::Module::Recommend::Any qw{ __any };
  1         3  
  1         456  
10              
11             my ( $is_5_010, $is_5_012 );
12              
13             if ( $] ge '5.012' ) {
14             $is_5_012 = $is_5_010 = 1;
15             } elsif ( $] ge '5.010' ) {
16             $is_5_010 = 1;
17             };
18              
19             my %misbehaving_os = map { $_ => 1 } qw{ MSWin32 cygwin };
20              
21             my @optionals = (
22             __any( 'Config::Identity' => <<'EOD' ),
23             This module is used to parse the user's identity file, which
24             provides default attribute values, and which can be encrypted with
25             gpg2. If you do not intend to make use of the identity file,
26             Config::Identity is not needed.
27             EOD
28             __any( 'Browser::Open' => <<'EOD' ),
29             This module is being phased in as the only supported way to
30             display web-based help. If you intend to leave the 'webcmd'
31             attribute false, this module is not needed.
32             EOD
33             __any( 'Time::HiRes' => <<'EOD' ),
34             This module is used for more precise throttling of Space Track
35             requests. The code will work without it, but the less precise
36             timing may result in retrieval failures.
37             EOD
38             );
39              
40             my %core = map { $_ => 1 } qw{ Time::HiRes };
41              
42             sub optionals {
43             # As of Test::Builder 1.302190 (March 2 2022) Time::HiRes is needed
44             # by Test::Builder, which is used by Test::More. It's a core module,
45             # so it OUGHT to be available, though there are known downstream
46             # packagers who strip core modules. Sigh. This is the reason I'm
47             # stripping it here rather than removing it completely.
48 0     0 1   return ( grep { ! $core{$_} } map { $_->modules() } @optionals );
  0            
  0            
49             }
50              
51             sub recommend {
52 0     0 1   my $need_some;
53 0           foreach my $mod ( @optionals ) {
54 0 0         defined( my $msg = $mod->recommend() )
55             or next;
56 0 0         $need_some++
57             or warn <<'EOD';
58              
59             The following optional modules were not available:
60             EOD
61 0           warn "\n$msg";
62             }
63             $need_some
64 0 0         and warn <<'EOD';
65              
66             It is not necessary to install these now. If you decide to install them
67             later, this software will make use of them when it finds them.
68              
69             EOD
70              
71 0           return;
72             }
73              
74             1;
75              
76             __END__