From: Peter Rabbitson Date: Sun, 18 Jan 2015 13:33:28 +0000 (+0100) Subject: Add import-time action stub to OptDeps, switch distbuild checks to it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=afb8fc5295f37e051ab76636d1f73538f42edc08;p=dbsrgits%2FDBIx-Class.git Add import-time action stub to OptDeps, switch distbuild checks to it More in the following commit --- diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index fcf1deb..aee78d0 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -568,6 +568,42 @@ my $dbic_reqs = { ### Public API +sub import { + my $class = shift; + + if (@_) { + + my $action = shift; + + if ($action eq '-die_without') { + my $err; + { + local $@; + eval { $class->die_unless_req_ok_for(\@_); 1 } + or $err = $@; + } + die "\n$err\n" if $err; + } + elsif ($action eq '-list_missing') { + print $class->modreq_missing_for(\@_); + print "\n"; + exit 0; + } + elsif ($action =~ /^-/) { + croak "Unknown import-time action '$action'"; + } + else { + croak "$class is not an exporter, unable to import '$action'"; + } + } + + 1; +} + +sub unimport { + croak( __PACKAGE__ . " does not implement unimport" ); +} + # OO for (mistakenly considered) ease of extensibility, not due to any need to # carry state of any sort. This API is currently used outside, so leave as-is. # FIXME - make sure to not propagate this further if module is extracted as a @@ -972,6 +1008,38 @@ EOC #@@ push @chunks, <<'EOC'; +=head1 IMPORT-LIKE ACTIONS + +Even though this module is not an L, it recognizes several C +supplied to its C method. + +=head2 -die_without + +=over + +=item Arguments: @group_names + +=back + +A convenience wrapper around L: +EOC + + push @chunks, " use $class -die_without => qw(deploy admin);"; + + push @chunks, <<'EOC'; + +=head2 -list_missing + +=over + +=item Arguments: @group_names + +=back + +A convenience wrapper around L: + + perl -Ilib -MDBIx::Class::Optional::Dependencies=-list_missing,deploy,admin | cpanm + =head1 METHODS =head2 req_group_list @@ -1087,6 +1155,9 @@ EOC push @chunks, qq{ "SQL::Translator~>=$sqltver"}; push @chunks, <<'EOC'; + +See also L. + =head2 die_unless_req_ok_for =over @@ -1097,7 +1168,7 @@ EOC Checks if L passes for the supplied group(s), and in case of failure throws an exception including the information -from L. +from L. See also L. =head2 modreq_errorlist_for diff --git a/maint/Makefile.PL.inc/50_redefine_makefile_flow.pl b/maint/Makefile.PL.inc/50_redefine_makefile_flow.pl index 873e669..251c184 100644 --- a/maint/Makefile.PL.inc/50_redefine_makefile_flow.pl +++ b/maint/Makefile.PL.inc/50_redefine_makefile_flow.pl @@ -4,6 +4,7 @@ package MY; sub distdir { (my $snippet = shift->SUPER::distdir(@_)) =~ s/^create_distdir :/create_distdir_copy_manifested :/; + no warnings 'qw'; return <<"EOM"; $snippet @@ -23,7 +24,7 @@ clonedir_cleanup_generated_files : check_create_distdir_prereqs : \t\$(NOECHO) @{[ - $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->die_unless_req_ok_for(q(dist_dir))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/]) + $mm_proto->oneliner("1", [qw( -Ilib -MDBIx::Class::Optional::Dependencies=-die_without,dist_dir )]) ]} EOM @@ -37,6 +38,7 @@ EOM sub postamble { my $snippet = shift->SUPER::postamble(@_); + no warnings 'qw'; return <<"EOM"; $snippet @@ -44,7 +46,7 @@ upload :: check_create_distdir_prereqs check_upload_dist_prereqs check_upload_dist_prereqs : \t\$(NOECHO) @{[ - $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->die_unless_req_ok_for(q(dist_upload))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/]) + $mm_proto->oneliner("1", [qw( -Ilib -MDBIx::Class::Optional::Dependencies=-die_without,dist_upload )]) ]} EOM diff --git a/maint/travis-ci_scripts/50_after_success.bash b/maint/travis-ci_scripts/50_after_success.bash index 5571e2b..a7b78dd 100755 --- a/maint/travis-ci_scripts/50_after_success.bash +++ b/maint/travis-ci_scripts/50_after_success.bash @@ -6,7 +6,7 @@ source maint/travis-ci_scripts/common.bash if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then exit 0 ; fi if [[ "$CLEANTEST" != "true" ]] ; then - parallel_installdeps_notest $(perl -Ilib -MDBIx::Class -e 'print join " ", keys %{DBIx::Class::Optional::Dependencies->req_list_for("dist_dir")}') + parallel_installdeps_notest $(perl -Ilib -MDBIx::Class::Optional::Dependencies=-list_missing,dist_dir) run_or_err "Attempt to build a dist with all prereqs present" "make dist" echo "Contents of the resulting dist tarball:" echo "==========================================="