NAME
DBIx::Class::Optional::Dependencies - Optional module dependency specifications (for module authors)
SYNOPSIS
Somewhere in your build-file (e.g. ExtUtils::MakeMaker's Makefile.PL):
...
$EUMM_ARGS{CONFIGURE_REQUIRES} = {
%{ $EUMM_ARGS{CONFIGURE_REQUIRES} || {} },
'DBIx::Class' => '0.082899_08',
};
...
my %DBIC_DEPLOY_AND_ORACLE_DEPS = %{ eval {
require DBIx::Class::Optional::Dependencies;
DBIx::Class::Optional::Dependencies->req_list_for([qw( deploy rdbms_oracle icdt )]);
} || {} };
$EUMM_ARGS{PREREQ_PM} = {
%DBIC_DEPLOY_AND_ORACLE_DEPS,
%{ $EUMM_ARGS{PREREQ_PM} || {} },
};
...
ExtUtils::MakeMaker::WriteMakefile(%EUMM_ARGS);
Note: The eval
protection within the example is due to support for requirements during the configure
build phase not being available on a sufficient portion of production installations of Perl. Robust support for such dependency requirements is available in the CPAN installer only since version 1.94_56
first made available for production with perl version 5.12
. It is the belief of the current maintainer that support for requirements during the configure
build phase will not be sufficiently ubiquitous until the year 2020 at the earliest, hence the extra care demonstrated above. It should also be noted that some 3rd party installers (e.g. cpanminus) do the right thing with configure requirements independent from the versions of perl and CPAN available.
DESCRIPTION
Some of the less-frequently used features of DBIx::Class have external module dependencies on their own. In order not to burden the average user with modules they will never use, these optional dependencies are not included in the base Makefile.PL. Instead an exception with a descriptive message is thrown when a specific feature can't find one or several modules required for its operation. This module is the central holding place for the current list of such dependencies, for DBIx::Class core authors, and DBIx::Class extension authors alike.
Dependencies are organized in groups where each group can list one or more required modules, with an optional minimum version (or 0 for any version). In addition groups prefixed with test_
can specify a set of environment variables, some (or all) of which are marked as required for the group to be considered by "req_list_for"
Each group name (or a combination thereof) can be used in the public methods as described below.
CURRENT REQUIREMENT GROUPS
DBIx::Class::Admin
admin
Modules required for the DBIx::Class administrative library
JSON::Any >= 1.23
Moose >= 0.98
MooseX::Types >= 0.21
MooseX::Types::JSON >= 0.02
MooseX::Types::LoadableClass >= 0.011
MooseX::Types::Path::Class >= 0.05
dbicadmin
admin_script
Modules required for the CLI DBIx::Class interface dbicadmin
Getopt::Long::Descriptive >= 0.081
JSON::Any >= 1.23
Moose >= 0.98
MooseX::Types >= 0.21
MooseX::Types::JSON >= 0.02
MooseX::Types::LoadableClass >= 0.011
MooseX::Types::Path::Class >= 0.05
Text::CSV >= 1.16
DBIx::Class::CDBICompat support
cdbicompat
Modules required for DBIx::Class::CDBICompat
Class::Data::Inheritable
Class::Trigger
Clone >= 0.32
DBIx::ContextualFetch
Storage::DBI::deploy()
deploy
Modules required for "deployment_statements" in DBIx::Class::Storage::DBI and "deploy" in DBIx::Class::Schema
SQL::Translator >= 0.11018
InflateColumn::DateTime support
icdt
Modules required for DBIx::Class::InflateColumn::DateTime. Note that this group does not require much on its own, but instead is augmented by various RDBMS-specific groups. See the documentation of each rbms_*
group for details
DateTime >= 0.55
DateTime::TimeZone::OlsonDB
Sybase ASE support
rdbms_ase
Modules required to connect to Sybase ASE
DBD::Sybase
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
DB2 support
rdbms_db2
Modules required to connect to DB2
DBD::DB2
Combined with "icdt" additionally requires:
DateTime::Format::DB2
DB2 on AS/400 support
rdbms_db2_400
Modules required to connect to DB2 on AS/400
DBD::ODBC
Combined with "icdt" additionally requires:
DateTime::Format::DB2
Firebird support
rdbms_firebird
Modules required to connect to Firebird
DBD::Firebird
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
Firebird support via DBD::InterBase
rdbms_firebird_interbase
Modules required to connect to Firebird via DBD::InterBase
DBD::InterBase
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
Firebird support via DBD::ODBC
rdbms_firebird_odbc
Modules required to connect to Firebird via DBD::ODBC
DBD::ODBC
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
Informix support
rdbms_informix
Modules required to connect to Informix
DBD::Informix
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MS Access support via DBD::ADO (Windows only)
rdbms_msaccess_ado
Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only
DBD::ADO
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MS Access support via DBD::ODBC
rdbms_msaccess_odbc
Modules required to connect to MS Access via DBD::ODBC
DBD::ODBC
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MSSQL support via DBD::ADO (Windows only)
rdbms_mssql_ado
Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only
DBD::ADO
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MSSQL support via DBD::ODBC
rdbms_mssql_odbc
Modules required to connect to MSSQL via DBD::ODBC
DBD::ODBC
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MSSQL support via DBD::Sybase
rdbms_mssql_sybase
Modules required to connect to MSSQL via DBD::Sybase
DBD::Sybase
Combined with "icdt" additionally requires:
DateTime::Format::Strptime >= 1.2
MySQL support
rdbms_mysql
Modules required to connect to MySQL
DBD::mysql
Combined with "icdt" additionally requires:
DateTime::Format::MySQL
Oracle support
rdbms_oracle
Modules required to connect to Oracle
DBD::Oracle
Math::Base36 >= 0.07
Math::BigInt >= 1.80
Combined with "icdt" additionally requires:
DateTime::Format::Oracle
PostgreSQL support
rdbms_pg
Modules required to connect to PostgreSQL
DBD::Pg
Combined with "icdt" additionally requires:
DateTime::Format::Pg >= 0.16004
SQLAnywhere support
rdbms_sqlanywhere
Modules required to connect to SQLAnywhere
DBD::SQLAnywhere
SQLAnywhere support via DBD::ODBC
rdbms_sqlanywhere_odbc
Modules required to connect to SQLAnywhere via DBD::ODBC
DBD::ODBC
SQLite support
rdbms_sqlite
Modules required to connect to SQLite
DBD::SQLite
Combined with "icdt" additionally requires:
DateTime::Format::SQLite
Storage::Replicated
replicated
Modules required for DBIx::Class::Storage::DBI::Replicated
Moose >= 0.98
MooseX::Types >= 0.21
MooseX::Types::LoadableClass >= 0.011
IMPORT-LIKE ACTIONS
Even though this module is not an Exporter, it recognizes several actions
supplied to its import
method.
-skip_all_without
A convenience wrapper for use during testing:
use DBIx::Class::Optional::Dependencies -skip_all_without => qw(admin test_rdbms_mysql);
Roughly equivalent to the following code:
BEGIN {
require DBIx::Class::Optional::Dependencies;
if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for(\@group_names_) ) {
print "1..0 # SKIP requirements not satisfied: $missing\n";
exit 0;
}
}
It also takes into account the RELEASE_TESTING
environment variable and behaves like "-die_without" for any requirement groups marked as release_testing_mandatory
.
-die_without
A convenience wrapper around "die_unless_req_ok_for":
use DBIx::Class::Optional::Dependencies -die_without => qw(deploy admin);
-list_missing
A convenience wrapper around "modreq_missing_for":
perl -Ilib -MDBIx::Class::Optional::Dependencies=-list_missing,deploy,admin | cpanm
METHODS
req_group_list
This method should be used by DBIx::Class packagers, to get a hashref of all dependencies keyed by dependency group. Each key (group name), or a combination thereof (as an arrayref) can be supplied to the methods below. The values of the returned hash are currently a set of options without a well defined structure. If you have use for any of the contents - contact the maintainers, instead of treating this as public (left alone stable) API.
req_list_for
This method should be used by DBIx::Class extension authors, to determine the version of modules a specific set of features requires for this version of DBIx::Class (regardless of their availability on the system). See the "SYNOPSIS" for a real-world example.
When handling test_*
groups this method behaves differently from "modreq_list_for" below (and is the only such inconsistency among the req_*
methods). If a particular group declares as requirements some environment variables
and these requirements are not satisfied (the envvars are unset) - then the module requirements
of this group are not included in the returned list.
modreq_list_for
Same as "req_list_for" but does not take into consideration any environment variable requirements
- returns just the list of required modules.
req_ok_for
Returns true or false depending on whether all modules/envvars required by the group(s) are loadable/set on the system.
req_missing_for
Returns a single-line string suitable for inclusion in larger error messages. This method would normally be used by DBIx::Class core features, to indicate to the user that they need to install specific modules and/or set specific environment variables before being able to use a specific feature set.
For example if some of the requirements for deploy
are not available, the returned string could look like:
"SQL::Translator~0.11018" (see DBIx::Class::Optional::Dependencies documentation for details)
The author is expected to prepend the necessary text to this message before returning the actual error seen by the user. See also "modreq_missing_for"
modreq_missing_for
Same as "req_missing_for" except that the error string is guaranteed to be either empty, or contain a set of module requirement specifications suitable for piping to e.g. cpanminus. The method explicitly does not attempt to validate the state of required environment variables (if any).
For instance if some of the requirements for deploy
are not available, the returned string could look like:
"SQL::Translator~0.11018"
See also "-list_missing".
skip_without
A convenience wrapper around skip. It does not take neither a reason (it is generated by "req_missing_for") nor an amount of skipped tests (it is always 1
, thus mandating unconditional use of done_testing). Most useful in combination with ad hoc requirement specifications:
SKIP: {
DBIx::Class::Optional::Dependencies->skip_without([ deploy YAML>=0.90 ]);
...
}
die_unless_req_ok_for
Checks if "req_ok_for" passes for the supplied group(s), and in case of failure throws an exception including the information from "req_missing_for". See also "-die_without".
modreq_errorlist_for
Returns a hashref containing the actual errors that occurred while attempting to load each module in the requirement group(s).
req_errorlist_for
Deprecated method name, equivalent (via proxy) to "modreq_errorlist_for".
FURTHER QUESTIONS?
Check the list of additional DBIC resources.
COPYRIGHT AND LICENSE
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.