From: Peter Rabbitson Date: Fri, 17 Oct 2014 10:04:58 +0000 (+0200) Subject: Switch all double-optdeps calls to a single invocation in lib/ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c96bf2bceade3ac0654ec8ae4379fc72ff82bed8;p=dbsrgits%2FDBIx-Class-Historic.git Switch all double-optdeps calls to a single invocation in lib/ --- diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index 81dd5b0..ffc236e 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -1,10 +1,14 @@ package DBIx::Class::Admin; +use warnings; +use strict; + # check deps BEGIN { - use DBIx::Class; - die('The following modules are required for DBIx::Class::Admin ' . DBIx::Class::Optional::Dependencies->req_missing_for ('admin') ) - unless DBIx::Class::Optional::Dependencies->req_ok_for ('admin'); + require DBIx::Class::Optional::Dependencies; + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('admin') ) { + die "The following extra modules are required for DBIx::Class::Admin: $missing\n"; + } } use JSON::Any qw(DWIW PP JSON CPANEL XS); diff --git a/lib/DBIx/Class/SQLMaker/Oracle.pm b/lib/DBIx/Class/SQLMaker/Oracle.pm index d1ed9a2..7f42855 100644 --- a/lib/DBIx/Class/SQLMaker/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Oracle.pm @@ -4,14 +4,15 @@ package # Hide from PAUSE use warnings; use strict; -use base qw( DBIx::Class::SQLMaker ); - BEGIN { - use DBIx::Class::Optional::Dependencies; - die('The following extra modules are required for Oracle-based Storages ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') . "\n" ) - unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); + require DBIx::Class::Optional::Dependencies; + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') ) { + die "The following extra modules are required for Oracle-based Storages: $missing\n"; + } } +use base 'DBIx::Class::SQLMaker'; + sub new { my $self = shift; my %opts = (ref $_[0] eq 'HASH') ? %{$_[0]} : @_; diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 84a5851..ba3b445 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -642,8 +642,8 @@ sub _create_db_to_schema_diff { return; } - unless (DBIx::Class::Optional::Dependencies->req_ok_for ('deploy')) { - $self->throw_exception("Unable to proceed without " . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') ); + if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('deploy') ) { + $self->throw_exception("Unable to proceed without $missing"); } my $db_tr = SQL::Translator->new({ diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 8a99d06..7122756 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2871,8 +2871,8 @@ sub create_ddl_dir { %{$sqltargs || {}} }; - unless (DBIx::Class::Optional::Dependencies->req_ok_for ('deploy')) { - $self->throw_exception("Can't create a ddl file without " . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') ); + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('deploy')) { + $self->throw_exception("Can't create a ddl file without $missing"); } my $sqlt = SQL::Translator->new( $sqltargs ); @@ -3028,8 +3028,8 @@ sub deployment_statements { return join('', @rows); } - unless (DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') ) { - $self->throw_exception("Can't deploy without a ddl_dir or " . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') ); + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') ) { + $self->throw_exception("Can't deploy without a pregenerated 'ddl_dir' directory or $missing"); } # sources needs to be a parser arg, but for simplicity allow at top level diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 70fd834..231b5a5 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -1,9 +1,13 @@ package DBIx::Class::Storage::DBI::Replicated; +use warnings; +use strict; + BEGIN { - use DBIx::Class; - die('The following modules are required for Replication ' . DBIx::Class::Optional::Dependencies->req_missing_for ('replicated') . "\n" ) - unless DBIx::Class::Optional::Dependencies->req_ok_for ('replicated'); + require DBIx::Class::Optional::Dependencies; + if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('replicated') ) { + die "The following modules are required for Replicated storage support: $missing\n"; + } } use Moose;