typo fixes
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Optional / Dependencies.pm
CommitLineData
8057ed01 1package DBIx::Class::Optional::Dependencies;
2
3use warnings;
4use strict;
5
9c1700e3 6use Carp ();
fb39747c 7
8# NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G)
8057ed01 9# This module is to be loaded by Makefile.PM on a pristine system
10
f6b26571 11# POD is generated automatically by calling _gen_pod from the
12# Makefile.PL in $AUTHOR mode
13
2a2a7b23 14my $json_any = {
15 'JSON::Any' => '1.22',
16};
17
2b48ebff 18my $moose_basic = {
68de9438 19 'Moose' => '0.98',
20 'MooseX::Types' => '0.21',
21};
22
23my $replicated = {
24 %$moose_basic,
2b48ebff 25};
26
ebcd0e4f 27my $admin_basic = {
28 %$moose_basic,
2a2a7b23 29 %$json_any,
68de9438 30 'MooseX::Types::Path::Class' => '0.05',
31 'MooseX::Types::JSON' => '0.02',
68de9438 32 'namespace::autoclean' => '0.09',
33};
34
a0361822 35my $admin_script = {
36 %$moose_basic,
37 %$admin_basic,
38 'Getopt::Long::Descriptive' => '0.081',
39 'Text::CSV' => '1.16',
40};
41
68de9438 42my $datetime_basic = {
43 'DateTime' => '0.55',
44 'DateTime::Format::Strptime' => '1.2',
ebcd0e4f 45};
46
c7d50a7d 47my $id_shortener = {
26022fb5 48 'Math::BigInt' => '1.80',
c7d50a7d 49 'Math::Base36' => '0.07',
50};
51
be68095d 52my $rdbms_sqlite = {
53 'DBD::SQLite' => '0',
54};
55my $rdbms_pg = {
56 'DBD::Pg' => '0',
57};
58my $rdbms_mssql_odbc = {
59 'DBD::ODBC' => '0',
60};
61my $rdbms_mssql_sybase = {
62 'DBD::Sybase' => '0',
63};
56dca25f 64my $rdbms_mssql_ado = {
65 'DBD::ADO' => '0',
66};
726c8f65 67my $rdbms_msaccess_odbc = {
68 'DBD::ODBC' => '0',
69};
70my $rdbms_msaccess_ado = {
71 'DBD::ADO' => '0',
72};
be68095d 73my $rdbms_mysql = {
74 'DBD::mysql' => '0',
75};
76my $rdbms_oracle = {
77 'DBD::Oracle' => '0',
78 %$id_shortener,
79};
80my $rdbms_ase = {
81 'DBD::Sybase' => '0',
82};
83my $rdbms_db2 = {
84 'DBD::DB2' => '0',
85};
199fbc45 86my $rdbms_db2_400 = {
87 'DBD::ODBC' => '0',
88};
89my $rdbms_informix = {
90 'DBD::Informix' => '0',
91};
92my $rdbms_sqlanywhere = {
93 'DBD::SQLAnywhere' => '0',
94};
95my $rdbms_sqlanywhere_odbc = {
96 'DBD::ODBC' => '0',
97};
98my $rdbms_firebird = {
99 'DBD::Firebird' => '0',
100};
101my $rdbms_firebird_interbase = {
102 'DBD::InterBase' => '0',
103};
e02b39b4 104my $rdbms_firebird_odbc = {
105 'DBD::ODBC' => '0',
106};
be68095d 107
8057ed01 108my $reqs = {
8057ed01 109 replicated => {
68de9438 110 req => $replicated,
f6b26571 111 pod => {
112 title => 'Storage::Replicated',
113 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
114 },
8057ed01 115 },
116
68de9438 117 test_replicated => {
118 req => {
119 %$replicated,
120 'Test::Moose' => '0',
121 },
122 },
123
124
8057ed01 125 admin => {
2b48ebff 126 req => {
ebcd0e4f 127 %$admin_basic,
128 },
129 pod => {
130 title => 'DBIx::Class::Admin',
131 desc => 'Modules required for the DBIx::Class administrative library',
132 },
133 },
134
a4a02f15 135 admin_script => {
ebcd0e4f 136 req => {
a0361822 137 %$admin_script,
2b48ebff 138 },
e144415f 139 pod => {
140 title => 'dbicadmin',
141 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
142 },
8057ed01 143 },
144
145 deploy => {
f6b26571 146 req => {
7536c92b 147 'SQL::Translator' => '0.11016',
f6b26571 148 },
149 pod => {
150 title => 'Storage::DBI::deploy()',
c7d50a7d 151 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deployment_statements>',
f6b26571 152 },
8057ed01 153 },
154
c7d50a7d 155 id_shortener => {
156 req => $id_shortener,
157 },
158
0d374214 159 test_component_accessor => {
160 req => {
161 'Class::Unload' => '0.07',
162 },
163 },
164
a109c954 165 test_pod => {
f6b26571 166 req => {
cbb19edf 167 'Test::Pod' => '1.42',
a109c954 168 },
169 },
170
171 test_podcoverage => {
172 req => {
f6b26571 173 'Test::Pod::Coverage' => '1.08',
174 'Pod::Coverage' => '0.20',
a109c954 175 },
176 },
177
ffce4b65 178 test_whitespace => {
a109c954 179 req => {
8273e845 180 'Test::EOL' => '1.0',
ffce4b65 181 'Test::NoTabs' => '0.9',
f6b26571 182 },
8057ed01 183 },
184
4a233f30 185 test_strictures => {
186 req => {
b2c1212f 187 'Test::Strict' => '0.20',
4a233f30 188 },
189 },
190
2a2a7b23 191 test_prettydebug => {
192 req => $json_any,
193 },
194
99503754 195 test_admin_script => {
196 req => {
197 %$admin_script,
198 'JSON' => 0,
199 'JSON::XS' => 0,
200 $^O eq 'MSWin32'
201 # for t/admin/10script.t
202 ? ('Win32::ShellQuote' => 0)
203 # DWIW does not compile (./configure even) on win32
204 : ('JSON::DWIW' => 0 )
205 ,
206 }
207 },
208
226d1c35 209 test_leaks => {
f6b26571 210 req => {
f6b26571 211 'Test::Memory::Cycle' => '0',
212 'Devel::Cycle' => '1.10',
a109c954 213 },
214 },
f6b26571 215
68de9438 216 test_dt => {
217 req => $datetime_basic,
218 },
219
220 test_dt_sqlite => {
a109c954 221 req => {
68de9438 222 %$datetime_basic,
f6b26571 223 # t/36datetime.t
224 # t/60core.t
225 'DateTime::Format::SQLite' => '0',
68de9438 226 },
227 },
f6b26571 228
68de9438 229 test_dt_mysql => {
230 req => {
231 %$datetime_basic,
9c92bb1c 232 # t/inflate/datetime_mysql.t
233 # (doesn't need Mysql itself)
68de9438 234 'DateTime::Format::MySQL' => '0',
235 },
236 },
9c92bb1c 237
68de9438 238 test_dt_pg => {
239 req => {
240 %$datetime_basic,
9c92bb1c 241 # t/inflate/datetime_pg.t
242 # (doesn't need PG itself)
ab35aeab 243 'DateTime::Format::Pg' => '0.16004',
f6b26571 244 },
8057ed01 245 },
246
68de9438 247 test_cdbicompat => {
f6b26571 248 req => {
f6b26571 249 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
d9bd5195 250 %$datetime_basic,
f6b26571 251 'Time::Piece::MySQL' => '0',
f6b26571 252 'Date::Simple' => '3.03',
253 },
8057ed01 254 },
255
be68095d 256 # this is just for completeness as SQLite
257 # is a core dep of DBIC for testing
258 rdbms_sqlite => {
259 req => {
260 %$rdbms_sqlite,
261 },
262 pod => {
263 title => 'SQLite support',
264 desc => 'Modules required to connect to SQLite',
265 },
266 },
267
268 rdbms_pg => {
269 req => {
a4fc1239 270 # when changing this list make sure to adjust xt/optional_deps.t
be68095d 271 %$rdbms_pg,
272 },
273 pod => {
274 title => 'PostgreSQL support',
275 desc => 'Modules required to connect to PostgreSQL',
276 },
277 },
278
279 rdbms_mssql_odbc => {
280 req => {
281 %$rdbms_mssql_odbc,
282 },
283 pod => {
284 title => 'MSSQL support via DBD::ODBC',
285 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
286 },
287 },
288
289 rdbms_mssql_sybase => {
290 req => {
291 %$rdbms_mssql_sybase,
292 },
293 pod => {
294 title => 'MSSQL support via DBD::Sybase',
56dca25f 295 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
296 },
297 },
298
299 rdbms_mssql_ado => {
300 req => {
301 %$rdbms_mssql_ado,
302 },
303 pod => {
304 title => 'MSSQL support via DBD::ADO (Windows only)',
305 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
be68095d 306 },
307 },
308
726c8f65 309 rdbms_msaccess_odbc => {
310 req => {
311 %$rdbms_msaccess_odbc,
312 },
313 pod => {
314 title => 'MS Access support via DBD::ODBC',
315 desc => 'Modules required to connect to MS Access via DBD::ODBC',
316 },
317 },
318
319 rdbms_msaccess_ado => {
320 req => {
321 %$rdbms_msaccess_ado,
322 },
323 pod => {
324 title => 'MS Access support via DBD::ADO (Windows only)',
325 desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
326 },
327 },
328
be68095d 329 rdbms_mysql => {
330 req => {
331 %$rdbms_mysql,
332 },
333 pod => {
334 title => 'MySQL support',
335 desc => 'Modules required to connect to MySQL',
336 },
337 },
338
339 rdbms_oracle => {
340 req => {
341 %$rdbms_oracle,
342 },
343 pod => {
344 title => 'Oracle support',
345 desc => 'Modules required to connect to Oracle',
346 },
347 },
348
349 rdbms_ase => {
350 req => {
351 %$rdbms_ase,
352 },
353 pod => {
354 title => 'Sybase ASE support',
355 desc => 'Modules required to connect to Sybase ASE',
356 },
357 },
358
359 rdbms_db2 => {
360 req => {
361 %$rdbms_db2,
362 },
363 pod => {
364 title => 'DB2 support',
365 desc => 'Modules required to connect to DB2',
366 },
367 },
368
199fbc45 369 rdbms_db2_400 => {
370 req => {
371 %$rdbms_db2_400,
372 },
373 pod => {
374 title => 'DB2 on AS/400 support',
375 desc => 'Modules required to connect to DB2 on AS/400',
376 },
377 },
378
379 rdbms_informix => {
380 req => {
381 %$rdbms_informix,
382 },
383 pod => {
384 title => 'Informix support',
385 desc => 'Modules required to connect to Informix',
386 },
8273e845 387 },
199fbc45 388
389 rdbms_sqlanywhere => {
390 req => {
391 %$rdbms_sqlanywhere,
392 },
393 pod => {
394 title => 'SQLAnywhere support',
395 desc => 'Modules required to connect to SQLAnywhere',
396 },
8273e845 397 },
199fbc45 398
399 rdbms_sqlanywhere_odbc => {
400 req => {
401 %$rdbms_sqlanywhere_odbc,
402 },
403 pod => {
404 title => 'SQLAnywhere support via DBD::ODBC',
405 desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
406 },
8273e845 407 },
199fbc45 408
409 rdbms_firebird => {
410 req => {
411 %$rdbms_firebird,
412 },
413 pod => {
414 title => 'Firebird support',
415 desc => 'Modules required to connect to Firebird',
416 },
8273e845 417 },
199fbc45 418
419 rdbms_firebird_interbase => {
420 req => {
421 %$rdbms_firebird_interbase,
422 },
423 pod => {
424 title => 'Firebird support via DBD::InterBase',
425 desc => 'Modules required to connect to Firebird via DBD::InterBase',
426 },
8273e845 427 },
199fbc45 428
429 rdbms_firebird_odbc => {
430 req => {
431 %$rdbms_firebird_odbc,
432 },
433 pod => {
434 title => 'Firebird support via DBD::ODBC',
435 desc => 'Modules required to connect to Firebird via DBD::ODBC',
436 },
8273e845 437 },
199fbc45 438
be68095d 439# the order does matter because the rdbms support group might require
440# a different version that the test group
68de9438 441 test_rdbms_pg => {
f6b26571 442 req => {
443 $ENV{DBICTEST_PG_DSN}
444 ? (
a4fc1239 445 # when changing this list make sure to adjust xt/optional_deps.t
be68095d 446 %$rdbms_pg,
b9d84a2d 447 ($^O ne 'MSWin32' ? ('Sys::SigAction' => '0') : ()),
f6b26571 448 'DBD::Pg' => '2.009002',
f6b26571 449 ) : ()
450 },
8057ed01 451 },
452
afae8507 453 test_rdbms_mssql_odbc => {
454 req => {
455 $ENV{DBICTEST_MSSQL_ODBC_DSN}
456 ? (
be68095d 457 %$rdbms_mssql_odbc,
afae8507 458 ) : ()
459 },
460 },
461
56dca25f 462 test_rdbms_mssql_ado => {
463 req => {
464 $ENV{DBICTEST_MSSQL_ADO_DSN}
465 ? (
466 %$rdbms_mssql_ado,
467 ) : ()
468 },
469 },
470
afae8507 471 test_rdbms_mssql_sybase => {
472 req => {
473 $ENV{DBICTEST_MSSQL_DSN}
474 ? (
be68095d 475 %$rdbms_mssql_sybase,
afae8507 476 ) : ()
477 },
478 },
479
726c8f65 480 test_rdbms_msaccess_odbc => {
481 req => {
482 $ENV{DBICTEST_MSACCESS_ODBC_DSN}
483 ? (
484 %$rdbms_msaccess_odbc,
485 %$datetime_basic,
486 'Data::GUID' => '0',
487 ) : ()
488 },
489 },
490
491 test_rdbms_msaccess_ado => {
492 req => {
493 $ENV{DBICTEST_MSACCESS_ADO_DSN}
494 ? (
495 %$rdbms_msaccess_ado,
496 %$datetime_basic,
497 'Data::GUID' => 0,
498 ) : ()
499 },
500 },
501
68de9438 502 test_rdbms_mysql => {
f6b26571 503 req => {
504 $ENV{DBICTEST_MYSQL_DSN}
505 ? (
be68095d 506 %$rdbms_mysql,
f6b26571 507 ) : ()
508 },
8057ed01 509 },
510
68de9438 511 test_rdbms_oracle => {
f6b26571 512 req => {
513 $ENV{DBICTEST_ORA_DSN}
514 ? (
be68095d 515 %$rdbms_oracle,
f6b26571 516 'DateTime::Format::Oracle' => '0',
e1b7e9b4 517 'DBD::Oracle' => '1.24',
f6b26571 518 ) : ()
519 },
8057ed01 520 },
521
68de9438 522 test_rdbms_ase => {
f6b26571 523 req => {
524 $ENV{DBICTEST_SYBASE_DSN}
525 ? (
be68095d 526 %$rdbms_ase,
f6b26571 527 ) : ()
528 },
8057ed01 529 },
530
68de9438 531 test_rdbms_db2 => {
f58a165c 532 req => {
533 $ENV{DBICTEST_DB2_DSN}
534 ? (
be68095d 535 %$rdbms_db2,
f58a165c 536 ) : ()
537 },
538 },
539
199fbc45 540 test_rdbms_db2_400 => {
541 req => {
542 $ENV{DBICTEST_DB2_400_DSN}
543 ? (
544 %$rdbms_db2_400,
545 ) : ()
546 },
547 },
548
549 test_rdbms_informix => {
550 req => {
551 $ENV{DBICTEST_INFORMIX_DSN}
552 ? (
553 %$rdbms_informix,
554 ) : ()
555 },
556 },
557
558 test_rdbms_sqlanywhere => {
559 req => {
560 $ENV{DBICTEST_SQLANYWHERE_DSN}
561 ? (
562 %$rdbms_sqlanywhere,
563 ) : ()
564 },
565 },
566
567 test_rdbms_sqlanywhere_odbc => {
568 req => {
569 $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
570 ? (
571 %$rdbms_sqlanywhere_odbc,
572 ) : ()
573 },
574 },
575
576 test_rdbms_firebird => {
577 req => {
578 $ENV{DBICTEST_FIREBIRD_DSN}
579 ? (
580 %$rdbms_firebird,
581 ) : ()
582 },
583 },
584
585 test_rdbms_firebird_interbase => {
586 req => {
587 $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN}
588 ? (
589 %$rdbms_firebird_interbase,
590 ) : ()
591 },
592 },
593
e02b39b4 594 test_rdbms_firebird_odbc => {
595 req => {
596 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
597 ? (
598 %$rdbms_firebird_odbc,
599 ) : ()
600 },
601 },
602
42168332 603 test_memcached => {
604 req => {
605 $ENV{DBICTEST_MEMCACHED}
606 ? (
607 'Cache::Memcached' => 0,
608 ) : ()
609 },
610 },
611
344f1f52 612 dist_dir => {
613 req => {
b81d8515 614 'ExtUtils::MakeMaker' => '6.64',
615 'Pod::Inherit' => '0.90',
616 'Pod::Tree' => '0',
344f1f52 617 }
618 },
619
620 dist_upload => {
621 req => {
622 'CPAN::Uploader' => '0.103001',
623 },
624 },
625
8057ed01 626};
627
344f1f52 628our %req_availability_cache;
f6b26571 629
fb39747c 630sub req_list_for {
631 my ($class, $group) = @_;
632
9c1700e3 633 Carp::croak "req_list_for() expects a requirement group name"
fb39747c 634 unless $group;
635
f6b26571 636 my $deps = $reqs->{$group}{req}
9c1700e3 637 or Carp::croak "Requirement group '$group' does not exist";
fb39747c 638
639 return { %$deps };
640}
641
642
344f1f52 643sub die_unless_req_ok_for {
644 my ($class, $group) = @_;
645
646 Carp::croak "die_unless_req_ok_for() expects a requirement group name"
647 unless $group;
648
649 $class->_check_deps($group)->{status}
650 or die sprintf( "Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{missing} );
651}
652
fb39747c 653sub req_ok_for {
654 my ($class, $group) = @_;
655
9c1700e3 656 Carp::croak "req_ok_for() expects a requirement group name"
fb39747c 657 unless $group;
658
d8799bab 659 return $class->_check_deps($group)->{status};
fb39747c 660}
661
662sub req_missing_for {
663 my ($class, $group) = @_;
664
9c1700e3 665 Carp::croak "req_missing_for() expects a requirement group name"
fb39747c 666 unless $group;
667
d8799bab 668 return $class->_check_deps($group)->{missing};
fb39747c 669}
670
671sub req_errorlist_for {
672 my ($class, $group) = @_;
673
9c1700e3 674 Carp::croak "req_errorlist_for() expects a requirement group name"
fb39747c 675 unless $group;
676
d8799bab 677 return $class->_check_deps($group)->{errorlist};
fb39747c 678}
679
680sub _check_deps {
681 my ($class, $group) = @_;
682
d8799bab 683 return $req_availability_cache{$group} ||= do {
684
685 my $deps = $class->req_list_for ($group);
686
687 my %errors;
688 for my $mod (keys %$deps) {
689 my $req_line = "require $mod;";
690 if (my $ver = $deps->{$mod}) {
691 $req_line .= "$mod->VERSION($ver);";
692 }
693
694 eval $req_line;
695
696 $errors{$mod} = $@ if $@;
697 }
698
699 my $res;
fb39747c 700
d8799bab 701 if (keys %errors) {
702 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
703 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
704 $res = {
705 status => 0,
706 errorlist => \%errors,
707 missing => $missing,
708 };
fb39747c 709 }
710 else {
d8799bab 711 $res = {
712 status => 1,
713 errorlist => {},
714 missing => '',
715 };
fb39747c 716 }
717
d8799bab 718 $res;
719 };
fb39747c 720}
721
e3fc11e1 722sub req_group_list {
723 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
724}
725
726# This is to be called by the author only (automatically in Makefile.PL)
f6b26571 727sub _gen_pod {
47589465 728 my ($class, $distver, $pod_dir) = @_;
31fa1764 729
47589465 730 die "No POD root dir supplied" unless $pod_dir;
31fa1764 731
ccebe1f1 732 $distver ||=
31fa1764 733 eval { require DBIx::Class; DBIx::Class->VERSION; }
734 ||
ccebe1f1 735 die
31fa1764 736"\n\n---------------------------------------------------------------------\n" .
737'Unable to load core DBIx::Class module to determine current version, '.
738'possibly due to missing dependencies. Author-mode autodocumentation ' .
739"halted\n\n" . $@ .
740"\n\n---------------------------------------------------------------------\n"
31fa1764 741 ;
742
3d4c5a84 743 # do not ask for a recent version, use 1.x API calls
47589465 744 # this *may* execute on a smoker with old perl or whatnot
745 require File::Path;
746
747 (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
748
749 (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
750 (my $dir = $podfn) =~ s|/[^/]+$||;
751
752 File::Path::mkpath([$dir]);
753
e3fc11e1 754 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
755 or die "Hrmm? No sqlt dep?";
7e3dc46f 756
f6b26571 757 my @chunks = (
6343a203 758 <<"EOC",
af4ac504 759#########################################################################
760##################### A U T O G E N E R A T E D ########################
761#########################################################################
762#
763# The contents of this POD file are auto-generated. Any changes you make
764# will be lost. If you need to change the generated text edit _gen_pod()
765# at the end of $modfn
766#
767EOC
f6b26571 768 '=head1 NAME',
7e3dc46f 769 "$class - Optional module dependency specifications (for module authors)",
e3fc11e1 770 '=head1 SYNOPSIS',
d8799bab 771 <<"EOS",
7e3dc46f 772Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
773
774 ...
775
776 configure_requires 'DBIx::Class' => '$distver';
777
778 require $class;
779
be68095d 780 my \$deploy_deps = $class->req_list_for('deploy');
7e3dc46f 781
782 for (keys %\$deploy_deps) {
783 requires \$_ => \$deploy_deps->{\$_};
784 }
785
786 ...
787
788Note that there are some caveats regarding C<configure_requires()>, more info
789can be found at L<Module::Install/configure_requires>
790EOS
f6b26571 791 '=head1 DESCRIPTION',
792 <<'EOD',
793Some of the less-frequently used features of L<DBIx::Class> have external
794module dependencies on their own. In order not to burden the average user
795with modules he will never use, these optional dependencies are not included
796in the base Makefile.PL. Instead an exception with a descriptive message is
797thrown when a specific feature is missing one or several modules required for
798its operation. This module is the central holding place for the current list
7e3dc46f 799of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
800authors alike.
f6b26571 801EOD
802 '=head1 CURRENT REQUIREMENT GROUPS',
803 <<'EOD',
804Dependencies are organized in C<groups> and each group can list one or more
805required modules, with an optional minimum version (or 0 for any version).
ecb68746 806The group name can be used in the
f6b26571 807EOD
808 );
809
810 for my $group (sort keys %$reqs) {
811 my $p = $reqs->{$group}{pod}
812 or next;
813
814 my $modlist = $reqs->{$group}{req}
815 or next;
816
817 next unless keys %$modlist;
818
819 push @chunks, (
820 "=head2 $p->{title}",
821 "$p->{desc}",
822 '=over',
823 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
824 '=back',
825 "Requirement group: B<$group>",
826 );
827 }
828
829 push @chunks, (
830 '=head1 METHODS',
e3fc11e1 831 '=head2 req_group_list',
832 '=over',
d8799bab 833 '=item Arguments: none',
fb13a49f 834 '=item Return Value: \%list_of_requirement_groups',
e3fc11e1 835 '=back',
d8799bab 836 <<'EOD',
e3fc11e1 837This method should be used by DBIx::Class packagers, to get a hashref of all
838dependencies keyed by dependency group. Each key (group name) can be supplied
839to one of the group-specific methods below.
840EOD
841
f6b26571 842 '=head2 req_list_for',
843 '=over',
844 '=item Arguments: $group_name',
fb13a49f 845 '=item Return Value: \%list_of_module_version_pairs',
f6b26571 846 '=back',
d8799bab 847 <<'EOD',
f6b26571 848This method should be used by DBIx::Class extension authors, to determine the
7e3dc46f 849version of modules a specific feature requires in the B<current> version of
e3fc11e1 850DBIx::Class. See the L</SYNOPSIS> for a real-world
7e3dc46f 851example.
f6b26571 852EOD
853
854 '=head2 req_ok_for',
855 '=over',
856 '=item Arguments: $group_name',
fb13a49f 857 '=item Return Value: 1|0',
f6b26571 858 '=back',
d8799bab 859 <<'EOD',
860Returns true or false depending on whether all modules required by
861C<$group_name> are present on the system and loadable.
862EOD
f6b26571 863
864 '=head2 req_missing_for',
865 '=over',
866 '=item Arguments: $group_name',
fb13a49f 867 '=item Return Value: $error_message_string',
f6b26571 868 '=back',
d8799bab 869 <<"EOD",
f6b26571 870Returns a single line string suitable for inclusion in larger error messages.
871This method would normally be used by DBIx::Class core-module author, to
872indicate to the user that he needs to install specific modules before he will
873be able to use a specific feature.
874
e3fc11e1 875For example if some of the requirements for C<deploy> are not available,
876the returned string could look like:
f6b26571 877
e3fc11e1 878 SQL::Translator >= $sqltver (see $class for details)
f6b26571 879
880The author is expected to prepend the necessary text to this message before
881returning the actual error seen by the user.
882EOD
883
344f1f52 884 '=head2 die_unless_req_ok_for',
885 '=over',
886 '=item Arguments: $group_name',
887 '=back',
888 <<'EOD',
889Checks if L</req_ok_for> passes for the supplied C<$group_name>, and
890in case of failure throws an exception including the information
891from L</req_missing_for>.
892EOD
893
f6b26571 894 '=head2 req_errorlist_for',
895 '=over',
896 '=item Arguments: $group_name',
fb13a49f 897 '=item Return Value: \%list_of_loaderrors_per_module',
f6b26571 898 '=back',
899 <<'EOD',
4a0eed52 900Returns a hashref containing the actual errors that occurred while attempting
f6b26571 901to load each module in the requirement group.
902EOD
fb8ae353 903 '=head1 AUTHOR',
904 'See L<DBIx::Class/CONTRIBUTORS>.',
905 '=head1 LICENSE',
906 'You may distribute this code under the same terms as Perl itself',
f6b26571 907 );
908
9c1700e3 909 open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!";
f6b26571 910 print $fh join ("\n\n", @chunks);
47589465 911 print $fh "\n";
f6b26571 912 close ($fh);
913}
914
8057ed01 9151;