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 = {
73 #'Module::Install::Pod::Inherit' => '0.01',
79 title => 'Storage::Replicated',
80 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
97 title => 'DBIx::Class::Admin',
98 desc => 'Modules required for the DBIx::Class administrative library',
106 'Getopt::Long::Descriptive' => '0.081',
107 'Text::CSV' => '1.16',
110 title => 'dbicadmin',
111 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
117 'SQL::Translator' => '0.11006',
120 title => 'Storage::DBI::deploy()',
121 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deployment_statements>',
126 req => $id_shortener,
131 'Test::Pod' => '1.41',
135 test_podcoverage => {
137 'Test::Pod::Coverage' => '1.08',
138 'Pod::Coverage' => '0.20',
144 'Test::NoTabs' => '0.9',
150 'Test::EOL' => '0.6',
154 test_prettydebug => {
160 'Test::Memory::Cycle' => '0',
161 'Devel::Cycle' => '1.10',
166 req => $datetime_basic,
174 'DateTime::Format::SQLite' => '0',
181 # t/inflate/datetime_mysql.t
182 # (doesn't need Mysql itself)
183 'DateTime::Format::MySQL' => '0',
190 # t/inflate/datetime_pg.t
191 # (doesn't need PG itself)
192 'DateTime::Format::Pg' => '0.16004',
198 'DBIx::ContextualFetch' => '0',
199 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
200 'Class::Trigger' => '0',
201 'Time::Piece::MySQL' => '0',
203 'Date::Simple' => '3.03',
207 # this is just for completeness as SQLite
208 # is a core dep of DBIC for testing
214 title => 'SQLite support',
215 desc => 'Modules required to connect to SQLite',
224 title => 'PostgreSQL support',
225 desc => 'Modules required to connect to PostgreSQL',
229 rdbms_mssql_odbc => {
234 title => 'MSSQL support via DBD::ODBC',
235 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
239 rdbms_mssql_sybase => {
241 %$rdbms_mssql_sybase,
244 title => 'MSSQL support via DBD::Sybase',
245 desc => 'Modules required to connect to MSSQL support via DBD::Sybase',
254 title => 'MySQL support',
255 desc => 'Modules required to connect to MySQL',
264 title => 'Oracle support',
265 desc => 'Modules required to connect to Oracle',
274 title => 'Sybase ASE support',
275 desc => 'Modules required to connect to Sybase ASE',
284 title => 'DB2 support',
285 desc => 'Modules required to connect to DB2',
289 # the order does matter because the rdbms support group might require
290 # a different version that the test group
293 $ENV{DBICTEST_PG_DSN}
296 'Sys::SigAction' => '0',
297 'DBD::Pg' => '2.009002',
302 test_rdbms_mssql_odbc => {
304 $ENV{DBICTEST_MSSQL_ODBC_DSN}
311 test_rdbms_mssql_sybase => {
313 $ENV{DBICTEST_MSSQL_DSN}
315 %$rdbms_mssql_sybase,
320 test_rdbms_mysql => {
322 $ENV{DBICTEST_MYSQL_DSN}
329 test_rdbms_oracle => {
331 $ENV{DBICTEST_ORA_DSN}
334 'DateTime::Format::Oracle' => '0',
335 'DBD::Oracle' => '1.24',
342 $ENV{DBICTEST_SYBASE_DSN}
345 'DateTime::Format::Sybase' => '0',
352 $ENV{DBICTEST_DB2_DSN}
361 $ENV{DBICTEST_MEMCACHED}
363 'Cache::Memcached' => 0,
372 my ($class, $group) = @_;
374 croak "req_list_for() expects a requirement group name"
377 my $deps = $reqs->{$group}{req}
378 or croak "Requirement group '$group' does not exist";
384 our %req_availability_cache;
386 my ($class, $group) = @_;
388 croak "req_ok_for() expects a requirement group name"
391 return $class->_check_deps($group)->{status};
394 sub req_missing_for {
395 my ($class, $group) = @_;
397 croak "req_missing_for() expects a requirement group name"
400 return $class->_check_deps($group)->{missing};
403 sub req_errorlist_for {
404 my ($class, $group) = @_;
406 croak "req_errorlist_for() expects a requirement group name"
409 return $class->_check_deps($group)->{errorlist};
413 my ($class, $group) = @_;
415 return $req_availability_cache{$group} ||= do {
417 my $deps = $class->req_list_for ($group);
420 for my $mod (keys %$deps) {
421 my $req_line = "require $mod;";
422 if (my $ver = $deps->{$mod}) {
423 $req_line .= "$mod->VERSION($ver);";
428 $errors{$mod} = $@ if $@;
434 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
435 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
438 errorlist => \%errors,
455 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
458 # This is to be called by the author only (automatically in Makefile.PL)
460 my ($class, $distver) = @_;
462 my $modfn = __PACKAGE__ . '.pm';
463 $modfn =~ s/\:\:/\//g;
465 my $podfn = __FILE__;
466 $podfn =~ s/\.pm$/\.pod/;
469 eval { require DBIx::Class; DBIx::Class->VERSION; }
472 "\n\n---------------------------------------------------------------------\n" .
473 'Unable to load core DBIx::Class module to determine current version, '.
474 'possibly due to missing dependencies. Author-mode autodocumentation ' .
476 "\n\n---------------------------------------------------------------------\n"
479 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
480 or die "Hrmm? No sqlt dep?";
484 #########################################################################
485 ##################### A U T O G E N E R A T E D ########################
486 #########################################################################
488 # The contents of this POD file are auto-generated. Any changes you make
489 # will be lost. If you need to change the generated text edit _gen_pod()
490 # at the end of $modfn
494 "$class - Optional module dependency specifications (for module authors)",
497 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
501 configure_requires 'DBIx::Class' => '$distver';
505 my \$deploy_deps = $class->req_list_for('deploy');
507 for (keys %\$deploy_deps) {
508 requires \$_ => \$deploy_deps->{\$_};
513 Note that there are some caveats regarding C<configure_requires()>, more info
514 can be found at L<Module::Install/configure_requires>
516 '=head1 DESCRIPTION',
518 Some of the less-frequently used features of L<DBIx::Class> have external
519 module dependencies on their own. In order not to burden the average user
520 with modules he will never use, these optional dependencies are not included
521 in the base Makefile.PL. Instead an exception with a descriptive message is
522 thrown when a specific feature is missing one or several modules required for
523 its operation. This module is the central holding place for the current list
524 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
527 '=head1 CURRENT REQUIREMENT GROUPS',
529 Dependencies are organized in C<groups> and each group can list one or more
530 required modules, with an optional minimum version (or 0 for any version).
531 The group name can be used in the
535 for my $group (sort keys %$reqs) {
536 my $p = $reqs->{$group}{pod}
539 my $modlist = $reqs->{$group}{req}
542 next unless keys %$modlist;
545 "=head2 $p->{title}",
548 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
550 "Requirement group: B<$group>",
556 '=head2 req_group_list',
558 '=item Arguments: none',
559 '=item Returns: \%list_of_requirement_groups',
562 This method should be used by DBIx::Class packagers, to get a hashref of all
563 dependencies keyed by dependency group. Each key (group name) can be supplied
564 to one of the group-specific methods below.
567 '=head2 req_list_for',
569 '=item Arguments: $group_name',
570 '=item Returns: \%list_of_module_version_pairs',
573 This method should be used by DBIx::Class extension authors, to determine the
574 version of modules a specific feature requires in the B<current> version of
575 DBIx::Class. See the L</SYNOPSIS> for a real-world
581 '=item Arguments: $group_name',
582 '=item Returns: 1|0',
585 Returns true or false depending on whether all modules required by
586 C<$group_name> are present on the system and loadable.
589 '=head2 req_missing_for',
591 '=item Arguments: $group_name',
592 '=item Returns: $error_message_string',
595 Returns a single line string suitable for inclusion in larger error messages.
596 This method would normally be used by DBIx::Class core-module author, to
597 indicate to the user that he needs to install specific modules before he will
598 be able to use a specific feature.
600 For example if some of the requirements for C<deploy> are not available,
601 the returned string could look like:
603 SQL::Translator >= $sqltver (see $class for details)
605 The author is expected to prepend the necessary text to this message before
606 returning the actual error seen by the user.
609 '=head2 req_errorlist_for',
611 '=item Arguments: $group_name',
612 '=item Returns: \%list_of_loaderrors_per_module',
615 Returns a hashref containing the actual errors that occured while attempting
616 to load each module in the requirement group.
619 'See L<DBIx::Class/CONTRIBUTORS>.',
621 'You may distribute this code under the same terms as Perl itself',
624 open (my $fh, '>', $podfn) or croak "Unable to write to $podfn: $!";
625 print $fh join ("\n\n", @chunks);