1 package DBIx::Class::Optional::Dependencies;
8 # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G)
9 # This module is to be loaded by Makefile.PM on a pristine system
11 # POD is generated automatically by calling _gen_pod from the
12 # Makefile.PL in $AUTHOR mode
15 'JSON::Any' => '1.22',
20 'MooseX::Types' => '0.21',
30 'MooseX::Types::Path::Class' => '0.05',
31 'MooseX::Types::JSON' => '0.02',
32 'namespace::autoclean' => '0.09',
35 my $datetime_basic = {
37 'DateTime::Format::Strptime' => '1.2',
41 'Math::BigInt' => '1.89',
42 'Math::Base36' => '0.07',
51 my $rdbms_mssql_odbc = {
54 my $rdbms_mssql_sybase = {
57 my $rdbms_mssql_ado = {
60 my $rdbms_msaccess_odbc = {
63 my $rdbms_msaccess_ado = {
79 my $rdbms_firebird_odbc = {
85 #'Module::Install::Pod::Inherit' => '0.01',
91 title => 'Storage::Replicated',
92 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
109 title => 'DBIx::Class::Admin',
110 desc => 'Modules required for the DBIx::Class administrative library',
118 'Getopt::Long::Descriptive' => '0.081',
119 'Text::CSV' => '1.16',
122 title => 'dbicadmin',
123 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
129 'SQL::Translator' => '0.11006',
132 title => 'Storage::DBI::deploy()',
133 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deployment_statements>',
138 req => $id_shortener,
141 test_component_accessor => {
143 'Class::Unload' => '0.07',
149 'Test::Pod' => '1.41',
153 test_podcoverage => {
155 'Test::Pod::Coverage' => '1.08',
156 'Pod::Coverage' => '0.20',
162 'Test::NoTabs' => '0.9',
168 'Test::EOL' => '0.6',
172 test_prettydebug => {
178 'Test::Memory::Cycle' => '0',
179 'Devel::Cycle' => '1.10',
184 req => $datetime_basic,
192 'DateTime::Format::SQLite' => '0',
199 # t/inflate/datetime_mysql.t
200 # (doesn't need Mysql itself)
201 'DateTime::Format::MySQL' => '0',
208 # t/inflate/datetime_pg.t
209 # (doesn't need PG itself)
210 'DateTime::Format::Pg' => '0.16004',
216 'DBIx::ContextualFetch' => '0',
217 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
218 'Class::Trigger' => '0',
219 'Time::Piece::MySQL' => '0',
221 'Date::Simple' => '3.03',
225 # this is just for completeness as SQLite
226 # is a core dep of DBIC for testing
232 title => 'SQLite support',
233 desc => 'Modules required to connect to SQLite',
242 title => 'PostgreSQL support',
243 desc => 'Modules required to connect to PostgreSQL',
247 rdbms_mssql_odbc => {
252 title => 'MSSQL support via DBD::ODBC',
253 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
257 rdbms_mssql_sybase => {
259 %$rdbms_mssql_sybase,
262 title => 'MSSQL support via DBD::Sybase',
263 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
272 title => 'MSSQL support via DBD::ADO (Windows only)',
273 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
277 rdbms_msaccess_odbc => {
279 %$rdbms_msaccess_odbc,
282 title => 'MS Access support via DBD::ODBC',
283 desc => 'Modules required to connect to MS Access via DBD::ODBC',
287 rdbms_msaccess_ado => {
289 %$rdbms_msaccess_ado,
292 title => 'MS Access support via DBD::ADO (Windows only)',
293 desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
302 title => 'MySQL support',
303 desc => 'Modules required to connect to MySQL',
312 title => 'Oracle support',
313 desc => 'Modules required to connect to Oracle',
322 title => 'Sybase ASE support',
323 desc => 'Modules required to connect to Sybase ASE',
332 title => 'DB2 support',
333 desc => 'Modules required to connect to DB2',
337 # the order does matter because the rdbms support group might require
338 # a different version that the test group
341 $ENV{DBICTEST_PG_DSN}
344 'Sys::SigAction' => '0',
345 'DBD::Pg' => '2.009002',
350 test_rdbms_mssql_odbc => {
352 $ENV{DBICTEST_MSSQL_ODBC_DSN}
359 test_rdbms_mssql_ado => {
361 $ENV{DBICTEST_MSSQL_ADO_DSN}
368 test_rdbms_mssql_sybase => {
370 $ENV{DBICTEST_MSSQL_DSN}
372 %$rdbms_mssql_sybase,
377 test_rdbms_msaccess_odbc => {
379 $ENV{DBICTEST_MSACCESS_ODBC_DSN}
381 %$rdbms_msaccess_odbc,
388 test_rdbms_msaccess_ado => {
390 $ENV{DBICTEST_MSACCESS_ADO_DSN}
392 %$rdbms_msaccess_ado,
399 test_rdbms_mysql => {
401 $ENV{DBICTEST_MYSQL_DSN}
408 test_rdbms_oracle => {
410 $ENV{DBICTEST_ORA_DSN}
413 'DateTime::Format::Oracle' => '0',
414 'DBD::Oracle' => '1.24',
421 $ENV{DBICTEST_SYBASE_DSN}
424 'DateTime::Format::Sybase' => '0',
431 $ENV{DBICTEST_DB2_DSN}
438 test_rdbms_firebird_odbc => {
440 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
442 %$rdbms_firebird_odbc,
449 $ENV{DBICTEST_MEMCACHED}
451 'Cache::Memcached' => 0,
460 my ($class, $group) = @_;
462 Carp::croak "req_list_for() expects a requirement group name"
465 my $deps = $reqs->{$group}{req}
466 or Carp::croak "Requirement group '$group' does not exist";
472 our %req_availability_cache;
474 my ($class, $group) = @_;
476 Carp::croak "req_ok_for() expects a requirement group name"
479 return $class->_check_deps($group)->{status};
482 sub req_missing_for {
483 my ($class, $group) = @_;
485 Carp::croak "req_missing_for() expects a requirement group name"
488 return $class->_check_deps($group)->{missing};
491 sub req_errorlist_for {
492 my ($class, $group) = @_;
494 Carp::croak "req_errorlist_for() expects a requirement group name"
497 return $class->_check_deps($group)->{errorlist};
501 my ($class, $group) = @_;
503 return $req_availability_cache{$group} ||= do {
505 my $deps = $class->req_list_for ($group);
508 for my $mod (keys %$deps) {
509 my $req_line = "require $mod;";
510 if (my $ver = $deps->{$mod}) {
511 $req_line .= "$mod->VERSION($ver);";
516 $errors{$mod} = $@ if $@;
522 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
523 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
527 errorlist => \%errors,
544 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
547 # This is to be called by the author only (automatically in Makefile.PL)
549 my ($class, $distver) = @_;
551 my $modfn = __PACKAGE__ . '.pm';
552 $modfn =~ s/\:\:/\//g;
554 my $podfn = __FILE__;
555 $podfn =~ s/\.pm$/\.pod/;
558 eval { require DBIx::Class; DBIx::Class->VERSION; }
561 "\n\n---------------------------------------------------------------------\n" .
562 'Unable to load core DBIx::Class module to determine current version, '.
563 'possibly due to missing dependencies. Author-mode autodocumentation ' .
565 "\n\n---------------------------------------------------------------------\n"
568 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
569 or die "Hrmm? No sqlt dep?";
573 #########################################################################
574 ##################### A U T O G E N E R A T E D ########################
575 #########################################################################
577 # The contents of this POD file are auto-generated. Any changes you make
578 # will be lost. If you need to change the generated text edit _gen_pod()
579 # at the end of $modfn
583 "$class - Optional module dependency specifications (for module authors)",
586 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
590 configure_requires 'DBIx::Class' => '$distver';
594 my \$deploy_deps = $class->req_list_for('deploy');
596 for (keys %\$deploy_deps) {
597 requires \$_ => \$deploy_deps->{\$_};
602 Note that there are some caveats regarding C<configure_requires()>, more info
603 can be found at L<Module::Install/configure_requires>
605 '=head1 DESCRIPTION',
607 Some of the less-frequently used features of L<DBIx::Class> have external
608 module dependencies on their own. In order not to burden the average user
609 with modules he will never use, these optional dependencies are not included
610 in the base Makefile.PL. Instead an exception with a descriptive message is
611 thrown when a specific feature is missing one or several modules required for
612 its operation. This module is the central holding place for the current list
613 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
616 '=head1 CURRENT REQUIREMENT GROUPS',
618 Dependencies are organized in C<groups> and each group can list one or more
619 required modules, with an optional minimum version (or 0 for any version).
620 The group name can be used in the
624 for my $group (sort keys %$reqs) {
625 my $p = $reqs->{$group}{pod}
628 my $modlist = $reqs->{$group}{req}
631 next unless keys %$modlist;
634 "=head2 $p->{title}",
637 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
639 "Requirement group: B<$group>",
645 '=head2 req_group_list',
647 '=item Arguments: none',
648 '=item Returns: \%list_of_requirement_groups',
651 This method should be used by DBIx::Class packagers, to get a hashref of all
652 dependencies keyed by dependency group. Each key (group name) can be supplied
653 to one of the group-specific methods below.
656 '=head2 req_list_for',
658 '=item Arguments: $group_name',
659 '=item Returns: \%list_of_module_version_pairs',
662 This method should be used by DBIx::Class extension authors, to determine the
663 version of modules a specific feature requires in the B<current> version of
664 DBIx::Class. See the L</SYNOPSIS> for a real-world
670 '=item Arguments: $group_name',
671 '=item Returns: 1|0',
674 Returns true or false depending on whether all modules required by
675 C<$group_name> are present on the system and loadable.
678 '=head2 req_missing_for',
680 '=item Arguments: $group_name',
681 '=item Returns: $error_message_string',
684 Returns a single line string suitable for inclusion in larger error messages.
685 This method would normally be used by DBIx::Class core-module author, to
686 indicate to the user that he needs to install specific modules before he will
687 be able to use a specific feature.
689 For example if some of the requirements for C<deploy> are not available,
690 the returned string could look like:
692 SQL::Translator >= $sqltver (see $class for details)
694 The author is expected to prepend the necessary text to this message before
695 returning the actual error seen by the user.
698 '=head2 req_errorlist_for',
700 '=item Arguments: $group_name',
701 '=item Returns: \%list_of_loaderrors_per_module',
704 Returns a hashref containing the actual errors that occured while attempting
705 to load each module in the requirement group.
708 'See L<DBIx::Class/CONTRIBUTORS>.',
710 'You may distribute this code under the same terms as Perl itself',
713 open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!";
714 print $fh join ("\n\n", @chunks);