X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FOptional%2FDependencies.pm;h=5cb513b558f6d76ad9b2a032abafd544a7330ce1;hb=e1b7e9b4ead77ee05830c2462cdb96c778b534f8;hp=780f6c310d12c2221d41214a86a410b854e0e54b;hpb=b718fd0a54e55098bf7103e9af83de9db4b192ab;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 780f6c3..5cb513b 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -32,8 +32,7 @@ my $reqs = { replicated => { req => { %$moose_basic, - 'namespace::clean' => '0.11', - 'Hash::Merge' => '0.11', + 'Hash::Merge' => '0.12', }, pod => { title => 'Storage::Replicated', @@ -66,7 +65,7 @@ my $reqs = { deploy => { req => { - 'SQL::Translator' => '0.11002', + 'SQL::Translator' => '0.11006', }, pod => { title => 'Storage::DBI::deploy()', @@ -74,28 +73,55 @@ my $reqs = { }, }, - author => { + + test_pod => { + req => { + 'Test::Pod' => '1.41', + }, + }, + + test_podcoverage => { req => { - 'Test::Pod' => '1.26', 'Test::Pod::Coverage' => '1.08', 'Pod::Coverage' => '0.20', - #'Test::NoTabs' => '0.9', - #'Test::EOL' => '0.6', }, }, - core => { + test_notabs => { + req => { + 'Test::NoTabs' => '0.9', + }, + }, + + test_eol => { + req => { + 'Test::EOL' => '0.6', + }, + }, + + test_cycle => { req => { - # t/52cycle.t 'Test::Memory::Cycle' => '0', 'Devel::Cycle' => '1.10', + }, + }, + test_dtrelated => { + req => { # t/36datetime.t # t/60core.t 'DateTime::Format::SQLite' => '0', # t/96_is_deteministic_value.t 'DateTime::Format::Strptime'=> '0', + + # t/inflate/datetime_mysql.t + # (doesn't need Mysql itself) + 'DateTime::Format::MySQL' => '0', + + # t/inflate/datetime_pg.t + # (doesn't need PG itself) + 'DateTime::Format::Pg' => '0', }, }, @@ -116,7 +142,6 @@ my $reqs = { ? ( 'Sys::SigAction' => '0', 'DBD::Pg' => '2.009002', - 'DateTime::Format::Pg' => '0', ) : () }, }, @@ -125,7 +150,6 @@ my $reqs = { req => { $ENV{DBICTEST_MYSQL_DSN} ? ( - 'DateTime::Format::MySQL' => '0', 'DBD::mysql' => '0', ) : () }, @@ -136,6 +160,7 @@ my $reqs = { $ENV{DBICTEST_ORA_DSN} ? ( 'DateTime::Format::Oracle' => '0', + 'DBD::Oracle' => '1.24', ) : () }, }, @@ -151,18 +176,24 @@ my $reqs = { rdbms_asa => { req => { - grep $_, @ENV{qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/} + (scalar grep { $ENV{$_} } (qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/) ) ? ( 'DateTime::Format::Strptime' => 0, ) : () }, }, -}; + rdbms_db2 => { + req => { + $ENV{DBICTEST_DB2_DSN} + ? ( + 'DBD::DB2' => 0, + ) : () + }, + }, + +}; -sub _all_optional_requirements { - return { map { %{ $reqs->{$_}{req} || {} } } (keys %$reqs) }; -} sub req_list_for { my ($class, $group) = @_; @@ -246,11 +277,38 @@ sub _check_deps { } } +sub req_group_list { + return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) }; +} + +# This is to be called by the author only (automatically in Makefile.PL) sub _gen_pod { + my $class = shift; my $modfn = __PACKAGE__ . '.pm'; $modfn =~ s/\:\:/\//g; + my $podfn = __FILE__; + $podfn =~ s/\.pm$/\.pod/; + + my $distver = + eval { require DBIx::Class; DBIx::Class->VERSION; } + || + do { + warn +"\n\n---------------------------------------------------------------------\n" . +'Unable to load core DBIx::Class module to determine current version, '. +'possibly due to missing dependencies. Author-mode autodocumentation ' . +"halted\n\n" . $@ . +"\n\n---------------------------------------------------------------------\n" + ; + '*UNKNOWN*'; # rv + } + ; + + my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'} + or die "Hrmm? No sqlt dep?"; + my @chunks = ( <<"EOC", ######################################################################### @@ -263,7 +321,28 @@ sub _gen_pod { # EOC '=head1 NAME', - "$class - Optional module dependency specifications", + "$class - Optional module dependency specifications (for module authors)", + '=head1 SYNOPSIS', + <'s Makefile.PL): + + ... + + configure_requires 'DBIx::Class' => '$distver'; + + require $class; + + my \$deploy_deps = $class->req_list_for ('deploy'); + + for (keys %\$deploy_deps) { + requires \$_ => \$deploy_deps->{\$_}; + } + + ... + +Note that there are some caveats regarding C, more info +can be found at L +EOS '=head1 DESCRIPTION', <<'EOD', Some of the less-frequently used features of L have external @@ -272,13 +351,14 @@ with modules he 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 is missing one or several modules required for its operation. This module is the central holding place for the current list -of such dependencies. +of such dependencies, for DBIx::Class core authors, and DBIx::Class extension +authors alike. EOD '=head1 CURRENT REQUIREMENT GROUPS', <<'EOD', Dependencies are organized in C and each group can list one or more required modules, with an optional minimum version (or 0 for any version). -The group name can be used in the +The group name can be used in the EOD ); @@ -303,6 +383,17 @@ EOD push @chunks, ( '=head1 METHODS', + '=head2 req_group_list', + '=over', + '=item Arguments: $none', + '=item Returns: \%list_of_requirement_groups', + '=back', + <, you can do the following in your -C or C - - require $class; - my \$dep_list = $class->req_list_for ('deploy'); - -Which will give you a list of module/version pairs necessary for the particular -feature to function with this version of DBIx::Class. +version of modules a specific feature requires in the B version of +DBIx::Class. See the L for a real-world +example. EOD '=head2 req_ok_for', @@ -341,10 +424,10 @@ This method would normally be used by DBIx::Class core-module author, to indicate to the user that he needs to install specific modules before he will be able to use a specific feature. -For example if the requirements for C are not available, the -returned string would look like: +For example if some of the requirements for C are not available, +the returned string could look like: - Moose >= 0.98, MooseX::Types >= 0.21, namespace::clean (see $class for details) + SQL::Translator >= $sqltver (see $class for details) The author is expected to prepend the necessary text to this message before returning the actual error seen by the user. @@ -365,10 +448,7 @@ EOD 'You may distribute this code under the same terms as Perl itself', ); - my $fn = __FILE__; - $fn =~ s/\.pm$/\.pod/; - - open (my $fh, '>', $fn) or croak "Unable to write to $fn: $!"; + open (my $fh, '>', $podfn) or croak "Unable to write to $podfn: $!"; print $fh join ("\n\n", @chunks); close ($fh); }