blib/lib/DBIO/Optional/Dependencies.pm

filter: Statementstmt 68.7% 66 / 96 Branchbran 41.6% 30 / 72 Conditioncond 30.0% 3 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.0% 9 / 12 Podpod 100% 6 / 6 totaltotal 56.7% 114 / 201 CC 30 SCAR 36.7
CC
30
Cov
56%
_gen_pod
132.0
die_unless_req_ok_for
12.0
_check_deps
8.1
CRAP 39.4
« blib/lib/DBIO/Storage/QueryRewrite.pm ↑ Summary blib/lib/DBIO/Relationship/Base.pm »
1 package DBIO::Optional::Dependencies;
2 # ABSTRACT: Optional dependency declarations for DBIO
3  
4 392 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 392 our $VERSION = '0.900007';
7  
8 392 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 392 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # NO EXTERNAL NON-5.20 CORE DEPENDENCIES EVER (e.g. C::A::G)
13 # This module is to be loaded by Makefile.PM on a pristine system
14  
15 # POD is generated automatically by calling _gen_pod from the
16 # Makefile.PL in $AUTHOR mode
17  
18 # NOTE: the rationale for 2 JSON::Any versions is that
19 # we need the newer only to work around JSON::XS, which
20 # itself is an optional dep
21 392 my $min_json_any = {
22 'JSON::Any' => '1.23',
23 };
24 392 my $test_and_dist_json_any = {
25 'JSON::Any' => '1.31',
26 };
27  
28 392 my $config_files = {
29 'Config::Any' => '0',
30 };
31  
32 392 my $admin_script = {
33 'Text::CSV' => '1.16',
34 };
35  
36 392 my $datetime_basic = {
37 'DateTime' => '0.55',
38 'DateTime::Format::Strptime' => '1.2',
39 };
40  
41 392 my $rdbms_sqlite = {
42 'DBD::SQLite' => '0',
43 };
44 392 my $rdbms_pg = {
45 'DBD::Pg' => '0',
46 };
47 392 my $rdbms_mssql_odbc = {
48 'DBD::ODBC' => '0',
49 };
50 392 my $rdbms_mssql_sybase = {
51 'DBD::Sybase' => '0',
52 };
53  
54  
55 398 ▶sub _module_findable {
Subroutine _module_findable: called CC=5 SCAR=16.3
56 398 my $notional_filename = shift;
57  
58 398 ▶ return 1 if $INC{$notional_filename};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{$notional_filename} 0 398 398
59  
60 # One stat per @INC entry instead of compiling the module and, for a DBD,
61 # initialising XS. Ref entries are hooks -- asking one means running it, which
62 # is the loading this exists to avoid -- so they are skipped.
63 398 for my $inc (@INC) {
64 3353 ▶ next if ref $inc;
Branch: 1 branch
BranchTrueFalseTotal
if ref $inc 149 3204 3353
65 3204 ▶ return 1 if -f "$inc/$notional_filename";
Branch: 1 branch
BranchTrueFalseTotal
if -f "$inc/$notional_filename" 0 3204 3204
66 }
67  
68 398 return 0;
69 }
70  
71 392 ▶my $rdbms_mysql = {
Branch: 1 branch
BranchTrueFalseTotal
_module_findable('DBD/MariaDB.pm') ? : 0 392 392
72 # Accept either DBD::mysql or DBD::MariaDB (the actively maintained fork).
73 # Probed, never loaded: DBIO::Base pulls this module in, so a require here
74 # drags DBI and an XS driver into every process that touches anything in this
75 # family -- for a metadata string.
76 ( _module_findable('DBD/MariaDB.pm')
77 ? ( 'DBD::MariaDB' => '0' )
78 : ( 'DBD::mysql' => '0' )
79 ),
80 };
81 392 my $rdbms_oracle = {
82 'DBD::Oracle' => '0',
83 };
84 392 my $rdbms_ase = {
85 'DBD::Sybase' => '0',
86 };
87 392 my $rdbms_db2 = {
88 'DBD::DB2' => '0',
89 };
90 392 my $rdbms_informix = {
91 'DBD::Informix' => '0',
92 };
93 392 my $rdbms_firebird = {
94 'DBD::Firebird' => '0',
95 };
96 392 my $rdbms_firebird_interbase = {
97 'DBD::InterBase' => '0',
98 };
99 392 my $rdbms_firebird_odbc = {
100 'DBD::ODBC' => '0',
101 };
102 my $reqs = {
103 config_files => {
104 req => {
105 %$config_files,
106 },
107 pod => {
108 title => 'Config file support',
109 desc => 'Modules required to parse DBIO config and profile files',
110 },
111 },
112  
113 admin_script => {
114 req => {
115 %$admin_script,
116 },
117 pod => {
118 title => 'dbioadmin',
119 desc => 'Modules required for optional dbioadmin output formats',
120 },
121 },
122  
123 encoded_column => {
124 req => {
125 'Crypt::Bcrypt' => '0',
126 'Crypt::Argon2' => '0',
127 },
128 pod => {
129 title => 'EncodedColumn',
130 desc => 'Password hashing of L<DBIO::EncodedColumn>: Crypt::Bcrypt for the default class Bcrypt (and to check bcrypt hashes), Crypt::Argon2 for the class Argon2 (and to check argon2id hashes)',
131 },
132 },
133  
134 deploy => {
135 req => {
136 },
137 pod => {
138 title => 'Storage::DBI::deploy()',
139 desc => 'Modules required for native Deploy (if the storage provides no C<dbio_deploy_class>, L<DBIO::Schema/deploy> falls back to C<deploy> on the storage, which runs an existing DDL file and throws if there is none)',
140 },
141 },
142  
143 test_kubernetes => {
144 req => {
145 'Kubernetes::REST' => '1.109',
146 'IO::K8s' => '0',
147 },
148 pod => {
149 title => 'DBIO::Test::Kubernetes',
150 desc => 'Modules for the live-test cluster tooling (xbin/k8s-test, L<DBIO::Test::Kubernetes>); 1.109 is the first Kubernetes::REST whose Job delete takes a propagationPolicy',
151 },
152 },
153  
154 test_component_accessor => {
155 req => {
156 'Class::Unload' => '0.07',
157 },
158 },
159  
160 test_pod => {
161 req => {
162 'Test::Pod' => '1.42',
163 },
164 },
165  
166 test_podcoverage => {
167 req => {
168 'Test::Pod::Coverage' => '1.08',
169 'Pod::Coverage' => '0.20',
170 },
171 },
172  
173 test_whitespace => {
174 req => {
175 'Test::EOL' => '1.0',
176 'Test::NoTabs' => '0.9',
177 },
178 },
179  
180 test_strictures => {
181 req => {
182 'Test::Strict' => '0.23',
183 },
184 },
185  
186 test_prettydebug => {
187 req => {
188 %$min_json_any,
189 %$config_files,
190 },
191 },
192  
193 test_admin_script => {
194 req => {
195 %$admin_script,
196 $^O eq 'MSWin32'
197 # for script invocation argument quoting on Win32
198 ? ('Win32::ShellQuote' => 0)
199 : ()
200 ,
201 }
202 },
203  
204 test_leaks_heavy => {
205 req => {
206 'Class::MethodCache' => '0.02',
207 'PadWalker' => '1.06',
208 },
209 },
210  
211 test_dt => {
212 req => $datetime_basic,
213 },
214  
215 test_dt_sqlite => {
216 req => {
217 %$datetime_basic,
218 # t/36datetime.t
219 # t/60core.t
220 'DateTime::Format::SQLite' => '0',
221 },
222 },
223  
224 test_dt_mysql => {
225 req => {
226 %$datetime_basic,
227 # (doesn't need Mysql itself)
228 'DateTime::Format::MySQL' => '0',
229 },
230 },
231  
232 test_dt_pg => {
233 req => {
234 %$datetime_basic,
235 # (doesn't need PG itself)
236 'DateTime::Format::Pg' => '0.16004',
237 },
238 },
239  
240 # this is just for completeness as SQLite
241 # is a core dep of DBIO for testing
242 rdbms_sqlite => {
243 req => {
244 %$rdbms_sqlite,
245 },
246 pod => {
247 title => 'SQLite support',
248 desc => 'Modules required to connect to SQLite',
249 },
250 },
251  
252 rdbms_pg => {
253 req => {
254 # when changing this list make sure to adjust xt/optional_deps.t
255 %$rdbms_pg,
256 },
257 pod => {
258 title => 'PostgreSQL support',
259 desc => 'Modules required to connect to PostgreSQL',
260 },
261 },
262  
263 rdbms_mssql_odbc => {
264 req => {
265 %$rdbms_mssql_odbc,
266 },
267 pod => {
268 title => 'MSSQL support via DBD::ODBC',
269 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
270 },
271 },
272  
273 rdbms_mssql_sybase => {
274 req => {
275 %$rdbms_mssql_sybase,
276 },
277 pod => {
278 title => 'MSSQL support via DBD::Sybase',
279 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
280 },
281 },
282  
283 rdbms_mysql => {
284 req => {
285 %$rdbms_mysql,
286 },
287 pod => {
288 title => 'MySQL support',
289 desc => 'Modules required to connect to MySQL',
290 },
291 },
292  
293 rdbms_oracle => {
294 req => {
295 %$rdbms_oracle,
296 },
297 pod => {
298 title => 'Oracle support',
299 desc => 'Modules required to connect to Oracle',
300 },
301 },
302  
303 rdbms_ase => {
304 req => {
305 %$rdbms_ase,
306 },
307 pod => {
308 title => 'Sybase ASE support',
309 desc => 'Modules required to connect to Sybase ASE',
310 },
311 },
312  
313 rdbms_db2 => {
314 req => {
315 %$rdbms_db2,
316 },
317 pod => {
318 title => 'DB2 support',
319 desc => 'Modules required to connect to DB2',
320 },
321 },
322  
323 rdbms_informix => {
324 req => {
325 %$rdbms_informix,
326 },
327 pod => {
328 title => 'Informix support',
329 desc => 'Modules required to connect to Informix',
330 },
331 },
332  
333 rdbms_firebird => {
334 req => {
335 %$rdbms_firebird,
336 },
337 pod => {
338 title => 'Firebird support',
339 desc => 'Modules required to connect to Firebird',
340 },
341 },
342  
343 rdbms_firebird_interbase => {
344 req => {
345 %$rdbms_firebird_interbase,
346 },
347 pod => {
348 title => 'Firebird support via DBD::InterBase',
349 desc => 'Modules required to connect to Firebird via DBD::InterBase',
350 },
351 },
352  
353 rdbms_firebird_odbc => {
354 req => {
355 %$rdbms_firebird_odbc,
356 },
357 pod => {
358 title => 'Firebird support via DBD::ODBC',
359 desc => 'Modules required to connect to Firebird via DBD::ODBC',
360 },
361 },
362  
363 # the order does matter because the rdbms support group might require
364 # a different version that the test group
365 test_rdbms_pg => {
366 req => {
367 ($ENV{DBIO_TEST_PG_DSN})
368 ? (
369 # when changing this list make sure to adjust xt/optional_deps.t
370 %$rdbms_pg,
371 'DBD::Pg' => '2.009002',
372 ) : ()
373 },
374 },
375  
376 test_rdbms_mssql_odbc => {
377 req => {
378 ($ENV{DBIO_TEST_MSSQL_ODBC_DSN})
379 ? (
380 %$rdbms_mssql_odbc,
381 ) : ()
382 },
383 },
384  
385 test_rdbms_mssql_sybase => {
386 req => {
387 ($ENV{DBIO_TEST_MSSQL_DSN})
388 ? (
389 %$rdbms_mssql_sybase,
390 ) : ()
391 },
392 },
393  
394 test_rdbms_mysql => {
395 req => {
396 ($ENV{DBIO_TEST_MYSQL_DSN})
397 ? (
398 %$rdbms_mysql,
399 ) : ()
400 },
401 },
402  
403 test_rdbms_oracle => {
404 req => {
405 ($ENV{DBIO_TEST_ORA_DSN})
406 ? (
407 %$rdbms_oracle,
408 'DateTime::Format::Oracle' => '0',
409 'DBD::Oracle' => '1.24',
410 ) : ()
411 },
412 },
413  
414 test_rdbms_ase => {
415 req => {
416 ($ENV{DBIO_TEST_SYBASE_DSN})
417 ? (
418 %$rdbms_ase,
419 ) : ()
420 },
421 },
422  
423 test_rdbms_db2 => {
424 req => {
425 ($ENV{DBIO_TEST_DB2_DSN})
426 ? (
427 %$rdbms_db2,
428 ) : ()
429 },
430 },
431  
432 test_rdbms_informix => {
433 req => {
434 ($ENV{DBIO_TEST_INFORMIX_DSN})
435 ? (
436 %$rdbms_informix,
437 ) : ()
438 },
439 },
440  
441 test_rdbms_firebird => {
442 req => {
443 ($ENV{DBIO_TEST_FIREBIRD_DSN})
444 ? (
445 %$rdbms_firebird,
446 ) : ()
447 },
448 },
449  
450 test_rdbms_firebird_interbase => {
451 req => {
452 ($ENV{DBIO_TEST_FIREBIRD_INTERBASE_DSN})
453 ? (
454 %$rdbms_firebird_interbase,
455 ) : ()
456 },
457 },
458  
459 test_rdbms_firebird_odbc => {
460 req => {
461 ($ENV{DBIO_TEST_FIREBIRD_ODBC_DSN})
462 ? (
463 %$rdbms_firebird_odbc,
464 ) : ()
465 },
466 },
467  
468 test_memcached => {
469 req => {
470 ($ENV{DBIO_TEST_MEMCACHED})
471 392 ▶ ? (
Branch: 13 branches
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 392 392
$ENV{'DBIO_TEST_PG_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_MSSQL_ODBC_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_MSSQL_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_MYSQL_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_ORA_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_SYBASE_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_DB2_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_INFORMIX_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_FIREBIRD_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_FIREBIRD_INTERBASE_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_FIREBIRD_ODBC_DSN'} ? : 0 392 392
$ENV{'DBIO_TEST_MEMCACHED'} ? : 0 392 392
472 'Cache::Memcached' => 0,
473 ) : ()
474 },
475 },
476  
477 dist_dir => {
478 req => {
479 %$config_files,
480 %$admin_script,
481 %$test_and_dist_json_any,
482 'ExtUtils::MakeMaker' => '6.64',
483 'Pod::Inherit' => '0.91',
484 },
485 },
486  
487 dist_upload => {
488 req => {
489 'CPAN::Uploader' => '0.103001',
490 },
491 },
492  
493 };
494  
495 392 our %req_availability_cache;
496  
497  
498 33 ▶sub req_list_for {
Subroutine req_list_for: called CC=3 SCAR=11.4
Pod documented
499 33 my ($class, $group) = @_;
500  
501 33 ▶ Carp::croak "req_list_for() expects a requirement group name"
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 33 33
502 unless $group;
503  
504 my $deps = $reqs->{$group}{req}
505 33 ▶ or Carp::croak "Requirement group '$group' does not exist";
Branch: 1 branch
BranchTrueFalseTotal
my $deps = $reqs->{$group}{"req"} or Carp::croak("Requirement group '${group}' does not exist") 33 0 33
506  
507 33 return { %$deps };
508 }
509  
510  
511  
512 0 ▶sub die_unless_req_ok_for {
Subroutine die_unless_req_ok_for: not called CC=3 SCAR=24.8
Pod documented
513 0 my ($class, $group) = @_;
514  
515 0 ▶ Carp::croak "die_unless_req_ok_for() expects a requirement group name"
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 0 0
516 unless $group;
517  
518 $class->_check_deps($group)->{status}
519 0 ▶ or die sprintf( "Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{missing} );
Branch: 1 branch
BranchTrueFalseTotal
$class->_check_deps($group)->{"status"} or die sprintf("Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{"missing"}) 0 0 0
520 }
521  
522  
523 3 ▶sub req_ok_for {
Subroutine req_ok_for: called CC=2 SCAR=7.1
Pod documented
524 3 my ($class, $group) = @_;
525  
526 3 ▶ Carp::croak "req_ok_for() expects a requirement group name"
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 3 3
527 unless $group;
528  
529 3 return $class->_check_deps($group)->{status};
530 }
531  
532  
533 1 ▶sub req_missing_for {
Subroutine req_missing_for: called CC=2 SCAR=7.1
Pod documented
534 1 my ($class, $group) = @_;
535  
536 1 ▶ Carp::croak "req_missing_for() expects a requirement group name"
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 1 1
537 unless $group;
538  
539 1 return $class->_check_deps($group)->{missing};
540 }
541  
542  
543 0 ▶sub req_errorlist_for {
Subroutine req_errorlist_for: not called CC=2 SCAR=17.9
Pod documented
544 0 my ($class, $group) = @_;
545  
546 0 ▶ Carp::croak "req_errorlist_for() expects a requirement group name"
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 0 0
547 unless $group;
548  
549 0 return $class->_check_deps($group)->{errorlist};
550 }
551  
552  
553 4 ▶sub _check_deps {
Subroutine _check_deps: called CC=8 SCAR=21.0
554 4 my ($class, $group) = @_;
555  
556 4 ▶ return $req_availability_cache{$group} ||= do {
Condition66%2/3
$DBIO::Optional::Dependencies::req_availability_cache{$group} ||= do { my $deps = $class->req_list_for($group); my %errors; foreach my $mod (keys %$deps) { my $req_line = "require $mod;"; if (my $ver = $deps->{$mod}) { $req_line .= "$mod->VERSION($ver);"; } ; eval $req_line; $errors{$mod} = $@ if $@; } ; my $res; if (keys %errors) { my $missing = join(", ", map({$deps->{$_} ? "$_ >= $deps->{$_}" : $_;} sort(keys %errors))); $missing .= " (see $class for details)" if $reqs->{$group}{"pod"}; $res = {"status", 0, "errorlist", \%errors, "missing", $missing}; } else { $res = {"status", 1, "errorlist", {}, "missing", ""}; } ; $res }
l!l&&r!l&&!r
130
MC/DC0%0/2
$DBIO::Optional::Dependencies::req_availability_cache{$group} ||= do { my $deps = $class->req_list_for($group); my %errors; foreach my $mod (keys %$deps) { my $req_line = "require $mod;"; if (my $ver = $deps->{$mod}) { $req_line .= "$mod->VERSION($ver);"; } ; eval $req_line; $errors{$mod} = $@ if $@; } ; my $res; if (keys %errors) { my $missing = join(", ", map({$deps->{$_} ? "$_ >= $deps->{$_}" : $_;} sort(keys %errors))); $missing .= " (see $class for details)" if $reqs->{$group}{"pod"}; $res = {"status", 0, "errorlist", \%errors, "missing", $missing}; } else { $res = {"status", 1, "errorlist", {}, "missing", ""}; } ; $res }
$DBIO::Optional::Dependencies::req_availability_cache{$group} do { my $deps = $class->req_list_for($group); my %errors; foreach my $mod (keys %$deps) { my $req_line = "require $mod;"; if (my $ver = $deps->{$mod}) { $req_line .= "$mod->VERSION($ver);"; } ; eval $req_line; $errors{$mod} = $@ if $@; } ; my $res; if (keys %errors) { my $missing = join(", ", map({$deps->{$_} ? "$_ >= $deps->{$_}" : $_;} sort(keys %errors))); $missing .= " (see $class for details)" if $reqs->{$group}{"pod"}; $res = {"status", 0, "errorlist", \%errors, "missing", $missing}; } else { $res = {"status", 1, "errorlist", {}, "missing", ""}; } ; $res }
Truth table66%2/3
A ||= B
A= $DBIO::Optional::Dependencies::req_availability_cache{$group}B= do { my $deps = $class->req_list_for($group); my %errors; foreach my $mod (keys %$deps) { my $req_line = "require $mod;"; if (my $ver = $deps->{$mod}) { $req_line .= "$mod->VERSION($ver);"; } ; eval $req_line; $errors{$mod} = $@ if $@; } ; my $res; if (keys %errors) { my $missing = join(", ", map({$deps->{$_} ? "$_ >= $deps->{$_}" : $_;} sort(keys %errors))); $missing .= " (see $class for details)" if $reqs->{$group}{"pod"}; $res = {"status", 0, "errorlist", \%errors, "missing", $missing}; } else { $res = {"status", 1, "errorlist", {}, "missing", ""}; } ; $res }
ABresult
1X1
011
000
557  
558 3 my $deps = $class->req_list_for ($group);
559  
560 3 my %errors;
561 3 for my $mod (keys %$deps) {
562 6 my $req_line = "require $mod;";
563 6 ▶ if (my $ver = $deps->{$mod}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ver = $deps->{$mod}) 5 1 6
564 5 $req_line .= "$mod->VERSION($ver);";
565 }
566  
567 6 eval $req_line;
568  
569 6 ▶ $errors{$mod} = $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 4 2 6
570 }
571  
572 3 my $res;
573  
574 3 ▶ if (keys %errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %errors) { } 3 0 3
575 3 ▶ my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
Branch: 1 branch
BranchTrueFalseTotal
$deps->{$_} ? : 3 1 4
576 3 ▶ $missing .= " (see $class for details)" if $reqs->{$group}{pod};
Branch: 1 branch
BranchTrueFalseTotal
if $reqs->{$group}{"pod"} 0 3 3
577 3 $res = {
578 status => 0,
579 errorlist => \%errors,
580 missing => $missing,
581 };
582 }
583 else {
584 0 $res = {
585 status => 1,
586 errorlist => {},
587 missing => '',
588 };
589 }
590  
591 3 $res;
592 };
593 }
594  
595  
596 1 ▶sub req_group_list {
Subroutine req_group_list: called CC=2 SCAR=7.1
Pod documented
597 1 ▶ return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
Condition50%1/2
$reqs->{$_}{'req'} || {}
l!l
430
MC/DC0%0/1
$reqs->{$_}{'req'} || {}
$reqs->{$_}{'req'}
Truth table50%1/2
A
A= $reqs->{$_}{'req'}
Aresult
11
00
598 }
599  
600 # This is to be called by the author only (automatically in Makefile.PL)
601  
602 0 ▶sub _gen_pod {
Subroutine _gen_pod: not called CC=11 SCAR=48.8
603 0 my ($class, $distver, $pod_dir) = @_;
604  
605 0 ▶ die "No POD root dir supplied" unless $pod_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $pod_dir 0 0 0
606  
607 $distver ||=
608 0 ▶ eval { require DBIO; DBIO->VERSION; }
Condition0%0/5
$distver ||= eval { do { require DBIO; "DBIO"->VERSION } } || die("\n\n---------------------------------------------------------------------\nUnable to load core DBIO module to determine current version, possibly due to missing dependencies. Author-mode autodocumentation halted\n\n" . $@ . "\n\n---------------------------------------------------------------------\n")
l!l&&r!l&&!r
000
eval { do { require DBIO; 'DBIO'->VERSION } } || die("\n\n---------------------------------------------------------------------\nUnable to load core DBIO module to determine current version, possibly due to missing dependencies. Author-mode autodocumentation halted\n\n" . $@ . "\n\n---------------------------------------------------------------------\n")
l!l
00
MC/DC0%0/2
$distver ||= eval { do { require DBIO; "DBIO"->VERSION } } || die("\n\n---------------------------------------------------------------------\nUnable to load core DBIO module to determine current version, possibly due to missing dependencies. Author-mode autodocumentation halted\n\n" . $@ . "\n\n---------------------------------------------------------------------\n")
$distver eval { do { require DBIO; 'DBIO'->VERSION } }
Truth table0%0/3
A ||= B
A= $distverB= eval { do { require DBIO; 'DBIO'->VERSION } }
ABresult
1X1
011
000
609 ||
610 die
611 "\n\n---------------------------------------------------------------------\n" .
612 'Unable to load core DBIO module to determine current version, '.
613 'possibly due to missing dependencies. Author-mode autodocumentation ' .
614 "halted\n\n" . $@ .
615 "\n\n---------------------------------------------------------------------\n"
616 ;
617  
618 # do not ask for a recent version, use 1.x API calls
619 # this *may* execute on a smoker with old perl or whatnot
620 0 require File::Path;
621  
622 0 (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
623  
624 0 (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
625 0 (my $dir = $podfn) =~ s|/[^/]+$||;
626  
627 0 File::Path::mkpath([$dir]);
628  
629 # The deploy group carries no modules in DBIO (native Deploy, no
630 # SQL::Translator), so req_missing_for() is illustrated below with a group
631 # that does declare a versioned requirement.
632 0 ▶ my $example_ver = $class->req_list_for ('admin_script')->{'Text::CSV'}
Branch: 1 branch
BranchTrueFalseTotal
my $example_ver = $class->req_list_for("admin_script")->{"Text::CSV"} or die "Hrmm? No Text::CSV dep?" 0 0 0
633 or die "Hrmm? No Text::CSV dep?";
634  
635 0 my @chunks = (
636 <<"EOC",
637 #########################################################################
638 ##################### A U T O G E N E R A T E D ########################
639 #########################################################################
640 #
641 # The contents of this POD file are auto-generated. Any changes you make
642 # will be lost. If you need to change the generated text edit _gen_pod()
643 # at the end of $modfn
644 #
645 EOC
646 '=head1 NAME',
647 "$class - Optional module dependency specifications (for module authors)",
648 '=head1 SYNOPSIS',
649 <<"EOS",
650 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
651  
652 ...
653  
654 configure_requires 'DBIO' => '$distver';
655  
656 require $class;
657  
658 my \$deploy_deps = $class->req_list_for('deploy');
659  
660 for (keys %\$deploy_deps) {
661 requires \$_ => \$deploy_deps->{\$_};
662 }
663  
664 ...
665  
666 Note that there are some caveats regarding C<configure_requires()>, more info
667 can be found at L<Module::Install/configure_requires>
668 EOS
669 '=head1 DESCRIPTION',
670 <<'EOD',
671 Some of the less-frequently used features of L<DBIO> have external
672 module dependencies on their own. In order not to burden the average user
673 with modules he will never use, these optional dependencies are not included
674 in the base Makefile.PL. Instead an exception with a descriptive message is
675 thrown when a specific feature is missing one or several modules required for
676 its operation. This module is the central holding place for the current list
677 of such dependencies, for DBIO core authors, and DBIO extension
678 authors alike.
679 EOD
680 '=head1 CURRENT REQUIREMENT GROUPS',
681 <<'EOD',
682 Dependencies are organized in C<groups> and each group can list one or more
683 required modules, with an optional minimum version (or 0 for any version).
684 The group name can be used in the
685 EOD
686 );
687  
688 0 for my $group (sort keys %$reqs) {
689 my $p = $reqs->{$group}{pod}
690 0 ▶ or next;
Branch: 1 branch
BranchTrueFalseTotal
my $p = $reqs->{$group}{"pod"} or next 0 0 0
691  
692 my $modlist = $reqs->{$group}{req}
693 0 ▶ or next;
Branch: 1 branch
BranchTrueFalseTotal
my $modlist = $reqs->{$group}{"req"} or next 0 0 0
694  
695 0 ▶ next unless keys %$modlist;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$modlist 0 0 0
696  
697 push @chunks, (
698 "=head2 $p->{title}",
699 "$p->{desc}",
700 '=over',
701 0 ▶ ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
Branch: 1 branch
BranchTrueFalseTotal
$modlist->{$_} ? : 0 0 0
702 '=back',
703 "Requirement group: B<$group>",
704 );
705 }
706  
707 0 push @chunks, (
708 '=head1 METHODS',
709 '=head2 req_group_list',
710 '=over',
711 '=item Arguments: none',
712 '=item Return Value: \%list_of_requirement_groups',
713 '=back',
714 <<'EOD',
715 This method should be used by DBIO packagers, to get a hashref of all
716 dependencies keyed by dependency group. Each key (group name) can be supplied
717 to one of the group-specific methods below.
718 EOD
719  
720 '=head2 req_list_for',
721 '=over',
722 '=item Arguments: $group_name',
723 '=item Return Value: \%list_of_module_version_pairs',
724 '=back',
725 <<'EOD',
726 This method should be used by DBIO extension authors, to determine the
727 version of modules a specific feature requires in the B<current> version of
728 DBIO. See the L</SYNOPSIS> for a real-world
729 example.
730 EOD
731  
732 '=head2 req_ok_for',
733 '=over',
734 '=item Arguments: $group_name',
735 '=item Return Value: 1|0',
736 '=back',
737 <<'EOD',
738 Returns true or false depending on whether all modules required by
739 C<$group_name> are present on the system and loadable.
740 EOD
741  
742 '=head2 req_missing_for',
743 '=over',
744 '=item Arguments: $group_name',
745 '=item Return Value: $error_message_string',
746 '=back',
747 <<"EOD",
748 Returns a single line string suitable for inclusion in larger error messages.
749 This method would normally be used by DBIO core-module author, to
750 indicate to the user that he needs to install specific modules before he will
751 be able to use a specific feature.
752  
753 For example if some of the requirements for C<admin_script> are not available,
754 the returned string could look like:
755  
756 Text::CSV >= $example_ver (see $class for details)
757  
758 The author is expected to prepend the necessary text to this message before
759 returning the actual error seen by the user.
760 EOD
761  
762 '=head2 die_unless_req_ok_for',
763 '=over',
764 '=item Arguments: $group_name',
765 '=back',
766 <<'EOD',
767 Checks if L</req_ok_for> passes for the supplied C<$group_name>, and
768 in case of failure throws an exception including the information
769 from L</req_missing_for>.
770 EOD
771  
772 '=head2 req_errorlist_for',
773 '=over',
774 '=item Arguments: $group_name',
775 '=item Return Value: \%list_of_loaderrors_per_module',
776 '=back',
777 <<'EOD',
778 Returns a hashref containing the actual errors that occurred while attempting
779 to load each module in the requirement group.
780 EOD
781 );
782  
783 0 ▶ open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $podfn or Carp::croak("Unable to write to ${podfn}: $!") 0 0 0
784 0 print $fh join ("\n\n", @chunks);
785 0 print $fh "\n";
786 0 close ($fh);
787 }
788  
789 392 1;
790  
791 __END__
« blib/lib/DBIO/Storage/QueryRewrite.pm ↑ Summary blib/lib/DBIO/Relationship/Base.pm »