line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Exporter::Progressive; |
2
|
|
|
|
|
|
|
$Sub::Exporter::Progressive::VERSION = '0.001012'; |
3
|
6
|
|
|
6
|
|
105799
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
132
|
|
4
|
6
|
|
|
6
|
|
21
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
487
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Only use Sub::Exporter if you need it |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _croak { |
9
|
1
|
|
|
1
|
|
4
|
require Carp; |
10
|
1
|
|
|
|
|
149
|
&Carp::croak; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
7
|
|
|
7
|
|
285
|
my ($self, @args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
16
|
my $inner_target = caller; |
17
|
7
|
|
|
|
|
18
|
my $export_data = sub_export_options($inner_target, @args); |
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
|
|
8
|
my $full_exporter; |
20
|
6
|
|
|
6
|
|
21
|
no strict 'refs'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
437
|
|
21
|
7
|
|
|
|
|
8
|
@{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}}; |
|
7
|
|
|
|
|
37
|
|
|
7
|
|
|
|
|
12
|
|
22
|
7
|
|
|
|
|
11
|
@{"${inner_target}::EXPORT"} = @{$export_data->{defaults}}; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
10
|
|
23
|
7
|
|
|
|
|
7
|
%{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}}; |
|
7
|
|
|
|
|
32
|
|
|
7
|
|
|
|
|
14
|
|
24
|
7
|
|
|
|
|
27
|
*{"${inner_target}::import"} = sub { |
25
|
6
|
|
|
6
|
|
19
|
use strict; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
3356
|
|
26
|
18
|
|
|
18
|
|
9766
|
my ($self, @args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
18
|
100
|
|
|
|
37
|
if ( grep { |
|
|
100
|
|
|
|
|
|
29
|
21
|
100
|
|
|
|
160
|
length ref $_ |
30
|
|
|
|
|
|
|
or |
31
|
|
|
|
|
|
|
$_ !~ / \A [:-]? \w+ \z /xm |
32
|
|
|
|
|
|
|
} @args ) { |
33
|
|
|
|
|
|
|
_croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed' |
34
|
1
|
50
|
|
|
|
1
|
unless eval { require Sub::Exporter }; |
|
1
|
|
|
|
|
7
|
|
35
|
1
|
|
33
|
|
|
5
|
$full_exporter ||= Sub::Exporter::build_exporter($export_data->{original}); |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
144
|
goto $full_exporter; |
38
|
19
|
|
|
|
|
65
|
} elsif ( defined( (my ($num) = grep { m/^\d/ } @args)[0] ) ) { |
39
|
1
|
|
|
|
|
5
|
_croak "cannot export symbols with a leading digit: '$num'"; |
40
|
|
|
|
|
|
|
} else { |
41
|
16
|
|
|
|
|
63
|
require Exporter; |
42
|
16
|
|
|
|
|
43
|
s/ \A - /:/xm for @args; |
43
|
16
|
|
|
|
|
31
|
@_ = ($self, @args); |
44
|
16
|
|
|
|
|
5098
|
goto \&Exporter::import; |
45
|
|
|
|
|
|
|
} |
46
|
7
|
|
|
|
|
30
|
}; |
47
|
7
|
|
|
|
|
282
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $too_complicated = <<'DEATH'; |
51
|
|
|
|
|
|
|
You are using Sub::Exporter::Progressive, but the features your program uses from |
52
|
|
|
|
|
|
|
Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well |
53
|
|
|
|
|
|
|
just use vanilla Sub::Exporter |
54
|
|
|
|
|
|
|
DEATH |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub sub_export_options { |
57
|
7
|
|
|
7
|
0
|
8
|
my ($inner_target, $setup, $options) = @_; |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
|
|
11
|
my @exports; |
60
|
|
|
|
|
|
|
my @defaults; |
61
|
0
|
|
|
|
|
0
|
my %tags; |
62
|
|
|
|
|
|
|
|
63
|
7
|
50
|
50
|
|
|
38
|
if ( ($setup||'') eq '-setup') { |
64
|
7
|
|
|
|
|
32
|
my %options = %$options; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
OPTIONS: |
67
|
7
|
|
|
|
|
21
|
for my $opt (keys %options) { |
68
|
13
|
100
|
|
|
|
35
|
if ($opt eq 'exports') { |
|
|
50
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
7
|
50
|
|
|
|
26
|
_croak $too_complicated if ref $options{exports} ne 'ARRAY'; |
71
|
7
|
|
|
|
|
10
|
@exports = @{$options{exports}}; |
|
7
|
|
|
|
|
16
|
|
72
|
7
|
50
|
|
|
|
28
|
_croak $too_complicated if grep { length ref $_ } @exports; |
|
18
|
|
|
|
|
34
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} elsif ($opt eq 'groups') { |
75
|
6
|
|
|
|
|
7
|
%tags = %{$options{groups}}; |
|
6
|
|
|
|
|
20
|
|
76
|
6
|
|
|
|
|
13
|
for my $tagset (values %tags) { |
77
|
|
|
|
|
|
|
_croak $too_complicated if grep { |
78
|
12
|
50
|
|
|
|
80
|
length ref $_ |
79
|
|
|
|
|
|
|
or |
80
|
|
|
|
|
|
|
$_ =~ / \A - (?! all \b ) /x |
81
|
11
|
50
|
|
|
|
21
|
} @{$tagset}; |
|
11
|
|
|
|
|
17
|
|
82
|
|
|
|
|
|
|
} |
83
|
6
|
50
|
|
|
|
6
|
@defaults = @{$tags{default} || [] }; |
|
6
|
|
|
|
|
24
|
|
84
|
|
|
|
|
|
|
} else { |
85
|
0
|
|
|
|
|
0
|
_croak $too_complicated; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
7
|
100
|
|
|
|
16
|
@{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags; |
|
18
|
|
|
|
|
33
|
|
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
18
|
|
89
|
7
|
|
50
|
|
|
34
|
$tags{all} ||= [ @exports ]; |
90
|
7
|
|
|
|
|
9
|
my %exports = map { $_ => 1 } @exports; |
|
18
|
|
|
|
|
36
|
|
91
|
7
|
|
|
|
|
10
|
my @errors = grep { not $exports{$_} } @defaults; |
|
7
|
|
|
|
|
16
|
|
92
|
7
|
50
|
|
|
|
26
|
_croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
return { |
96
|
7
|
|
|
|
|
26
|
exports => \@exports, |
97
|
|
|
|
|
|
|
defaults => \@defaults, |
98
|
|
|
|
|
|
|
original => $options, |
99
|
|
|
|
|
|
|
tags => \%tags, |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |