our $VERSION = '0.001007';
+use Carp 'croak';
use List::Util 'first';
sub import {
my ($self, @args) = @_;
my $inner_target = caller(0);
- my ($TOO_COMPLICATED, $export_data) = sub_export_options($inner_target, @args);
-
- die <<'DEATH' if $TOO_COMPLICATED;
-You are using Sub::Exporter::Progressive, but the features your program uses from
-Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
-just use vanilla Sub::Exporter
-DEATH
+ my $export_data = sub_export_options($inner_target, @args);
my $full_exporter;
no strict;
};
}
+my $too_complicated = <<'DEATH';
+You are using Sub::Exporter::Progressive, but the features your program uses from
+Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
+just use vanilla Sub::Exporter
+DEATH
+
sub sub_export_options {
my ($inner_target, $setup, $options) = @_;
- my $TOO_COMPLICATED = 0;
-
my @exports;
my @defaults;
my %tags;
for my $opt (keys %options) {
if ($opt eq 'exports') {
- $TOO_COMPLICATED = 1, last OPTIONS
- if ref $options{exports} ne 'ARRAY';
-
+ croak $too_complicated if ref $options{exports} ne 'ARRAY';
@exports = @{$options{exports}};
-
- $TOO_COMPLICATED = 1, last OPTIONS
- if first { ref } @exports;
+ croak $too_complicated if first { ref } @exports;
} elsif ($opt eq 'groups') {
%tags = %{$options{groups}};
for my $tagset (values %tags) {
- $TOO_COMPLICATED = 1 if first { /^-(?!all\b)/ || ref } @{$tagset};
+ croak $too_complicated if first { /^-(?!all\b)/ || ref } @{$tagset};
}
@defaults = @{$tags{default} || [] };
} else {
- $TOO_COMPLICATED = 1;
- last OPTIONS
+ croak $too_complicated;
}
}
@{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags;
die join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors;
}
- return $TOO_COMPLICATED, {
+ return {
exports => \@exports,
defaults => \@defaults,
original => $options,
tags => \%tags,
- }
+ };
}
1;