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