meta/FunctionalPerl/Dependencies.pm

filter: Statementstmt 100% 49 / 49 Branchbran 87.5% 7 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 94.5% 69 / 73 CC 6 SCAR 6.6
CC
6
Cov
98%
modulename_or_array_to_code
3.0
have_dependency
3.0
module_needs
2.0
CRAP 1.9
« lib/FP/Memoizing.pm ↑ Summary lib/FP/OrderedCollection.pm »
1 #
2 # Copyright (c) 2015-2021 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 FunctionalPerl::Dependencies
13  
14 =head1 SYNOPSIS
15  
16 1 ▶ use FunctionalPerl::Dependencies 'module_needs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # if (my @needs = module_needs $module) {
19 # skip "- don't have @needs", 1;
20 # }
21  
22 =head1 DESCRIPTION
23  
24  
25 =cut
26  
27 package FunctionalPerl::Dependencies;
28 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 2 our @EXPORT = qw();
34 2 our @EXPORT_OK = qw(have_dependency module_needs);
35 2 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
36  
37 # ------------------------------------------------------------------
38 # Non-core dependencies of modules to decide whether to skip testing
39 # them. XX: keep these updated!
40  
41 our %dependencies = (
42  
43 # Don't specify Sub::Call::Tail (if meta/tail-expand can expand it)!
44  
45 # "5.020" for experimental 'signatures'
46 'FunctionalPerl::Indexing' => [
47 "5.020",
48 "File::chdir",
49 [
50 # The called "meta/perlfiles" script needs:
51 "FunctionalPerl::Dependencies::ChjBin" => qw( printfield gls filter
52 is-perl skiplines )
53 ]
54 ],
55 'Chj::Packages' => ["5.020"],
56 'FP::SortedPureArray' => ["5.020", "List::BinarySearch"],
57 'FP::RegexMatch' => ["5.020"],
58 'FP::JSON' => ['JSON', "5.020"],
59 'FP::Abstract::Sequence::t' => ['FP::autobox'],
60 'Chj::Serialize' => ['FP::Repl::Dependencies', 'B::Deparse'],
61 'FP::Docstring' => ['B::Deparse'],
62 'FP::BigInt' => ['Math::BigInt'],
63 'FP::autobox' => ['autobox'],
64 'FP::Failure' => ['Path::Tiny'],
65 'FP::Text::CSV' => ['Text::CSV'],
66 'FP::url_' => ['URI'],
67 'Chj::CPAN::ModulePODUrl' => ['LWP::UserAgent'],
68 'FP::DBI' => ['DBI'],
69 'FunctionalPerl::Htmlgen::UriUtil' => ['5.020', 'URI'],
70 'FunctionalPerl::Htmlgen::PathUtil' => ['5.020', 'File::Spec',],
71 'FunctionalPerl::Htmlgen::PathTranslate' =>
72 ['5.020', 'FunctionalPerl::Htmlgen::PathUtil'],
73 'FunctionalPerl::Htmlgen::Mediawiki' => ['5.020', 'Encode', 'URI',],
74 'FunctionalPerl::Htmlgen::MarkdownPlus' => [
75 '5.020',
76 'FunctionalPerl::Htmlgen::Htmlparse',
77 'Text::Markdown',
78 'FunctionalPerl::Htmlgen::Mediawiki'
79 ],
80 'FunctionalPerl::Htmlgen::Linking' => [
81 '5.020',
82 'FunctionalPerl::Htmlgen::PathUtil',
83 'Chj::CPAN::ModulePODUrl',
84 'FunctionalPerl::Htmlgen::UriUtil',
85 ],
86 'FunctionalPerl::Htmlgen::Htmlparse' => ['5.020', 'HTML::TreeBuilder',],
87 'Chj::HTTP::Daemon' => ['HTTP::Request',],
88 'FunctionalPerl::Htmlgen::PerlTidy' =>
89 ['5.020', 'Perl::Tidy', 'FunctionalPerl::Htmlgen::Htmlparse',],
90 (
91 16 map { $_ => ['5.020'] }
92 qw(
93 FP::AST::Perl
94 FunctionalPerl::Htmlgen::Toc
95 FunctionalPerl::Htmlgen::PXMLMapper
96 FunctionalPerl::Htmlgen::FileUtil
97 FunctionalPerl::Htmlgen::default_config
98 FunctionalPerl::Htmlgen::Cost
99 FunctionalPerl::Htmlgen::Nav
100 FunctionalPerl::Htmlgen::Sourcelang
101 )
102 ),
103 (
104 2 map { $_ => ['FP::Repl::Dependencies'] }
105 qw(
106 FP::Repl::Dependencies
107 FP::Repl::Repl
108 FP::Repl::StackPlus
109 FP::Repl::Trap
110 FP::Repl::WithRepl
111 FP::Repl
112 FP::Trie::t
113 )
114 ),
115 );
116  
117 # ------------------------------------------------------------------
118  
119 2 ▶use Chj::singlequote qw(singlequote_many);
Subroutine BEGIN: called CC=1 SCAR=0.0
120  
121 118 ▶sub modulename_or_array_to_code {
Subroutine modulename_or_array_to_code: called CC=3 SCAR=11.0
Pod undocumented
122 118 my ($modulename_or_array) = @_;
123 118 ▶ if (my $r = ref $modulename_or_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = ref $modulename_or_array) { } 4 114 118
124 4 ▶ $r eq "ARRAY" or die "invalid datum in dependenies data structure";
Branch: 1 branch
BranchTrueFalseTotal
$r eq "ARRAY" or die "invalid datum in dependenies data structure" 4 0 4
125 4 my ($modulename, @args) = @$modulename_or_array;
126 4 my $quotedargs = singlequote_many @args;
127 4 "use $modulename ($quotedargs)"
128 } else {
129  
130 # "use $modulename_or_array ()" doesn't work for 5.020!
131 114 "require $modulename_or_array"
132 }
133 }
134  
135 2 my %have_dependency;
136  
137 my $counter; # ugly hack to avoid redefinitions
138  
139 105 ▶sub have_dependency {
Subroutine have_dependency: called CC=3 SCAR=11.0
Pod undocumented
140 105 my ($modulename_or_array) = @_;
141 105 my $code1 = modulename_or_array_to_code $modulename_or_array;
142 105 ▶ exists $have_dependency{$code1} ? $have_dependency{$code1} : do {
Branch: 1 branch
BranchTrueFalseTotal
exists $have_dependency{$code1} ? : 56 49 105
143 49 my $n = $counter++;
144 49 my $code = "package\nFunctionalPerl::Dependenies::TMP$n {
145 $code1;
146 1
147 }";
148 2 ▶ my $res = (eval $code or 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition100%2/2
eval $code || 0
l!l
436
MC/DC100%1/1
eval $code || 0
eval $code
Truth table100%2/2
A
A= eval $code
Aresult
11
00
149 49 $have_dependency{$code1} = $res;
150 49 $res
151 }
152 }
153  
154 281 ▶sub module_needs {
Subroutine module_needs: called CC=2 SCAR=6.9
Pod undocumented
155 281 my ($modulename) = @_;
156 281 ▶ if (my $ds = $dependencies{$modulename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ds = $FunctionalPerl::Dependencies::dependencies{$modulename}) { } 68 213 281
157 13 map { modulename_or_array_to_code $_ }
158 68 grep { not have_dependency $_ }
159 sort @$ds
160 } else {
161 ()
162 213 }
163 }
164  
165 2 1
« lib/FP/Memoizing.pm ↑ Summary lib/FP/OrderedCollection.pm »