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 = {
73 my $rdbms_firebird_odbc = {
79 #'Module::Install::Pod::Inherit' => '0.01',
85 title => 'Storage::Replicated',
86 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
103 title => 'DBIx::Class::Admin',
104 desc => 'Modules required for the DBIx::Class administrative library',
112 'Getopt::Long::Descriptive' => '0.081',
113 'Text::CSV' => '1.16',
116 title => 'dbicadmin',
117 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
123 'SQL::Translator' => '0.11006',
126 title => 'Storage::DBI::deploy()',
127 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deploy> and L<DBIx::Class::Storage::DBI/deployment_statements>',
132 req => $id_shortener,
137 'Test::Pod' => '1.41',
141 test_podcoverage => {
143 'Test::Pod::Coverage' => '1.08',
144 'Pod::Coverage' => '0.20',
150 'Test::NoTabs' => '0.9',
156 'Test::EOL' => '0.6',
160 test_prettydebug => {
166 'Test::Memory::Cycle' => '0',
167 'Devel::Cycle' => '1.10',
172 req => $datetime_basic,
180 'DateTime::Format::SQLite' => '0',
187 # t/inflate/datetime_mysql.t
188 # (doesn't need Mysql itself)
189 'DateTime::Format::MySQL' => '0',
196 # t/inflate/datetime_pg.t
197 # (doesn't need PG itself)
198 'DateTime::Format::Pg' => '0.16004',
204 'DBIx::ContextualFetch' => '0',
205 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
206 'Class::Trigger' => '0',
207 'Time::Piece::MySQL' => '0',
209 'Date::Simple' => '3.03',
213 # this is just for completeness as SQLite
214 # is a core dep of DBIC for testing
220 title => 'SQLite support',
221 desc => 'Modules required to connect to SQLite',
230 title => 'PostgreSQL support',
231 desc => 'Modules required to connect to PostgreSQL',
235 rdbms_mssql_odbc => {
240 title => 'MSSQL support via DBD::ODBC',
241 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
245 rdbms_mssql_sybase => {
247 %$rdbms_mssql_sybase,
250 title => 'MSSQL support via DBD::Sybase',
251 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
260 title => 'MSSQL support via DBD::ADO (Windows only)',
261 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
270 title => 'MySQL support',
271 desc => 'Modules required to connect to MySQL',
280 title => 'Oracle support',
281 desc => 'Modules required to connect to Oracle',
290 title => 'Sybase ASE support',
291 desc => 'Modules required to connect to Sybase ASE',
300 title => 'DB2 support',
301 desc => 'Modules required to connect to DB2',
305 # the order does matter because the rdbms support group might require
306 # a different version that the test group
309 $ENV{DBICTEST_PG_DSN}
312 'Sys::SigAction' => '0',
313 'DBD::Pg' => '2.009002',
318 test_rdbms_mssql_odbc => {
320 $ENV{DBICTEST_MSSQL_ODBC_DSN}
327 test_rdbms_mssql_ado => {
329 $ENV{DBICTEST_MSSQL_ADO_DSN}
336 test_rdbms_mssql_sybase => {
338 $ENV{DBICTEST_MSSQL_DSN}
340 %$rdbms_mssql_sybase,
345 test_rdbms_mysql => {
347 $ENV{DBICTEST_MYSQL_DSN}
354 test_rdbms_oracle => {
356 $ENV{DBICTEST_ORA_DSN}
359 'DateTime::Format::Oracle' => '0',
360 'DBD::Oracle' => '1.24',
367 $ENV{DBICTEST_SYBASE_DSN}
370 'DateTime::Format::Sybase' => '0',
377 $ENV{DBICTEST_DB2_DSN}
384 test_rdbms_firebird_odbc => {
386 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
388 %$rdbms_firebird_odbc,
395 $ENV{DBICTEST_MEMCACHED}
397 'Cache::Memcached' => 0,
406 my ($class, $group) = @_;
408 croak "req_list_for() expects a requirement group name"
411 my $deps = $reqs->{$group}{req}
412 or croak "Requirement group '$group' does not exist";
418 our %req_availability_cache;
420 my ($class, $group) = @_;
422 croak "req_ok_for() expects a requirement group name"
425 return $class->_check_deps($group)->{status};
428 sub req_missing_for {
429 my ($class, $group) = @_;
431 croak "req_missing_for() expects a requirement group name"
434 return $class->_check_deps($group)->{missing};
437 sub req_errorlist_for {
438 my ($class, $group) = @_;
440 croak "req_errorlist_for() expects a requirement group name"
443 return $class->_check_deps($group)->{errorlist};
447 my ($class, $group) = @_;
449 return $req_availability_cache{$group} ||= do {
451 my $deps = $class->req_list_for ($group);
454 for my $mod (keys %$deps) {
455 my $req_line = "require $mod;";
456 if (my $ver = $deps->{$mod}) {
457 $req_line .= "$mod->VERSION($ver);";
462 $errors{$mod} = $@ if $@;
468 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
469 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
472 errorlist => \%errors,
489 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
492 # This is to be called by the author only (automatically in Makefile.PL)
494 my ($class, $distver) = @_;
496 my $modfn = __PACKAGE__ . '.pm';
497 $modfn =~ s/\:\:/\//g;
499 my $podfn = __FILE__;
500 $podfn =~ s/\.pm$/\.pod/;
503 eval { require DBIx::Class; DBIx::Class->VERSION; }
506 "\n\n---------------------------------------------------------------------\n" .
507 'Unable to load core DBIx::Class module to determine current version, '.
508 'possibly due to missing dependencies. Author-mode autodocumentation ' .
510 "\n\n---------------------------------------------------------------------\n"
513 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
514 or die "Hrmm? No sqlt dep?";
518 #########################################################################
519 ##################### A U T O G E N E R A T E D ########################
520 #########################################################################
522 # The contents of this POD file are auto-generated. Any changes you make
523 # will be lost. If you need to change the generated text edit _gen_pod()
524 # at the end of $modfn
528 "$class - Optional module dependency specifications (for module authors)",
531 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
535 configure_requires 'DBIx::Class' => '$distver';
539 my \$deploy_deps = $class->req_list_for('deploy');
541 for (keys %\$deploy_deps) {
542 requires \$_ => \$deploy_deps->{\$_};
547 Note that there are some caveats regarding C<configure_requires()>, more info
548 can be found at L<Module::Install/configure_requires>
550 '=head1 DESCRIPTION',
552 Some of the less-frequently used features of L<DBIx::Class> have external
553 module dependencies on their own. In order not to burden the average user
554 with modules he will never use, these optional dependencies are not included
555 in the base Makefile.PL. Instead an exception with a descriptive message is
556 thrown when a specific feature is missing one or several modules required for
557 its operation. This module is the central holding place for the current list
558 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
561 '=head1 CURRENT REQUIREMENT GROUPS',
563 Dependencies are organized in C<groups> and each group can list one or more
564 required modules, with an optional minimum version (or 0 for any version).
565 The group name can be used in the
569 for my $group (sort keys %$reqs) {
570 my $p = $reqs->{$group}{pod}
573 my $modlist = $reqs->{$group}{req}
576 next unless keys %$modlist;
579 "=head2 $p->{title}",
582 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
584 "Requirement group: B<$group>",
590 '=head2 req_group_list',
592 '=item Arguments: none',
593 '=item Returns: \%list_of_requirement_groups',
596 This method should be used by DBIx::Class packagers, to get a hashref of all
597 dependencies keyed by dependency group. Each key (group name) can be supplied
598 to one of the group-specific methods below.
601 '=head2 req_list_for',
603 '=item Arguments: $group_name',
604 '=item Returns: \%list_of_module_version_pairs',
607 This method should be used by DBIx::Class extension authors, to determine the
608 version of modules a specific feature requires in the B<current> version of
609 DBIx::Class. See the L</SYNOPSIS> for a real-world
615 '=item Arguments: $group_name',
616 '=item Returns: 1|0',
619 Returns true or false depending on whether all modules required by
620 C<$group_name> are present on the system and loadable.
623 '=head2 req_missing_for',
625 '=item Arguments: $group_name',
626 '=item Returns: $error_message_string',
629 Returns a single line string suitable for inclusion in larger error messages.
630 This method would normally be used by DBIx::Class core-module author, to
631 indicate to the user that he needs to install specific modules before he will
632 be able to use a specific feature.
634 For example if some of the requirements for C<deploy> are not available,
635 the returned string could look like:
637 SQL::Translator >= $sqltver (see $class for details)
639 The author is expected to prepend the necessary text to this message before
640 returning the actual error seen by the user.
643 '=head2 req_errorlist_for',
645 '=item Arguments: $group_name',
646 '=item Returns: \%list_of_loaderrors_per_module',
649 Returns a hashref containing the actual errors that occured while attempting
650 to load each module in the requirement group.
653 'See L<DBIx::Class/CONTRIBUTORS>.',
655 'You may distribute this code under the same terms as Perl itself',
658 open (my $fh, '>', $podfn) or croak "Unable to write to $podfn: $!";
659 print $fh join ("\n\n", @chunks);