| 1 | package Module::Install::CheckOptional; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use 5.005; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | # For module install and version checks | ||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Module::AutoInstall; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars qw( @ISA $VERSION ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Module::Install::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | @ISA = qw( Module::Install::Base Module::AutoInstall ); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | $VERSION = sprintf "%d.%02d%02d", q/0.11.5/ =~ /(\d+)/g; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub check_optional { | ||||||||||||||||||||||||||
|
Subroutine
check_optional: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 4 | my ($self, $module, $version, $message) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Tell Module::Install to include this, since we use it. | ||||||||||||||||||||||||||||
| 23 | 4 | $self->perl_version('5.005'); | |||||||||||||||||||||||||||
| 24 | 4 | $self->include('Module::AutoInstall', 0); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | croak "check_optional requires a dependency and version such as \"Carp => 1.03\"" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $module and defined $version
MC/DC0%0/2
defined $module and defined $version
defined $module
defined $version
Truth table33%1/3
A and B
A= defined $moduleB= defined $version
| |||||||||||||||||||||||||||||
| 27 | unless defined $module and defined $version; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | return if Module::AutoInstall::_version_cmp( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | Module::AutoInstall::_load($module), $version ) >= 0; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 3 | print<<EOF; | |||||||||||||||||||||||||||
| 33 | *************************************************************************** | ||||||||||||||||||||||||||||
| 34 | NOTE: The optional module $module (version $version) is not installed. | ||||||||||||||||||||||||||||
| 35 | EOF | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 3 | ▶ | print "\n$message" if defined $message; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | 1; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 NAME | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Module::Install::CheckOptional - A Module::Install extension that checks to see if an optional dependency is satisfied | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | In Makefile.PL: | ||||||||||||||||||||||||||||
| 52 | use inc::Module::Install; | ||||||||||||||||||||||||||||
| 53 | ... | ||||||||||||||||||||||||||||
| 54 | check_optional( Carp => 1.02, | ||||||||||||||||||||||||||||
| 55 | "This module will perform better error reporting with Carp installed."); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | This is a Module::Install extension that checks that a suitable version of a module is installed, printing a message if it is not. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 METHODS | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =over 4 | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =item check_optional( E<lt>MODULE NAMEE<gt> => E<lt>0|VERSIONE<gt>, [MESSAGE] ) | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Checks whether a module is installed or not and that it has the correct | ||||||||||||||||||||||||||||
| 70 | version. Prints a note similar to the following if the module with a version | ||||||||||||||||||||||||||||
| 71 | greater than or equal to the specified version cannot be found: | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | *************************************************************************** | ||||||||||||||||||||||||||||
| 74 | NOTE: The optional module Carp (version 1.03) is not installed. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | In addition, the optional MESSAGE argument will be appended to the notice. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =back | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | This code is distributed under the GNU General Public License (GPL) Version 2. | ||||||||||||||||||||||||||||
| 86 | See the file LICENSE in the distribution for details. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | David Coppit E<lt>david@coppit.orgE<gt> | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | L<Module::Install> | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||