File Coverage

inc/My/Module/Recommend.pm
Criterion Covered Total %
statement 18 29 62.0
branch 0 6 0.0
condition n/a
subroutine 6 9 66.6
pod 3 3 100.0
total 27 47 57.4


line stmt bran cond sub pod time code
1             package My::Module::Recommend;
2              
3 1     1   5 use strict;
  1         1  
  1         27  
4 1     1   3 use warnings;
  1         6  
  1         27  
5              
6 1     1   3 use Carp;
  1         1  
  1         37  
7 1     1   3 use Config;
  1         1  
  1         28  
8 1     1   357 use My::Module::Recommend::Any qw{ __any };
  1         2  
  1         74  
9 1     1   336 use My::Module::Recommend::All qw{ __all };
  1         1  
  1         330  
10              
11             my %misbehaving_os = map { $_ => 1 } qw{ MSWin32 cygwin };
12              
13             my @optionals = (
14             __any( 'Astro::Coord::ECI::TLE::Iridium' => <<'EOD' ),
15             This module is needed if you wish to compute Iridium Classic flare
16             events. If you do not intend to do this, this module is not
17             needed.
18             EOD
19             __any( 'Astro::SIMBAD::Client' => <<'EOD' ),
20             This module is required for the 'satpass' script's 'sky lookup'
21             command, but is otherwise unused by this package. If you do not
22             intend to use this functionality, this module is not needed.
23             EOD
24             __any( [ 'Astro::SpaceTrack' => 0.052 ] => <<'EOD' ),
25             This module is required for the 'satpass' script's 'st' command,
26             but is otherwise unused by this package. If you do not intend to
27             use this functionality, this module is not needed.
28             EOD
29             __any( 'Date::Manip' => <<'EOD'
30             This module is not required, but the alternative to installing it
31             is to specify times to the 'satpass' script in ISO 8601 format.
32             See 'SPECIFYING TIMES' in the 'satpass' documentation for the
33             details.
34             EOD
35             . ( $] < 5.010 ? <<'EOD' : '' ) ),
36              
37             Unfortunately, the current Date::Manip requires Perl 5.10. Since
38             you are running an earlier Perl, you can try installing Date-Manip
39             5.54, which is the most recent version that does _not_ require
40             Perl 5.10.
41             EOD
42             __any( 'Geo::Coder::OSM' => <<'EOD' ),
43             This module is required for the 'satpass' script's 'geocode'
44             command, but is otherwise unused by this package. If you do not
45             intend to use this functionality, this module is not needed.
46             EOD
47             __any( 'Geo::WebService::Elevation::USGS' => <<'EOD' ),
48             This module is required for the 'satpass' script's 'height'
49             command, but is otherwise unused by this package. If you do not
50             intend to use this functionality, this module is not needed.
51             EOD
52             ( ( $] >= 5.008 && $Config{useperlio} ) ? () :
53             __any( 'IO::String' => <<'EOD' ) ),
54             You appear to have a version of Perl earlier than 5.8, or one
55             which is not configured to use perlio. Under this version of Perl
56             IO::String is required by the 'satpass' script if you wish to pass
57             commands on the command line, or to define macros. If you do not
58             intend to do these things, this module is not needed.
59             EOD
60             __any( 'JSON' => <<'EOD' ),
61             This module is required for Astro::Coord::ECI::TLE to parse
62             orbital data in JSON format. If you do not intend to do this, this
63             module is not needed.
64             EOD
65             ( $] >= 5.012 ? () :
66             __any( 'Time::y2038' => <<'EOD'
67             This module is not required, but if installed allows you to do
68             computations for times outside the usual range of system epoch to
69             system epoch + 0x7FFFFFFF seconds.
70             EOD
71             . ( $misbehaving_os{$^O} ? <<"EOD" : '' )
72              
73             Unfortunately, Time::y2038 has been known to misbehave when
74             running under $^O, so you may be better off just accepting the
75             restricted time range.
76             EOD
77             . ( ( $Config{use64bitint} || $Config{use64bitall} ) ? <<'EOD' : '' ) ) ),
78             and $recommendation .= <<'EOD';
79              
80             Since your Perl appears to support 64-bit integers, you may well
81             not need Time::y2038 to do computations for times outside the
82             so-called 'usual range.' It will be used, though, if it is
83             available.
84             EOD
85             );
86              
87             sub optionals {
88 0     0 1   return ( map { $_->modules() } @optionals );
  0            
89             }
90              
91             sub recommend {
92 0     0 1   my $need_some;
93 0           foreach my $mod ( @optionals ) {
94 0 0         defined( my $msg = $mod->recommend() )
95             or next;
96 0 0         $need_some++
97             or warn <<'EOD';
98              
99             The following optional modules were not available:
100             EOD
101 0           warn "\n$msg";
102             }
103             $need_some
104 0 0         and warn <<'EOD';
105              
106             It is not necessary to install these now. If you decide to install them
107             later, this software will make use of them when it finds them.
108              
109             EOD
110              
111 0           return;
112             }
113              
114             sub test_without {
115 0     0 1   return ( map { $_->test_without() } @optionals );
  0            
116             }
117              
118             1;
119              
120             =head1 NAME
121              
122             My::Module::Recommend - Recommend modules to install.
123              
124             =head1 SYNOPSIS
125              
126             use lib qw{ inc };
127             use My::Module::Recommend;
128             My::Module::Recommend->recommend();
129              
130             =head1 DETAILS
131              
132             This package generates the recommendations for optional modules. It is
133             intended to be called by the build system. The build system's own
134             mechanism is not used because we find its output on the Draconian side.
135              
136             =head1 METHODS
137              
138             This class supports the following public methods:
139              
140             =head2 optionals
141              
142             say for My::Module::Recommend->optionals();
143              
144             This static method simply returns the names of the optional modules.
145              
146             =head2 recommend
147              
148             My::Module::Recommend->recommend();
149              
150             This static method examines the current Perl to see which optional
151             modules are installed. If any are not installed, a message is printed to
152             standard error explaining the benefits to be gained from installing the
153             module, and any possible problems with installing it.
154              
155             =head2 test_without
156              
157             say for My::Module::Recommend->test_without();
158              
159             This static method simply returns the names of the modules to be tested
160             without.
161              
162             =head1 SUPPORT
163              
164             Support is by the author. Please file bug reports at
165             L,
166             L, or in
167             electronic mail to the author.
168              
169             =head1 AUTHOR
170              
171             Thomas R. Wyant, III F
172              
173             =head1 COPYRIGHT AND LICENSE
174              
175             Copyright (C) 2014-2025 by Thomas R. Wyant, III
176              
177             This program is free software; you can redistribute it and/or modify it
178             under the same terms as Perl 5.10.0. For more details, see the full text
179             of the licenses in the directory LICENSES.
180              
181             This program is distributed in the hope that it will be useful, but
182             without any warranty; without even the implied warranty of
183             merchantability or fitness for a particular purpose.
184              
185             =cut
186              
187             __END__