### 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
#@@
push @chunks, <<'EOC';
+=head1 IMPORT-LIKE ACTIONS
+
+Even though this module is not an L<Exporter>, it recognizes several C<actions>
+supplied to its C<import> method.
+
+=head2 -die_without
+
+=over
+
+=item Arguments: @group_names
+
+=back
+
+A convenience wrapper around L</die_unless_req_ok_for>:
+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</modreq_missing_for>:
+
+ perl -Ilib -MDBIx::Class::Optional::Dependencies=-list_missing,deploy,admin | cpanm
+
=head1 METHODS
=head2 req_group_list
push @chunks, qq{ "SQL::Translator~>=$sqltver"};
push @chunks, <<'EOC';
+
+See also L</-list_missing>.
+
=head2 die_unless_req_ok_for
=over
Checks if L</req_ok_for> passes for the supplied group(s), and
in case of failure throws an exception including the information
-from L</req_missing_for>.
+from L</req_missing_for>. See also L</-die_without>.
=head2 modreq_errorlist_for
package MY;
sub distdir {
(my $snippet = shift->SUPER::distdir(@_)) =~ s/^create_distdir :/create_distdir_copy_manifested :/;
+ no warnings 'qw';
return <<"EOM";
$snippet
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
sub postamble {
my $snippet = shift->SUPER::postamble(@_);
+ no warnings 'qw';
return <<"EOM";
$snippet
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
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 "==========================================="