From: Peter Rabbitson Date: Sat, 13 Feb 2010 13:32:50 +0000 (+0000) Subject: Switch Admin/dbicadmin to Opt::Deps X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4a02f15a49ccd4ab04bd18ff58d1de7fbe8b23f;p=dbsrgits%2FDBIx-Class-Historic.git Switch Admin/dbicadmin to Opt::Deps --- diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index 8814bf7..e47e93b 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -2,28 +2,14 @@ package DBIx::Class::Admin; # check deps BEGIN { - my @_deps = qw( - Moose MooseX::Types MooseX::Types::JSON MooseX::Types::Path::Class - Try::Tiny parent JSON::Any Class::C3::Componentised - namespace::autoclean - ); - - my @_missing_deps; - foreach my $dep (@_deps) { - eval "require $dep"; - if ($@) { - push @_missing_deps, $dep; - } - } - - if (@_missing_deps > 0) { - die "The following dependecies are missing " . join ",", @_missing_deps; - } + use Carp::Clan qw/^DBIx::Class/; + use DBIx::Class; + croak('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'); } use Moose; use parent 'DBIx::Class::Schema'; -use Carp::Clan qw/^DBIx::Class/; use MooseX::Types::Moose qw/Int Str Any Bool/; use DBIx::Class::Admin::Types qw/DBICConnectInfo DBICHashRef/; @@ -72,31 +58,10 @@ DBIx::Class::Admin - Administration object for schemas =head1 REQUIREMENTS -The following CPAN modules are required to use C and this module: - -L - -L - -L - -L - -L - -L - -L - -(L preferred for barekey support) - -L - -L - -L +The Admin interface has additional requirements not currently part of +L. See L for more details. -=head1 Attributes +=head1 ATTRIBUTES =head2 schema_class diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 99ae149..adc26f9 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -51,7 +51,7 @@ my $reqs = { }, }, - dbicadmin => { + admin_script => { req => { %$moose_basic, %$admin_basic, diff --git a/script/dbicadmin b/script/dbicadmin index c50c50b..2b6a456 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -3,6 +3,13 @@ use strict; use warnings; +BEGIN { + use DBIx::Class; + die ( "The following modules are required for the dbicadmin utility\n" + . DBIx::Class::Optional::Dependencies->req_missing_for ('admin_script') + ) unless DBIx::Class::Optional::Dependencies->req_ok_for ('admin_script'); +} + use Getopt::Long::Descriptive; use DBIx::Class::Admin; @@ -77,15 +84,12 @@ if ($action eq 'select') { } } - - =head1 AUTHOR -Aran Deltac - -refactored by -Gordon Irving +See L. =head1 LICENSE -You may distribute this code under the same terms as Perl itself. +You may distribute this code under the same terms as Perl itself + +=cut diff --git a/t/admin/10script.t b/t/admin/10script.t index d8ccbfc..7718b34 100644 --- a/t/admin/10script.t +++ b/t/admin/10script.t @@ -11,8 +11,8 @@ use DBICTest; BEGIN { require DBIx::Class; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('dbicadmin') - unless DBIx::Class::Optional::Dependencies->req_ok_for('dbicadmin'); + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin_script') + unless DBIx::Class::Optional::Dependencies->req_ok_for('admin_script'); } my @json_backends = qw/XS JSON DWIW/;