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         82  
4 1     1   7 use warnings;
  1         1  
  1         48  
5              
6 1     1   5 use Carp;
  1         2  
  1         75  
7 1     1   541 use My::Module::Recommend::Any qw{ __any };
  1         3  
  1         122  
8 1     1   462 use My::Module::Recommend::None qw{ __none };
  1         3  
  1         366  
9              
10             my @optionals = (
11             __any( 'LWP::Protocol::https' => <<'EOD' ),
12             This module is required if you want to use the https: URL scheme
13             to access SIMBAD. If you intend to use only the default http:
14             scheme this module is not needed.
15             EOD
16             __any( 'SOAP::Lite' => <<'EOD' ),
17             This module is required for the query() method. If you do not
18             intend to use this method, SOAP::Lite is not needed.
19             EOD
20             __any( 'XML::DoubleEncodedEntities' => <<'EOD' ),
21             This module is not normally required. But at one point the SIMBAD
22             service was double-encoding XML entities, and anything that has
23             gone wrong once can go wrong again. If you find you need this
24             module you cam install it and it will be used.
25             EOD
26             __any( qw{ XML::Parser XML::Parser::Lite } => <<'EOD' ),
27             One of these module is required to process the results of
28             VO-format queries. If you do not intend to make VO-format queries,
29             they are not needed.
30             EOD
31             __any( 'Time::HiRes' => <<'EOD' ),
32             This module can be used for more accurate control of query delay.
33             EOD
34             __none( YAML => '' ),
35             );
36              
37             my %core = map { $_ => 1 } qw{ Time::HiRes };
38              
39             sub optionals {
40             # As of Test::Builder 1.302190 (March 2 2022) Time::HiRes is needed
41             # by Test::Builder, which is used by Test::More. It's a core module,
42             # so it OUGHT to be available, though there are known downstream
43             # packagers who strip core modules. Sigh. This is the reason I'm
44             # stripping it here rather than removing it completely.
45 0     0 1   return ( grep { ! $core{$_} } map { $_->modules() } @optionals );
  0            
  0            
46             }
47              
48             sub recommend {
49 0     0 1   my $need_some;
50 0           foreach my $mod ( @optionals ) {
51 0 0         defined( my $msg = $mod->recommend() )
52             or next;
53 0 0         $need_some++
54             or warn <<'EOD';
55              
56             The following optional modules were not available:
57             EOD
58 0           warn "\n$msg";
59             }
60             $need_some
61 0 0         and warn <<'EOD';
62              
63             It is not necessary to install these now. If you decide to install them
64             later, this software will make use of them when it finds them.
65              
66             EOD
67              
68 0           return;
69             }
70              
71             1;
72              
73             __END__