From: Peter Rabbitson Date: Fri, 12 Feb 2010 13:03:17 +0000 (+0000) Subject: Move replicated to Opt::Deps X-Git-Tag: v0.08119~14^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=a34b0c8943373100618907cc1613529bd6214142 Move replicated to Opt::Deps --- diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 64198da..ae16aa9 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -2,27 +2,9 @@ package DBIx::Class::Storage::DBI::Replicated; BEGIN { use Carp::Clan qw/^DBIx::Class/; - - ## Modules required for Replication support not required for general DBIC - ## use, so we explicitly test for these. - - my %replication_required = ( - 'Moose' => '0.98', - 'MooseX::Types' => '0.21', - 'namespace::clean' => '0.11', - 'Hash::Merge' => '0.11' - ); - - my @didnt_load; - - for my $module (keys %replication_required) { - eval "use $module $replication_required{$module}"; - push @didnt_load, "$module $replication_required{$module}" - if $@; - } - - croak("@{[ join ', ', @didnt_load ]} are missing and are required for Replication") - if @didnt_load; + use DBIx::Class; + croak('The following modules are required for Replication ' . DBIx::Class::Optional::Dependencies->req_missing_for ('replicated') ) + unless DBIx::Class::Optional::Dependencies->req_ok_for ('replicated'); } use Moose; @@ -119,15 +101,10 @@ to force a query to run against Master when needed. =head1 REQUIREMENTS -Replicated Storage has additional requirements not currently part of L - - Moose => '0.98', - MooseX::Types => '0.21', - namespace::clean => '0.11', - Hash::Merge => '0.11' - -You will need to install these modules manually via CPAN or make them part of the -Makefile for your distribution. +Replicated Storage has additional requirements not currently part of +L The missing requirements will be announced via an exception +when you try to load this module. You will need to install these modules +manually via CPAN or make them part of the Makefile for your distribution. =head1 ATTRIBUTES diff --git a/t/storage/replication.t b/t/storage/replicated.t similarity index 98% rename from t/storage/replication.t rename to t/storage/replicated.t index 5b74ab9..b14553b 100644 --- a/t/storage/replication.t +++ b/t/storage/replicated.t @@ -10,8 +10,12 @@ use File::Spec; use IO::Handle; BEGIN { - eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose"; - plan skip_all => "Deps not installed: $@" if $@; + eval { require Test::Moose; Test::Moose->import() }; + plan skip_all => "Need Test::Moose to run this test" if $@; + require DBIx::Class; + + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('replicated') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('replicated'); } use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';