blib/script/cpandeps

filter: Statementstmt 93.9% 31 / 33 Branchbran 87.5% 14 / 16 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 90.4% 57 / 63 CC 1 SCAR 0.0
CC
1
Cov
91%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/script/cpandeps-diff ↑ Summary blib/lib/CPAN/FindDependencies/Dependency.pm »
1 #!/usr/local/bin/perl
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 my $showversion;
8 my $showhelp;
9 8 ▶if(grep { $_ eq '--showmoduleversions' } @ARGV) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {$_ eq '--showmoduleversions';} @ARGV) { } 4 4 8
elsif (grep {$_ =~ /^(-h|--help)$/;} @ARGV) { } 0 4 4
10 4 $showversion = 1;
11 16 } elsif(grep { $_ =~ /^(-h|--help)$/ } @ARGV) {
12 0 $showhelp = 1;
13 }
14  
15 # can't assume `perldoc` is in the path. Yuck.
16 8 ▶if($showhelp || $ARGV[0] eq 'help') { exec(
Branch: 1 branch
BranchTrueFalseTotal
if ($showhelp or $ARGV[0] eq "help") 1 7 8
Condition66%2/3
$showhelp or $ARGV[0] eq "help"
l!l&&r!l&&!r
017
MC/DC50%1/2
$showhelp or $ARGV[0] eq "help"
$showhelp $ARGV[0] eq "help"
Truth table66%2/3
A or B
A= $showhelpB= $ARGV[0] eq "help"
ABresult
1X1
011
000
17 1 $Config{perlpath}, qw{-MPod::Perldoc -e Pod::Perldoc->run() -- -T}, $0
18 ) }
19  
20 7 ▶eval "use CPAN::FindDependencies;";
Subroutine BEGIN: called CC=1 SCAR=0.0
21 7 ▶if($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 7 7
22 0 die "Couldn't load CPAN::FindDependencies.\n";
23 }
24  
25 my @deps = CPAN::FindDependencies::finddeps(
26 nowarnings => 1,
27 map {
28 7 $_ =~ /^(--showmoduleversions|-h|--help)$/ ? () :
29 47 ▶ $_ =~ /^--/ ? do { s/^--//; $_ } :
Branch: 2 branches
BranchTrueFalseTotal
$_ =~ /^(--showmoduleversions|-h|--help)$/ ? : 4 43 47
$_ =~ /^--/ ? : 4 39 43
30 $_
31 } @ARGV
32 );
33  
34 4 foreach my $dep (@deps) {
35 16 print ' ' x $dep->depth();
36 16 ▶ print '*' if($dep->warning());
Branch: 1 branch
BranchTrueFalseTotal
if $dep->warning 2 14 16
37 16 print $dep->name().' (dist: '.$dep->distribution();
38 16 ▶ print ', mod ver: '.$dep->version() if($showversion && $dep->name() ne $deps[0]->name());
Branch: 1 branch
BranchTrueFalseTotal
if $showversion and $dep->name ne $deps[0]->name 2 14 16
Condition100%3/3
$showversion and $dep->name ne $deps[0]->name
!ll&&!rl&&r
1222
MC/DC100%2/2
$showversion and $dep->name ne $deps[0]->name
$showversion $dep->name ne $deps[0]->name
Truth table100%3/3
A and B
A= $showversionB= $dep->name ne $deps[0]->name
ABresult
0X0
100
111
39 16 print ")\n";
40 }
41  
42 =head1 NAME
43  
44 cpandeps - show a module on the CPAN's dependency tree.
45  
46 =head1 DESCRIPTION
47  
48 This program is a simple wrapper around CPAN::FindDependencies.
49  
50 =head1 SYNOPSIS
51  
52 cpandeps CPAN::FindDependencies
53  
54 cpandeps --perl 5.8.8 --cachedir ../foo/bar CPAN::FindDependencies
55  
56 cpandeps --showmoduleversions CPAN::FindDependencies
57  
58 Given a module name, this program will show you the module's
59 dependency tree. It takes exactly the same arguments as the
60 C<finddeps> function of CPAN::FindDependencies, with the exception
61 that C<nowarnings> is turned *on* by default:
62  
63 =over
64  
65 =item nowarnings
66  
67 Warnings about modules where we can't find their META.yml or Makefile.PL, and
68 so can't divine their pre-requisites, will be suppressed. Other warnings may
69 still be emitted though, such as those telling you about modules which have
70 dodgy (but still understandable) metadata;
71  
72 =item fatalerrors
73  
74 Failure to get a module's dependencies will be a fatal error
75 instead of merely emitting a warning;
76  
77 =item perl
78  
79 Use this version of perl to figure out what's in core. If not
80 specified, it defaults to 5.005. Three part version numbers
81 (eg 5.8.8) are supported but discouraged.
82  
83 =item cachedir
84  
85 A directory to use for caching. It defaults to no caching. Even if
86 caching is turned on, this is only for META.yml or Makefile.PL files.
87 The cache is never automatically cleared out. It is your responsibility
88 to clear out old data.
89  
90 If the directory doesn't exist we will try to create it. If we can't,
91 or it exists but isn't readable and writeable, that is a fatal error.
92  
93 =item maxdepth
94  
95 Cuts off the dependency tree at the specified depth. Your specified
96 module is at depth 0, your dependencies at depth 1, their dependencies
97 at depth 2, and so on.
98  
99 If you don't specify any maxdepth at all it will grovel over the
100 entire tree.
101  
102 =item mirror
103  
104 This can be provided more than once, if for example you want to use
105 a private L<Pinto> repository for your own code while using a public
106 CPAN mirror for open source dependencies. The argument comes in two parts
107 separated by a comma - the base URL from which to fetch files, and
108 optionally the URL or a file from which to fetch the index
109 C<02packages.details.txt.gz> file to use with that mirror.
110  
111 mirror https://cpan.mydomain.net,file:///home/me/mycache/02packages.txt.gz
112  
113 If you want to use the default CPAN mirror (https://cpan.metacpan.org/)
114 but also specify an index location you can use C<DEFAULT> for the mirror URL.
115  
116 So for example, to use your own special private mirror, including fetching
117 02packages from it, but also use the default mirror with a cached local
118 copy of its 02packages, specify two mirrors thus:
119  
120 mirror => 'https://cpan.mydomain.net',
121 mirror => 'DEFAULT,file:///home/me/mycache/02packages.txt.gz'
122  
123 The index is cached for three minutes or until your process finishes, whichever is soonest. This is because it is HUMUNGOUS and parsing it takes ages even when it's loaded from a local disk, and I don't want the tests to take forever.
124  
125 =item usemakefilepl
126  
127 If set to true, then for any module that doesn't have a META.yml,
128 try to use its Makefile.PL as well. Note that this involves
129 downloading code from the Internet and running it. This obviously
130 opens you up to all kinds of bad juju, hence why it is disabled
131 by default. NB that this fetches Makefile.PL from
132 L<https://fastapi.metacpan.org> B<only> so will not work for private mirrors.
133 This is a deliberate choice, your own private code ought to be packaged
134 properly with a META file, you should only care about divining dependencies
135 from Makefile.PL if you rely on really old stuff on public CPAN mirrors.
136  
137 =item recommended
138  
139 Adds recommended modules to the list of dependencies, if set to a true value.
140  
141 =item suggested
142  
143 Adds suggested modules to the list of dependencies, if set to a true value.
144  
145  
146 =back
147  
148 It also takes the following extra parameter:
149  
150 =over
151  
152 =item --showmoduleversions
153  
154 If present, the required version of each module is also shown
155  
156 =back
157  
158 It shows the module name, its distribution, and if any warnings were
159 raised (such as if a module's dependencies couldn't be fetched) this
160 is indicated with an asterisk before the module's name.
161  
162 =head1 INCOMPATIBLE CHANGES
163  
164 Up to version 2.49 you used the C<02packages> argument to specify where a
165 cached C<02packages.details.txt.gz> could be found. That argument no longer
166 exists as of version 3.00, use the C<mirror> argument instead.
167  
168 Up to version 2.49, C<maxdepth =E<gt> 0> would incorrectly return the whole
169 tree. From version 3.00 it cuts the tree off at its root so will only return
170 the module that you asked about. Not very useful, but correct.
171  
172 In version 2.49 you used the C<configreqs> argument to specify that you were
173 interested in configure-time requirements as well as build- and run-time
174 requirements. That option no longer exists as of version 3.00, it will always
175 report on configure, build, test, and run-time requirements.
176  
177 Up to version 3.13 specifying a bogus directory for C<cachedir> would be
178 ignored.
179  
180 From version 4.00 onwards you *must* have Net::SSLeay and IO::Socket::SSL
181 available. A perl that doesn't have SSL support is broken. We will no
182 longer fall back to wget.
183  
184  
185 =head1 TREE PRUNING
186  
187 The dependency tree is pruned to remove duplicates. This means that even though
188 C<Test::More>, for example, is a dependency of almost everything on the CPAN,
189 it will only be listed once.
190  
191  
192 =head1 WARNINGS, BUGS and FEEDBACK
193  
194 This script has not been thoroughly tested.
195  
196 I welcome feedback about my code, including constructive criticism.
197 Bug reports should be made on Github or by email.
198  
199 =head1 SEE ALSO
200  
201 L<CPAN::FindDependencies>
202  
203 L<http://deps.cpantesters.org/>
204  
205 =head1 AUTHOR, LICENCE and COPYRIGHT
206  
207 Copyright 2007 - 2026 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
208  
209 This software is free-as-in-speech software, and may be used,
210 distributed, and modified under the terms of either the GNU
211 General Public Licence version 2 or the Artistic Licence. It's
212 up to you which one you use. The full text of the licences can
213 be found in the files GPL2.txt and ARTISTIC.txt, respectively.
214  
215 =head1 CONSPIRACY
216  
217 This software is also free-as-in-mason.
218  
219 =cut
« blib/script/cpandeps-diff ↑ Summary blib/lib/CPAN/FindDependencies/Dependency.pm »