line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package custom::failures::x::alias; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: export aliases for custom::failures |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
234986
|
use v5.10.0; |
|
1
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
489
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _croak { |
13
|
0
|
|
|
0
|
|
0
|
require Carp; |
14
|
0
|
|
|
|
|
0
|
goto \&Carp::croak; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _alias { |
18
|
7
|
|
|
7
|
|
18
|
my ( $failure, $opt ) = @_; |
19
|
7
|
|
|
|
|
19
|
$failure =~ s/::/_/g; |
20
|
7
|
|
100
|
|
|
54
|
return ($opt->{-prefix} // '') . $failure . ($opt->{-suffix} // '') ; |
|
|
|
100
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub import { |
24
|
6
|
|
|
6
|
|
20988
|
my ( $class, @failures ) = @_; |
25
|
6
|
|
|
|
|
12
|
my $caller; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# mimic what failures::import does to allow specifying the caller |
28
|
6
|
100
|
|
|
|
25
|
if ( 'ARRAY' eq ref $failures[1] ) { |
29
|
5
|
|
|
|
|
12
|
$caller = shift @failures; |
30
|
5
|
|
|
|
|
11
|
@failures = @{ $failures[0] }; |
|
5
|
|
|
|
|
17
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
1
|
|
|
|
|
3
|
$caller = caller; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
14
|
my $export = 'EXPORT_OK'; |
37
|
6
|
|
|
|
|
12
|
my $exporter = 'Exporter'; |
38
|
6
|
|
|
|
|
17
|
my $alias = \&_alias; |
39
|
6
|
|
|
|
|
12
|
my %opt; |
40
|
|
|
|
|
|
|
|
41
|
6
|
|
66
|
|
|
44
|
while ( @failures && substr( $failures[0], 0, 1 ) eq '-' ) { |
42
|
6
|
|
|
|
|
12
|
my $opt = shift @failures; |
43
|
|
|
|
|
|
|
|
44
|
6
|
100
|
|
|
|
32
|
if ( $opt eq '-prefix' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
45
|
1
|
|
33
|
|
|
8
|
$opt{-prefix} = shift( @failures ) |
46
|
|
|
|
|
|
|
// _croak( "missing value for -prefix" ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
elsif ( $opt eq '-suffix' ) { |
50
|
1
|
|
33
|
|
|
7
|
$opt{-suffix} = shift( @failures ) |
51
|
|
|
|
|
|
|
// _croak( "missing value for -suffix" ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
elsif ( $opt eq '-alias' ) { |
55
|
0
|
|
0
|
|
|
0
|
$alias = shift( @failures ) // _croak( "missing value for -alias" ); |
56
|
0
|
0
|
|
|
|
0
|
'CODE' eq ref $alias |
57
|
|
|
|
|
|
|
or _croak( "-alias must be a coderef" ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
elsif ( $opt eq '-export' ) { |
61
|
3
|
|
|
|
|
13
|
$export = 'EXPORT'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
elsif ( $opt eq '-exporter' ) { |
65
|
1
|
|
33
|
|
|
4
|
$exporter = shift( @failures ) |
66
|
|
|
|
|
|
|
// _croak( "missing value for -exporter" ); |
67
|
1
|
50
|
|
1
|
|
10
|
eval "use $exporter ; 1 " ## no critic (ProhibitStringyEval) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
73
|
|
68
|
|
|
|
|
|
|
|| _croak( |
69
|
|
|
|
|
|
|
"requested exporter '$exporter' cannot be loaded: $@" ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
6
|
|
|
|
|
579
|
require custom::failures; |
76
|
6
|
|
|
|
|
5670
|
custom::failures->import( $caller => \@failures ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
{ |
79
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; ## no critic (ProhibitNoStrict) |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
287
|
|
|
6
|
|
|
|
|
558
|
|
80
|
|
|
|
|
|
|
|
81
|
6
|
|
|
|
|
12
|
my @export; |
82
|
6
|
|
|
|
|
17
|
for my $failure ( @failures ) { |
83
|
7
|
|
|
|
|
21
|
my $alias = $alias->( $failure, \%opt ); |
84
|
7
|
|
|
|
|
18
|
push @export, $alias; |
85
|
7
|
|
|
|
|
18
|
my $fqn = "${caller}::${alias}"; |
86
|
11
|
|
|
11
|
|
21425
|
*$fqn = sub () { "${caller}::${failure}" } |
87
|
7
|
|
|
|
|
74
|
} |
88
|
|
|
|
|
|
|
|
89
|
6
|
100
|
|
|
|
22
|
if ( $exporter eq 'Exporter' ) { |
90
|
5
|
|
|
|
|
24
|
require Exporter; |
91
|
5
|
|
|
|
|
13
|
my $fqn = "${caller}::import"; |
92
|
5
|
|
|
|
|
46
|
*$fqn = \&Exporter::import; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else { |
95
|
1
|
|
|
|
|
4
|
my $fqn = "${caller}::ISA"; |
96
|
1
|
|
50
|
|
|
3
|
my $ISA = *{$fqn}{ARRAY} // ( *$fqn = [] ); |
|
1
|
|
|
|
|
7
|
|
97
|
1
|
|
|
|
|
18
|
push @$ISA, $exporter; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
{ |
101
|
6
|
|
|
|
|
15
|
my $fqn = "${caller}::${export}"; |
102
|
6
|
|
50
|
|
|
10
|
my $export = *{$fqn}{ARRAY} // ( *$fqn = [] ); |
|
6
|
|
|
|
|
58
|
|
103
|
6
|
|
|
|
|
20
|
push @$export, @export; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
{ |
107
|
6
|
|
|
|
|
18
|
my $fqn = "${caller}::EXPORT_TAGS"; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
14
|
|
108
|
6
|
|
50
|
|
|
10
|
my $tags = *{$fqn}{HASH} // ( *$fqn = {} ); |
|
6
|
|
|
|
|
47
|
|
109
|
6
|
|
50
|
|
|
12
|
push @{ $tags->{all} //= [] }, @export; |
|
6
|
|
|
|
|
34
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
6
|
|
|
|
|
3680
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# |
119
|
|
|
|
|
|
|
# This file is part of custom-failures-x-alias |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
# This software is Copyright (c) 2021 by Smithsonian Astrophysical Observatory. |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
# This is free software, licensed under: |
124
|
|
|
|
|
|
|
# |
125
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
126
|
|
|
|
|
|
|
# |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |