1 package DBIx::Class::Schema::Loader::Optional::Dependencies;
3 ### This may look crazy, but it in fact tangibly ( by 50(!)% ) shortens
4 # the skip-test time when everything requested is unavailable
6 if ( $ENV{RELEASE_TESTING} ) {
7 require warnings and warnings->import;
8 require strict and strict->import;
18 # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G)
19 # This module is to be loaded by Makefile.PM on a pristine system
21 # POD is generated automatically by calling _gen_pod from the
22 # Makefile.PL in $AUTHOR mode
29 'MooseX::NonMoose' => '0.25',
30 'namespace::autoclean' => '0.09',
31 'MooseX::MarkAsMethods' => '0.13',
35 desc => 'Modules required for the use_moose option',
42 'namespace::autoclean' => '0.16',
46 desc => 'Modules required for the use_moo option',
55 title => 'dbicdump config file',
56 desc => 'Modules required for using a config file with dbicdump',
60 test_dbicdump_config => {
61 include => 'dbicdump_config',
63 'Config::General' => '0',
66 title => 'dbicdump config file testing',
67 desc => 'Modules required for using testing using a config file with dbicdump',
71 _rdbms_generic_odbc => {
77 _rdbms_generic_ado => {
83 # must list any dep used by adhoc testing
84 # this prevents the "skips due to forgotten deps" issue
92 'Math::BigInt' => '1.80',
93 'Math::Base36' => '0.07',
99 'Test::Pod' => '1.14',
100 'Pod::Simple' => '3.22',
103 title => 'POD testing',
104 desc => 'Modules required for testing POD in this distribution',
106 release_testing_mandatory => 1,
109 test_podcoverage => {
111 'Test::Pod::Coverage' => '1.08',
112 'Pod::Coverage' => '0.20',
114 release_testing_mandatory => 1,
119 'Test::EOL' => '1.0',
120 'Test::NoTabs' => '0.9',
122 release_testing_mandatory => 1,
127 'Test::Strict' => '0.20',
129 release_testing_mandatory => 1,
134 SCHEMA_LOADER_TESTS_BACKCOMPAT => 1,
138 # this is just for completeness as SQLite
139 # is a core dep of DBIC for testing
145 title => 'SQLite support',
146 desc => 'Modules required to connect to SQLite',
154 # when changing this list make sure to adjust xt/optional_deps.t
158 title => 'PostgreSQL support',
159 desc => 'Modules required to connect to PostgreSQL',
163 _rdbms_mssql_common => {
166 rdbms_mssql_odbc => {
167 include => [qw( _rdbms_generic_odbc _rdbms_mssql_common )],
169 title => 'MSSQL support via DBD::ODBC',
170 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
174 rdbms_mssql_sybase => {
175 include => '_rdbms_mssql_common',
180 title => 'MSSQL support via DBD::Sybase',
181 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
186 include => [qw( _rdbms_generic_ado _rdbms_mssql_common )],
188 title => 'MSSQL support via DBD::ADO (Windows only)',
189 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
193 _rdbms_msaccess_common => {
196 rdbms_msaccess_odbc => {
197 include => [qw( _rdbms_generic_odbc _rdbms_msaccess_common )],
199 title => 'MS Access support via DBD::ODBC',
200 desc => 'Modules required to connect to MS Access via DBD::ODBC',
204 rdbms_msaccess_ado => {
205 include => [qw( _rdbms_generic_ado _rdbms_msaccess_common )],
207 title => 'MS Access support via DBD::ADO (Windows only)',
208 desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
217 title => 'MySQL support',
218 desc => 'Modules required to connect to MySQL',
223 include => 'id_shortener',
228 title => 'Oracle support',
229 desc => 'Modules required to connect to Oracle',
240 title => 'Sybase ASE support',
241 desc => 'Modules required to connect to Sybase ASE',
250 title => 'DB2 support',
251 desc => 'Modules required to connect to DB2',
257 'DBD::Informix' => 0,
260 title => 'Informix support',
261 desc => 'Modules required to connect to Informix',
265 _rdbms_sqlanywhere_common => {
268 rdbms_sqlanywhere => {
269 include => '_rdbms_sqlanywhere_common',
271 'DBD::SQLAnywhere' => 0,
274 title => 'SQLAnywhere support',
275 desc => 'Modules required to connect to SQLAnywhere',
279 rdbms_sqlanywhere_odbc => {
280 include => [qw( _rdbms_generic_odbc _rdbms_sqlanywhere_common )],
282 title => 'SQLAnywhere support via DBD::ODBC',
283 desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
287 _rdbms_firebird_common => {
291 include => '_rdbms_firebird_common',
293 'DBD::Firebird' => 0,
296 title => 'Firebird support',
297 desc => 'Modules required to connect to Firebird',
301 rdbms_firebird_interbase => {
302 include => '_rdbms_firebird_common',
304 'DBD::InterBase' => 0,
307 title => 'Firebird support via DBD::InterBase',
308 desc => 'Modules required to connect to Firebird via DBD::InterBase',
312 rdbms_firebird_odbc => {
313 include => [qw( _rdbms_generic_odbc _rdbms_firebird_common )],
315 title => 'Firebird support via DBD::ODBC',
316 desc => 'Modules required to connect to Firebird via DBD::ODBC',
320 test_rdbms_sqlite => {
321 include => 'rdbms_sqlite',
324 ### IMPORTANT - do not raise this dependency
325 ### even though many bugfixes are present in newer versions, the general DBIC
326 ### rule is to bend over backwards for available DBDs (given upgrading them is
327 ### often *not* easy or even possible)
329 'DBD::SQLite' => '1.29',
334 include => 'rdbms_pg',
336 DBICTEST_PG_DSN => 1,
337 DBICTEST_PG_USER => 0,
338 DBICTEST_PG_PASS => 0,
341 # the order does matter because the rdbms support group might require
342 # a different version that the test group
344 # when changing this list make sure to adjust xt/optional_deps.t
345 'DBD::Pg' => '2.009002', # specific version to test bytea
349 test_rdbms_mssql_odbc => {
350 include => 'rdbms_mssql_odbc',
352 DBICTEST_MSSQL_ODBC_DSN => 1,
353 DBICTEST_MSSQL_ODBC_USER => 0,
354 DBICTEST_MSSQL_ODBC_PASS => 0,
358 test_rdbms_mssql_ado => {
359 include => 'rdbms_mssql_ado',
361 DBICTEST_MSSQL_ADO_DSN => 1,
362 DBICTEST_MSSQL_ADO_USER => 0,
363 DBICTEST_MSSQL_ADO_PASS => 0,
367 test_rdbms_mssql_sybase => {
368 include => 'rdbms_mssql_sybase',
370 DBICTEST_MSSQL_DSN => 1,
371 DBICTEST_MSSQL_USER => 0,
372 DBICTEST_MSSQL_PASS => 0,
376 test_rdbms_msaccess_odbc => {
377 include => 'rdbms_msaccess_odbc',
379 DBICTEST_MSACCESS_ODBC_DSN => 1,
380 DBICTEST_MSACCESS_ODBC_USER => 0,
381 DBICTEST_MSACCESS_ODBC_PASS => 0,
388 test_rdbms_msaccess_ado => {
389 include => 'rdbms_msaccess_ado',
391 DBICTEST_MSACCESS_ADO_DSN => 1,
392 DBICTEST_MSACCESS_ADO_USER => 0,
393 DBICTEST_MSACCESS_ADO_PASS => 0,
400 test_rdbms_mysql => {
401 include => 'rdbms_mysql',
403 DBICTEST_MYSQL_DSN => 1,
404 DBICTEST_MYSQL_USER => 0,
405 DBICTEST_MYSQL_PASS => 0,
409 test_rdbms_oracle => {
410 include => 'rdbms_oracle',
412 DBICTEST_ORA_DSN => 1,
413 DBICTEST_ORA_USER => 0,
414 DBICTEST_ORA_PASS => 0,
417 'DBD::Oracle' => '1.24',
422 include => 'rdbms_ase',
424 DBICTEST_SYBASE_DSN => 1,
425 DBICTEST_SYBASE_USER => 0,
426 DBICTEST_SYBASE_PASS => 0,
431 include => 'rdbms_db2',
433 DBICTEST_DB2_DSN => 1,
434 DBICTEST_DB2_USER => 0,
435 DBICTEST_DB2_PASS => 0,
439 test_rdbms_informix => {
440 include => 'rdbms_informix',
442 DBICTEST_INFORMIX_DSN => 1,
443 DBICTEST_INFORMIX_USER => 0,
444 DBICTEST_INFORMIX_PASS => 0,
448 test_rdbms_sqlanywhere => {
449 include => 'rdbms_sqlanywhere',
451 DBICTEST_SQLANYWHERE_DSN => 1,
452 DBICTEST_SQLANYWHERE_USER => 0,
453 DBICTEST_SQLANYWHERE_PASS => 0,
457 test_rdbms_sqlanywhere_odbc => {
458 include => 'rdbms_sqlanywhere_odbc',
460 DBICTEST_SQLANYWHERE_ODBC_DSN => 1,
461 DBICTEST_SQLANYWHERE_ODBC_USER => 0,
462 DBICTEST_SQLANYWHERE_ODBC_PASS => 0,
466 test_rdbms_firebird => {
467 include => 'rdbms_firebird',
469 DBICTEST_FIREBIRD_DSN => 1,
470 DBICTEST_FIREBIRD_USER => 0,
471 DBICTEST_FIREBIRD_PASS => 0,
475 test_rdbms_firebird_interbase => {
476 include => 'rdbms_firebird_interbase',
478 DBICTEST_FIREBIRD_INTERBASE_DSN => 1,
479 DBICTEST_FIREBIRD_INTERBASE_USER => 0,
480 DBICTEST_FIREBIRD_INTERBASE_PASS => 0,
484 test_rdbms_firebird_odbc => {
485 include => 'rdbms_firebird_odbc',
487 DBICTEST_FIREBIRD_ODBC_DSN => 1,
488 DBICTEST_FIREBIRD_ODBC_USER => 0,
489 DBICTEST_FIREBIRD_ODBC_PASS => 0,
506 if ($action eq '-die_without') {
510 eval { $class->die_unless_req_ok_for(\@_); 1 }
513 die "\n$err\n" if $err;
515 elsif ($action eq '-list_missing') {
516 print $class->modreq_missing_for(\@_);
520 elsif ($action eq '-skip_all_without') {
522 # sanity check - make sure ->current_test is 0 and no plan has been declared
526 Test::Builder->new->current_test
528 Test::Builder->new->has_plan
530 } and croak("Unable to invoke -skip_all_without after testing has started");
532 if ( my $missing = $class->req_missing_for(\@_) ) {
534 die ("\nMandatory requirements not satisfied during release-testing: $missing\n\n")
535 if $ENV{RELEASE_TESTING} and $class->_groups_to_reqs(\@_)->{release_testing_mandatory};
537 print "1..0 # SKIP requirements not satisfied: $missing\n";
541 elsif ($action =~ /^-/) {
542 croak "Unknown import-time action '$action'";
545 croak "$class is not an exporter, unable to import '$action'";
553 croak( __PACKAGE__ . " does not implement unimport" );
556 # OO for (mistakenly considered) ease of extensibility, not due to any need to
557 # carry state of any sort. This API is currently used outside, so leave as-is.
558 # FIXME - make sure to not propagate this further if module is extracted as a
559 # standalone library - keep the stupidity to a DBIC-secific shim!
562 shift->_groups_to_reqs(shift)->{effective_modreqs};
565 sub modreq_list_for {
566 shift->_groups_to_reqs(shift)->{modreqs};
571 { $_ => $_[0]->_groups_to_reqs($_) }
572 grep { $_ !~ /^_/ } keys %$dbic_reqs
576 sub req_errorlist_for { shift->modreq_errorlist_for(shift) } # deprecated
577 sub modreq_errorlist_for {
578 my ($self, $groups) = @_;
579 $self->_errorlist_for_modreqs( $self->_groups_to_reqs($groups)->{modreqs} );
583 shift->req_missing_for(shift) ? 0 : 1;
586 sub req_missing_for {
587 my ($self, $groups) = @_;
589 my $reqs = $self->_groups_to_reqs($groups);
591 my $mods_missing = $reqs->{missing_envvars}
592 ? $self->_list_physically_missing_modules( $reqs->{modreqs} )
593 : $self->modreq_missing_for($groups)
599 ! $reqs->{missing_envvars}
602 my @res = $mods_missing || ();
604 push @res, 'the following group(s) of environment variables: ' . join ' and ', sort map
605 { __envvar_group_desc($_) }
606 @{$reqs->{missing_envvars}}
607 if $reqs->{missing_envvars};
610 ( join ' as well as ', @res )
612 ( $reqs->{modreqs_fully_documented} ? " (see @{[ ref $self || $self ]} documentation for details)" : '' ),
616 sub modreq_missing_for {
617 my ($self, $groups) = @_;
619 my $reqs = $self->_groups_to_reqs($groups);
620 my $modreq_errors = $self->_errorlist_for_modreqs($reqs->{modreqs})
624 { $reqs->{modreqs}{$_} ? "$_~$reqs->{modreqs}{$_}" : $_ }
625 sort { lc($a) cmp lc($b) } keys %$modreq_errors
631 my ($self, $groups) = @_;
633 $tb ||= do { local $@; eval { Test::Builder->new } }
634 or croak "Calling skip_without() before loading Test::Builder makes no sense";
636 if ( my $err = $self->req_missing_for($groups) ) {
637 my ($fn, $ln) = (caller(0))[1,2];
638 $tb->skip("block in $fn around line $ln requires $err");
646 sub die_unless_req_ok_for {
647 if (my $err = shift->req_missing_for(shift) ) {
648 die "Unable to continue due to missing requirements: $err\n";
654 ### Private functions
656 # potentially shorten group desc
657 sub __envvar_group_desc {
660 my (@res, $last_prefix);
661 while (my $ev = shift @envs) {
662 my ($pref, $sep, $suff) = split / ([\_\-]) (?= [^\_\-]+ \z )/x, $ev;
664 if ( defined $sep and ($last_prefix||'') eq $pref ) {
665 push @res, "...${sep}${suff}"
671 $last_prefix = $pref if $sep;
677 my $groupname_re = qr/ [a-z_] [0-9_a-z]* /x;
678 my $modname_re = qr/ [A-Z_a-z] [0-9A-Z_a-z]* (?:::[0-9A-Z_a-z]+)* /x;
679 my $modver_re = qr/ [0-9]+ (?: \. [0-9]+ )? /x;
681 # Expand includes from a random group in a specific order:
682 # nonvariable groups first, then their includes, then the variable groups,
683 # then their includes.
684 # This allows reliably marking the rest of the mod reqs as variable (this is
685 # also why variable includes are currently not allowed)
686 sub __expand_includes {
687 my ($groups, $seen) = @_;
689 # !! DIFFERENT !! behavior and return depending on invocation mode
690 # (easier to recurse this way)
691 my $is_toplevel = $seen
696 my ($res_per_type, $missing_envvars);
698 # breadth-first evaluation, with non-variable includes on top
699 for my $g (@$groups) {
701 croak "Invalid requirement group name '$g': only ascii alphanumerics and _ are allowed"
702 if $g !~ qr/ \A $groupname_re \z/x;
704 my $r = $dbic_reqs->{$g}
705 or croak "Requirement group '$g' is not defined";
707 # always do this check *before* the $seen check
708 croak "Group '$g' with variable effective_modreqs can not be specified as an 'include'"
709 if ( $r->{env} and ! $is_toplevel );
711 next if $seen->{$g}++;
713 my $req_type = 'static';
715 if ( my @e = @{$r->{env}||[]} ) {
717 croak "Unexpected 'env' attribute under group '$g' (only allowed in test_* groups)"
718 unless $g =~ /^test_/;
720 croak "Unexpected *odd* list in 'env' under group '$g'"
723 # deconstruct the whole thing
724 my (@group_envnames_list, $some_envs_required, $some_required_missing);
726 push @group_envnames_list, my $envname = shift @e;
728 # env required or not
729 next unless shift @e;
731 $some_envs_required ||= 1;
733 $some_required_missing ||= (
734 ! defined $ENV{$envname}
736 ! length $ENV{$envname}
740 croak "None of the envvars in group '$g' declared as required, making the requirement moot"
741 unless $some_envs_required;
743 if ($some_required_missing) {
744 push @{$missing_envvars->{$g}}, \@group_envnames_list;
745 $req_type = 'variable';
749 push @{$res_per_type->{"base_${req_type}"}}, $g;
751 if (my $i = $dbic_reqs->{$g}{include}) {
752 $i = [ $i ] unless ref $i eq 'ARRAY';
754 croak "Malformed 'include' for group '$g': must be another existing group name or arrayref of existing group names"
757 push @{$res_per_type->{"incs_${req_type}"}}, @$i;
762 @{ $res_per_type->{"base_${_}"} || [] },
763 ( $res_per_type->{"incs_${_}"} ? __expand_includes( $res_per_type->{"incs_${_}"}, $seen ) : () ),
764 } qw(static variable);
766 return ! $is_toplevel ? @ret : do {
769 idx => 1 + keys %$rv,
770 missing_envvars => $missing_envvars->{$_},
772 $rv->{$_}{user_requested} = 1 for @$groups;
778 our %req_unavailability_cache;
780 # this method is just a lister and envvar/metadata checker - it does not try to load anything
781 sub _groups_to_reqs {
782 my ($self, $want) = @_;
784 $want = [ $want || () ]
785 unless ref $want eq 'ARRAY';
787 croak "@{[ (caller(1))[3] ]}() expects a requirement group name or arrayref of group names"
792 modreqs_fully_documented => 1,
796 for my $piece (@$want) {
797 if ($piece =~ qr/ \A $groupname_re \z /x) {
798 push @$groups, $piece;
800 elsif ( my ($mod, $ver) = $piece =~ qr/ \A ($modname_re) \>\= ($modver_re) \z /x ) {
801 croak "Ad hoc module specification lists '$mod' twice"
802 if exists $ret->{modreqs}{$mod};
804 croak "Ad hoc module specification '${mod} >= $ver' (or greater) not listed in the test_adhoc optdep group" if (
805 ! defined $dbic_reqs->{test_adhoc}{req}{$mod}
807 $dbic_reqs->{test_adhoc}{req}{$mod} < $ver
810 $ret->{modreqs}{$mod} = $ver;
811 $ret->{modreqs_fully_documented} = 0;
814 croak "Unsupported argument '$piece' supplied to @{[ (caller(1))[3] ]}()"
818 my $all_groups = __expand_includes($groups);
820 # pre-assemble list of augmentations, perform basic sanity checks
821 # Note that below we *DO NOT* respect the source/target reationship, but
822 # instead always default to augment the "later" group
823 # This is done so that the "stable/variable" boundary keeps working as
826 for my $requesting_group (keys %$all_groups) {
827 if (my $ag = $dbic_reqs->{$requesting_group}{augment}) {
828 for my $target_group (keys %$ag) {
830 croak "Group '$requesting_group' claims to augment a non-existent group '$target_group'"
831 unless $dbic_reqs->{$target_group};
833 croak "Augmentation combined with variable effective_modreqs currently unsupported for group '$requesting_group'"
834 if $dbic_reqs->{$requesting_group}{env};
836 croak "Augmentation of group '$target_group' with variable effective_modreqs unsupported (requested by '$requesting_group')"
837 if $dbic_reqs->{$target_group}{env};
839 if (my @foreign = grep { $_ ne 'req' } keys %{$ag->{$target_group}} ) {
840 croak "Only 'req' augmentations are currently supported (group '$requesting_group' attempts to alter '$foreign[0]' of group '$target_group'";
843 $ret->{augments}{$target_group} = 1;
845 # no augmentation for stuff that hasn't been selected
846 if ( $all_groups->{$target_group} and my $ar = $ag->{$target_group}{req} ) {
847 push @{$augmentations->{
848 ( $all_groups->{$requesting_group}{idx} < $all_groups->{$target_group}{idx} )
857 for my $group (sort { $all_groups->{$a}{idx} <=> $all_groups->{$b}{idx} } keys %$all_groups ) {
859 my $group_reqs = $dbic_reqs->{$group}{req};
862 for my $req_bag ($group_reqs, @{ $augmentations->{$group} || [] } ) {
863 for (keys %$req_bag) {
865 $_ =~ / \A $modname_re \z /x
866 or croak "Requirement '$_' in group '$group' is not a valid module name";
868 # !!!DO NOT CHANGE!!!
869 # remember - version.pm may not be available on the system
870 croak "Requirement '$_' in group '$group' specifies an invalid version '$req_bag->{$_}' (only plain non-underscored floating point decimals are supported)"
871 if ( ($req_bag->{$_}||0) !~ qr/ \A $modver_re \z /x );
875 if (my $e = $all_groups->{$group}{missing_envvars}) {
876 push @{$ret->{missing_envvars}}, @$e;
879 # assemble into the final ret
882 ( $ret->{missing_envvars} ? () : 'effective_modreqs' ),
884 for my $req_bag ($group_reqs, @{ $augmentations->{$group} || [] } ) {
885 for my $mod (keys %$req_bag) {
887 $ret->{$type}{$mod} = $req_bag->{$mod}||0 if (
889 ! exists $ret->{$type}{$mod}
891 # we sanitized the version to be numeric above - we can just -gt it
892 ($req_bag->{$mod}||0) > $ret->{$type}{$mod}
899 $ret->{modreqs_fully_documented} &&= !!$dbic_reqs->{$group}{pod}
900 if $all_groups->{$group}{user_requested};
902 $ret->{release_testing_mandatory} ||= !!$dbic_reqs->{$group}{release_testing_mandatory};
909 # this method tries to find/load specified modreqs and returns a hashref of
910 # module/loaderror pairs for anything that failed
911 sub _errorlist_for_modreqs {
912 # args supposedly already went through _groups_to_reqs and are therefore sanitized
913 # safe to eval at will
914 my ($self, $reqs) = @_;
918 for my $m ( keys %$reqs ) {
921 if (! exists $req_unavailability_cache{$m}{$v} ) {
923 eval( "require $m;" . ( $v ? "$m->VERSION(q($v))" : '' ) );
924 $req_unavailability_cache{$m}{$v} = $@;
927 $ret->{$m} = $req_unavailability_cache{$m}{$v}
928 if $req_unavailability_cache{$m}{$v};
934 # Unlike the above DO NOT try to load anything
935 # This is executed when some needed envvars are not available
936 # which in turn means a module load will never be reached anyway
937 # This is important because some modules (especially DBDs) can be
938 # *really* fickle when a require() is attempted, with pretty confusing
939 # side-effects (especially on windows)
940 sub _list_physically_missing_modules {
941 my ($self, $modreqs) = @_;
943 # in case there is a coderef in @INC there is nothing we can definitively prove
944 # so short circuit directly
945 return '' if grep { length ref $_ } @INC;
947 my @definitely_missing;
948 for my $mod (keys %$modreqs) {
949 (my $fn = $mod . '.pm') =~ s|::|/|g;
951 push @definitely_missing, $mod unless grep
952 # this should work on any combination of slashes
953 { $_ and -d $_ and -f "$_/$fn" and -r "$_/$fn" }
959 { $modreqs->{$_} ? "$_~$modreqs->{$_}" : $_ }
960 sort { lc($a) cmp lc($b) } @definitely_missing
965 # This is to be called by the author only (automatically in Makefile.PL)
967 my ($class, $distver, $pod_dir) = @_;
969 die "No POD root dir supplied" unless $pod_dir;
973 require DBIx::Class::Schema::Loader;
974 DBIx::Class::Schema::Loader->VERSION;
977 "\n\n---------------------------------------------------------------------\n" .
978 'Unable to load core DBIx::Class::Schema::Loader module to determine current version, '.
979 'possibly due to missing dependencies. Author-mode autodocumentation ' .
981 "\n\n---------------------------------------------------------------------\n"
984 # do not ask for a recent version, use 1.x API calls
985 # this *may* execute on a smoker with old perl or whatnot
988 (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
990 (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
991 (my $dir = $podfn) =~ s|/[^/]+$||;
993 File::Path::mkpath([$dir]);
995 my $moosever = $class->req_list_for('use_moose')->{'Moose'}
996 or die "Hrmm? No Moose dep?";
1004 push @chunks, <<"EOC";
1005 #########################################################################
1006 ##################### A U T O G E N E R A T E D ########################
1007 #########################################################################
1009 # The contents of this POD file are auto-generated. Any changes you make
1010 # will be lost. If you need to change the generated text edit _gen_pod()
1011 # at the end of $modfn
1016 $class - Optional module dependency specifications (for module authors)
1021 #@@ SYNOPSIS HEADING
1023 push @chunks, <<"EOC";
1026 Somewhere in your build-file (e.g. L<ExtUtils::MakeMaker>'s F<Makefile.PL>):
1030 \$EUMM_ARGS{CONFIGURE_REQUIRES} = {
1031 \%{ \$EUMM_ARGS{CONFIGURE_REQUIRES} || {} },
1032 'DBIx::Class::Schema::Loader' => '$distver',
1037 my %DBIC_CONFIG_AND_ORACLE_DEPS = %{ eval {
1039 $class->req_list_for([qw( dbicdump_config rdbms_oracle )]);
1042 \$EUMM_ARGS{PREREQ_PM} = {
1043 \%DBIC_CONFIG_AND_ORACLE_DEPS,
1044 \%{ \$EUMM_ARGS{PREREQ_PM} || {} },
1049 ExtUtils::MakeMaker::WriteMakefile(\%EUMM_ARGS);
1051 B<Note>: The C<eval> protection within the example is due to support for
1052 requirements during L<the C<configure> build phase|CPAN::Meta::Spec/Phases>
1053 not being available on a sufficient portion of production installations of
1054 Perl. Robust support for such dependency requirements is available in the
1055 L<CPAN> installer only since version C<1.94_56> first made available for
1056 production with perl version C<5.12>. It is the belief of the current
1057 maintainer that support for requirements during the C<configure> build phase
1058 will not be sufficiently ubiquitous until the B<year 2020> at the earliest,
1059 hence the extra care demonstrated above. It should also be noted that some
1060 3rd party installers (e.g. L<cpanminus|App::cpanminus>) do the right thing
1061 with configure requirements independent from the versions of perl and CPAN
1067 #@@ DESCRIPTION HEADING
1069 push @chunks, <<'EOC';
1072 Some of the less-frequently used features of L<DBIx::Class::Schema::Loader> have external
1073 module dependencies on their own. In order not to burden the average user
1074 with modules they will never use, these optional dependencies are not included
1075 in the base Makefile.PL. Instead an exception with a descriptive message is
1076 thrown when a specific feature can't find one or several modules required for
1077 its operation. This module is the central holding place for the current list
1078 of such dependencies, for DBIx::Class::Schema::Loader core authors, and DBIx::Class::Schema::Loader extension
1081 Dependencies are organized in L<groups|/CURRENT REQUIREMENT GROUPS> where each
1082 group can list one or more required modules, with an optional minimum version
1083 (or 0 for any version). In addition groups prefixed with C<test_> can specify
1084 a set of environment variables, some (or all) of which are marked as required
1085 for the group to be considered by L</req_list_for>
1087 Each group name (or a combination thereof) can be used in the
1088 L<public methods|/METHODS> as described below.
1093 #@@ REQUIREMENT GROUPLIST HEADING
1095 push @chunks, '=head1 CURRENT REQUIREMENT GROUPS';
1097 my $standalone_info;
1099 for my $group (sort keys %$dbic_reqs) {
1101 my $info = $standalone_info->{$group} ||= $class->_groups_to_reqs($group);
1104 $info->{modreqs_fully_documented}
1106 ( $info->{augments} or $info->{modreqs} )
1109 my $p = $dbic_reqs->{$group}{pod};
1112 "=head2 $p->{title}",
1118 if ( keys %{ $info->{modreqs}||{} } ) {
1120 { "=item * $_" . ($info->{modreqs}{$_} ? " >= $info->{modreqs}{$_}" : '') }
1121 ( sort keys %{ $info->{modreqs} } )
1125 push @chunks, '=item * No standalone requirements',
1128 push @chunks, '=back';
1130 for my $ag ( sort keys %{ $info->{augments} || {} } ) {
1131 my $ag_info = $standalone_info->{$ag} ||= $class->_groups_to_reqs($ag);
1133 my $newreqs = $class->modreq_list_for([ $group, $ag ]);
1134 for (keys %$newreqs) {
1135 delete $newreqs->{$_} if (
1136 ( defined $info->{modreqs}{$_} and $info->{modreqs}{$_} == $newreqs->{$_} )
1138 ( defined $ag_info->{modreqs}{$_} and $ag_info->{modreqs}{$_} == $newreqs->{$_} )
1142 if (keys %$newreqs) {
1144 "Combined with L</$ag> additionally requires:",
1147 { "=item * $_" . ($newreqs->{$_} ? " >= $newreqs->{$_}" : '') }
1148 ( sort keys %$newreqs )
1158 #@@ API DOCUMENTATION HEADING
1160 push @chunks, <<'EOC';
1162 =head1 IMPORT-LIKE ACTIONS
1164 Even though this module is not an L<Exporter>, it recognizes several C<actions>
1165 supplied to its C<import> method.
1167 =head2 -skip_all_without
1171 =item Arguments: @group_names
1175 A convenience wrapper for use during testing:
1178 push @chunks, " use $class -skip_all_without => qw(admin test_rdbms_mysql);";
1180 push @chunks, 'Roughly equivalent to the following code:';
1182 push @chunks, sprintf <<'EOS', ($class) x 2;
1186 if ( my $missing = %s->req_missing_for(\@group_names_) ) {
1187 print "1..0 # SKIP requirements not satisfied: $missing\n";
1193 push @chunks, <<'EOC';
1195 It also takes into account the C<RELEASE_TESTING> environment variable and
1196 behaves like L</-die_without> for any requirement groups marked as
1197 C<release_testing_mandatory>.
1203 =item Arguments: @group_names
1207 A convenience wrapper around L</die_unless_req_ok_for>:
1210 push @chunks, " use $class -die_without => qw(deploy admin);";
1212 push @chunks, <<'EOC';
1214 =head2 -list_missing
1218 =item Arguments: @group_names
1222 A convenience wrapper around L</modreq_missing_for>:
1224 perl -Ilib -MDBIx::Class::Schema::Loader::Optional::Dependencies=-list_missing,dbicdump_config,rdbms_oracle | cpanm
1228 =head2 req_group_list
1232 =item Arguments: none
1234 =item Return Value: \%list_of_requirement_groups
1238 This method should be used by DBIx::Class::Schema::Loader packagers, to get a hashref of all
1239 dependencies B<keyed> by dependency group. Each key (group name), or a combination
1240 thereof (as an arrayref) can be supplied to the methods below.
1241 The B<values> of the returned hash are currently a set of options B<without a
1242 well defined structure>. If you have use for any of the contents - contact the
1243 maintainers, instead of treating this as public (left alone stable) API.
1249 =item Arguments: $group_name | \@group_names
1251 =item Return Value: \%set_of_module_version_pairs
1255 This method should be used by DBIx::Class::Schema::Loader extension authors, to determine the
1256 version of modules a specific set of features requires for this version of
1257 DBIx::Class::Schema::Loader (regardless of their availability on the system).
1258 See the L</SYNOPSIS> for a real-world example.
1260 When handling C<test_*> groups this method behaves B<differently> from
1261 L</modreq_list_for> below (and is the only such inconsistency among the
1262 C<req_*> methods). If a particular group declares as requirements some
1263 C<environment variables> and these requirements are not satisfied (the envvars
1264 are unset) - then the C<module requirements> of this group are not included in
1267 =head2 modreq_list_for
1271 =item Arguments: $group_name | \@group_names
1273 =item Return Value: \%set_of_module_version_pairs
1277 Same as L</req_list_for> but does not take into consideration any
1278 C<environment variable requirements> - returns just the list of required
1285 =item Arguments: $group_name | \@group_names
1287 =item Return Value: 1|0
1291 Returns true or false depending on whether all modules/envvars required by
1292 the group(s) are loadable/set on the system.
1294 =head2 req_missing_for
1298 =item Arguments: $group_name | \@group_names
1300 =item Return Value: $error_message_string
1304 Returns a single-line string suitable for inclusion in larger error messages.
1305 This method would normally be used by DBIx::Class::Schema::Loader core features, to indicate to
1306 the user that they need to install specific modules and/or set specific
1307 environment variables before being able to use a specific feature set.
1309 For example if some of the requirements for C<deploy> are not available,
1310 the returned string could look like:
1313 push @chunks, qq{ "Moose~$moosever" (see $class documentation for details)};
1315 push @chunks, <<'EOC';
1316 The author is expected to prepend the necessary text to this message before
1317 returning the actual error seen by the user. See also L</modreq_missing_for>
1319 =head2 modreq_missing_for
1323 =item Arguments: $group_name | \@group_names
1325 =item Return Value: $error_message_string
1329 Same as L</req_missing_for> except that the error string is guaranteed to be
1330 either empty, or contain a set of module requirement specifications suitable
1331 for piping to e.g. L<cpanminus|App::cpanminus>. The method explicitly does not
1332 attempt to validate the state of required environment variables (if any).
1334 For instance if some of the requirements for C<deploy> are not available,
1335 the returned string could look like:
1338 push @chunks, qq{ "Moose~$moosever"};
1340 push @chunks, <<'EOC';
1342 See also L</-list_missing>.
1348 =item Arguments: $group_name | \@group_names
1352 A convenience wrapper around L<skip|Test::More/SKIP>. It does not take neither
1353 a reason (it is generated by L</req_missing_for>) nor an amount of skipped tests
1354 (it is always C<1>, thus mandating unconditional use of
1355 L<done_testing|Test::More/done_testing>). Most useful in combination with ad hoc
1356 requirement specifications:
1359 push @chunks, <<EOC;
1361 $class->skip_without([ deploy YAML>=0.90 ]);
1367 push @chunks, <<'EOC';
1369 =head2 die_unless_req_ok_for
1373 =item Arguments: $group_name | \@group_names
1377 Checks if L</req_ok_for> passes for the supplied group(s), and
1378 in case of failure throws an exception including the information
1379 from L</req_missing_for>. See also L</-die_without>.
1381 =head2 modreq_errorlist_for
1385 =item Arguments: $group_name | \@group_names
1387 =item Return Value: \%set_of_loaderrors_per_module
1391 Returns a hashref containing the actual errors that occurred while attempting
1392 to load each module in the requirement group(s).
1394 =head2 req_errorlist_for
1396 Deprecated method name, equivalent (via proxy) to L</modreq_errorlist_for>.
1403 push @chunks, <<'EOC';
1404 =head1 FURTHER QUESTIONS?
1406 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
1408 =head1 COPYRIGHT AND LICENSE
1410 This module is free software L<copyright|DBIx::Class::Schema::Loader/COPYRIGHT AND LICENSE>
1411 by the L<DBIx::Class::Schema::Loader (DBICSL) authors|DBIx::Class::Schema::Loader/AUTHORS>.
1412 You can redistribute it and/or modify it under the same terms as the
1413 L<DBIx::Class::Schema::Loader library|DBIx::Class::Schema::Loader/COPYRIGHT AND LICENSE>.
1417 open (my $fh, '>', $podfn) or die;
1418 print $fh join ("\n\n", @chunks) or die;
1419 print $fh "\n" or die;
1421 } or croak( "Unable to write $podfn: " . ( $! || $@ || 'unknown error') );