line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Utils::PlaceholderNamed; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
99557
|
use strict;
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
149
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings;
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
132
|
|
5
|
4
|
|
|
4
|
|
25
|
use Carp qw(confess);
|
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
214
|
|
6
|
4
|
|
|
4
|
|
1792
|
use Moo;
|
|
4
|
|
|
|
|
46586
|
|
|
4
|
|
|
|
|
28
|
|
7
|
4
|
|
|
4
|
|
7227
|
use MooX::StrictConstructor;
|
|
4
|
|
|
|
|
47290
|
|
|
4
|
|
|
|
|
25
|
|
8
|
4
|
|
|
4
|
|
90596
|
use MooX::Types::MooseLike::Base qw(Bool CodeRef);
|
|
4
|
|
|
|
|
24151
|
|
|
4
|
|
|
|
|
354
|
|
9
|
4
|
|
|
4
|
|
2234
|
use namespace::autoclean;
|
|
4
|
|
|
|
|
54068
|
|
|
4
|
|
|
|
|
20
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.003';
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has is_strict => (
|
14
|
|
|
|
|
|
|
is => 'rw',
|
15
|
|
|
|
|
|
|
isa => Bool,
|
16
|
|
|
|
|
|
|
);
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has modifier_code => (
|
19
|
|
|
|
|
|
|
is => 'rw',
|
20
|
|
|
|
|
|
|
isa => CodeRef,
|
21
|
|
|
|
|
|
|
clearer => 'clear_modifier_code',
|
22
|
|
|
|
|
|
|
);
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _mangle_value {
|
25
|
17
|
|
|
17
|
|
53
|
my ($self, $placeholder, $value, $attribute) = @_;
|
26
|
|
|
|
|
|
|
|
27
|
17
|
100
|
|
|
|
74
|
defined $value
|
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
or return $self->is_strict ? $placeholder : q{};
|
29
|
15
|
100
|
|
|
|
74
|
defined $attribute
|
30
|
|
|
|
|
|
|
or return $value;
|
31
|
2
|
50
|
|
|
|
50
|
$self->modifier_code
|
32
|
|
|
|
|
|
|
or return $value;
|
33
|
2
|
|
|
|
|
42
|
$value = $self->modifier_code->($value, $attribute);
|
34
|
2
|
50
|
|
|
|
31
|
defined $value
|
35
|
|
|
|
|
|
|
or confess 'modifier_code returns nothing or undef';
|
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
9
|
return $value;
|
38
|
|
|
|
|
|
|
}
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub expand_named {
|
41
|
10
|
|
|
10
|
1
|
3802
|
my ($self, $text, @args) = @_;
|
42
|
|
|
|
|
|
|
|
43
|
10
|
100
|
|
|
|
38
|
defined $text
|
44
|
|
|
|
|
|
|
or return $text;
|
45
|
9
|
50
|
|
|
|
45
|
my $arg_ref = @args == 1
|
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
? $args[0]
|
47
|
|
|
|
|
|
|
: {
|
48
|
|
|
|
|
|
|
@args % 2
|
49
|
|
|
|
|
|
|
? confess 'Arguments expected pairwise'
|
50
|
|
|
|
|
|
|
: @args
|
51
|
|
|
|
|
|
|
};
|
52
|
|
|
|
|
|
|
|
53
|
9
|
|
|
|
|
21
|
my $regex = join q{|}, map { quotemeta } keys %{$arg_ref};
|
|
16
|
|
|
|
|
43
|
|
|
9
|
|
|
|
|
30
|
|
54
|
|
|
|
|
|
|
## no critic (EscapedMetacharacters)
|
55
|
9
|
|
|
|
|
297
|
$text =~ s{
|
56
|
|
|
|
|
|
|
(
|
57
|
|
|
|
|
|
|
\{
|
58
|
|
|
|
|
|
|
( $regex )
|
59
|
|
|
|
|
|
|
(?: [ ]* [:] ( [^\}]+ ) )?
|
60
|
|
|
|
|
|
|
\}
|
61
|
|
|
|
|
|
|
)
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
{
|
64
|
17
|
|
|
|
|
75
|
$self->_mangle_value($1, $arg_ref->{$2}, $3)
|
65
|
|
|
|
|
|
|
}xmsge;
|
66
|
|
|
|
|
|
|
## use critic (EscapedMetacharacters)
|
67
|
|
|
|
|
|
|
|
68
|
9
|
|
|
|
|
76
|
return $text;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable;
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1;
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__
|