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,
135 test_component_accessor => {
137 'Class::Unload' => '0.07',
143 'Test::Pod' => '1.41',
147 test_podcoverage => {
149 'Test::Pod::Coverage' => '1.08',
150 'Pod::Coverage' => '0.20',
156 'Test::NoTabs' => '0.9',
162 'Test::EOL' => '0.6',
166 test_prettydebug => {
172 'Test::Memory::Cycle' => '0',
173 'Devel::Cycle' => '1.10',
178 req => $datetime_basic,
186 'DateTime::Format::SQLite' => '0',
193 # t/inflate/datetime_mysql.t
194 # (doesn't need Mysql itself)
195 'DateTime::Format::MySQL' => '0',
202 # t/inflate/datetime_pg.t
203 # (doesn't need PG itself)
204 'DateTime::Format::Pg' => '0.16004',
210 'DBIx::ContextualFetch' => '0',
211 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
212 'Class::Trigger' => '0',
213 'Time::Piece::MySQL' => '0',
215 'Date::Simple' => '3.03',
219 # this is just for completeness as SQLite
220 # is a core dep of DBIC for testing
226 title => 'SQLite support',
227 desc => 'Modules required to connect to SQLite',
236 title => 'PostgreSQL support',
237 desc => 'Modules required to connect to PostgreSQL',
241 rdbms_mssql_odbc => {
246 title => 'MSSQL support via DBD::ODBC',
247 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
251 rdbms_mssql_sybase => {
253 %$rdbms_mssql_sybase,
256 title => 'MSSQL support via DBD::Sybase',
257 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
266 title => 'MSSQL support via DBD::ADO (Windows only)',
267 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
276 title => 'MySQL support',
277 desc => 'Modules required to connect to MySQL',
286 title => 'Oracle support',
287 desc => 'Modules required to connect to Oracle',
296 title => 'Sybase ASE support',
297 desc => 'Modules required to connect to Sybase ASE',
306 title => 'DB2 support',
307 desc => 'Modules required to connect to DB2',
311 # the order does matter because the rdbms support group might require
312 # a different version that the test group
315 $ENV{DBICTEST_PG_DSN}
318 'Sys::SigAction' => '0',
319 'DBD::Pg' => '2.009002',
324 test_rdbms_mssql_odbc => {
326 $ENV{DBICTEST_MSSQL_ODBC_DSN}
333 test_rdbms_mssql_ado => {
335 $ENV{DBICTEST_MSSQL_ADO_DSN}
342 test_rdbms_mssql_sybase => {
344 $ENV{DBICTEST_MSSQL_DSN}
346 %$rdbms_mssql_sybase,
351 test_rdbms_mysql => {
353 $ENV{DBICTEST_MYSQL_DSN}
360 test_rdbms_oracle => {
362 $ENV{DBICTEST_ORA_DSN}
365 'DateTime::Format::Oracle' => '0',
366 'DBD::Oracle' => '1.24',
373 $ENV{DBICTEST_SYBASE_DSN}
376 'DateTime::Format::Sybase' => '0',
383 $ENV{DBICTEST_DB2_DSN}
390 test_rdbms_firebird_odbc => {
392 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
394 %$rdbms_firebird_odbc,
401 $ENV{DBICTEST_MEMCACHED}
403 'Cache::Memcached' => 0,
412 my ($class, $group) = @_;
414 Carp::croak "req_list_for() expects a requirement group name"
417 my $deps = $reqs->{$group}{req}
418 or Carp::croak "Requirement group '$group' does not exist";
424 our %req_availability_cache;
426 my ($class, $group) = @_;
428 Carp::croak "req_ok_for() expects a requirement group name"
431 return $class->_check_deps($group)->{status};
434 sub req_missing_for {
435 my ($class, $group) = @_;
437 Carp::croak "req_missing_for() expects a requirement group name"
440 return $class->_check_deps($group)->{missing};
443 sub req_errorlist_for {
444 my ($class, $group) = @_;
446 Carp::croak "req_errorlist_for() expects a requirement group name"
449 return $class->_check_deps($group)->{errorlist};
453 my ($class, $group) = @_;
455 return $req_availability_cache{$group} ||= do {
457 my $deps = $class->req_list_for ($group);
460 for my $mod (keys %$deps) {
461 my $req_line = "require $mod;";
462 if (my $ver = $deps->{$mod}) {
463 $req_line .= "$mod->VERSION($ver);";
468 $errors{$mod} = $@ if $@;
474 my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) );
475 $missing .= " (see $class for details)" if $reqs->{$group}{pod};
478 errorlist => \%errors,
495 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
498 # This is to be called by the author only (automatically in Makefile.PL)
500 my ($class, $distver) = @_;
502 my $modfn = __PACKAGE__ . '.pm';
503 $modfn =~ s/\:\:/\//g;
505 my $podfn = __FILE__;
506 $podfn =~ s/\.pm$/\.pod/;
509 eval { require DBIx::Class; DBIx::Class->VERSION; }
512 "\n\n---------------------------------------------------------------------\n" .
513 'Unable to load core DBIx::Class module to determine current version, '.
514 'possibly due to missing dependencies. Author-mode autodocumentation ' .
516 "\n\n---------------------------------------------------------------------\n"
519 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
520 or die "Hrmm? No sqlt dep?";
524 #########################################################################
525 ##################### A U T O G E N E R A T E D ########################
526 #########################################################################
528 # The contents of this POD file are auto-generated. Any changes you make
529 # will be lost. If you need to change the generated text edit _gen_pod()
530 # at the end of $modfn
534 "$class - Optional module dependency specifications (for module authors)",
537 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
541 configure_requires 'DBIx::Class' => '$distver';
545 my \$deploy_deps = $class->req_list_for('deploy');
547 for (keys %\$deploy_deps) {
548 requires \$_ => \$deploy_deps->{\$_};
553 Note that there are some caveats regarding C<configure_requires()>, more info
554 can be found at L<Module::Install/configure_requires>
556 '=head1 DESCRIPTION',
558 Some of the less-frequently used features of L<DBIx::Class> have external
559 module dependencies on their own. In order not to burden the average user
560 with modules he will never use, these optional dependencies are not included
561 in the base Makefile.PL. Instead an exception with a descriptive message is
562 thrown when a specific feature is missing one or several modules required for
563 its operation. This module is the central holding place for the current list
564 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
567 '=head1 CURRENT REQUIREMENT GROUPS',
569 Dependencies are organized in C<groups> and each group can list one or more
570 required modules, with an optional minimum version (or 0 for any version).
571 The group name can be used in the
575 for my $group (sort keys %$reqs) {
576 my $p = $reqs->{$group}{pod}
579 my $modlist = $reqs->{$group}{req}
582 next unless keys %$modlist;
585 "=head2 $p->{title}",
588 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
590 "Requirement group: B<$group>",
596 '=head2 req_group_list',
598 '=item Arguments: none',
599 '=item Returns: \%list_of_requirement_groups',
602 This method should be used by DBIx::Class packagers, to get a hashref of all
603 dependencies keyed by dependency group. Each key (group name) can be supplied
604 to one of the group-specific methods below.
607 '=head2 req_list_for',
609 '=item Arguments: $group_name',
610 '=item Returns: \%list_of_module_version_pairs',
613 This method should be used by DBIx::Class extension authors, to determine the
614 version of modules a specific feature requires in the B<current> version of
615 DBIx::Class. See the L</SYNOPSIS> for a real-world
621 '=item Arguments: $group_name',
622 '=item Returns: 1|0',
625 Returns true or false depending on whether all modules required by
626 C<$group_name> are present on the system and loadable.
629 '=head2 req_missing_for',
631 '=item Arguments: $group_name',
632 '=item Returns: $error_message_string',
635 Returns a single line string suitable for inclusion in larger error messages.
636 This method would normally be used by DBIx::Class core-module author, to
637 indicate to the user that he needs to install specific modules before he will
638 be able to use a specific feature.
640 For example if some of the requirements for C<deploy> are not available,
641 the returned string could look like:
643 SQL::Translator >= $sqltver (see $class for details)
645 The author is expected to prepend the necessary text to this message before
646 returning the actual error seen by the user.
649 '=head2 req_errorlist_for',
651 '=item Arguments: $group_name',
652 '=item Returns: \%list_of_loaderrors_per_module',
655 Returns a hashref containing the actual errors that occured while attempting
656 to load each module in the requirement group.
659 'See L<DBIx::Class/CONTRIBUTORS>.',
661 'You may distribute this code under the same terms as Perl itself',
664 open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!";
665 print $fh join ("\n\n", @chunks);