File Coverage

blib/lib/Locale/TextDomain/OO/Plugin/Expand/Maketext.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 6 66.6
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 45 47 95.7


line stmt bran cond sub pod time code
1             package Locale::TextDomain::OO::Plugin::Expand::Maketext; ## no critic (TidyCode)
2            
3 8     8   8477 use strict;
  8         23  
  8         261  
4 8     8   50 use warnings;
  8         52  
  8         216  
5 8     8   1093 use Locale::Utils::PlaceholderMaketext;
  8         17776  
  8         225  
6 8     8   54 use Moo::Role;
  8         27  
  8         52  
7            
8             our $VERSION = '1.027';
9            
10             requires qw(
11             translate
12             filter
13             run_filter
14             );
15            
16             has expand_maketext => (
17             is => 'rw',
18             default => sub {
19             return Locale::Utils::PlaceholderMaketext->new;
20             },
21             );
22            
23             sub maketext {
24 23     23 1 8407 my ($self, $msgid, @args) = @_;
25            
26 23         87 my $translation = $self->translate(undef, $msgid);
27 23         129 $translation = $self->expand_maketext->expand_maketext(
28             $translation,
29             @args,
30             );
31 23 50       2217 $self->filter
32             and $self->run_filter(\$translation);
33            
34 23         282 return $translation;
35             }
36            
37             sub maketext_p {
38 11     11 1 45 my ($self, $msgctxt, $msgid, @args) = @_;
39            
40 11         45 my $translation = $self->translate($msgctxt, $msgid);
41 11         80 $translation = $self->expand_maketext->expand_maketext(
42             $translation,
43             @args,
44             );
45 11 50       965 $self->filter
46             and $self->run_filter(\$translation);
47            
48 11         136 return $translation;
49             }
50            
51             BEGIN {
52 8     8   5419 no warnings qw(redefine); ## no critic (NoWarnings)
  8         30  
  8         761  
53            
54             # Dummy methods for string marking.
55             my $dummy = sub {
56 11     11   44 my (undef, @more) = @_;
57 11 100       93 return wantarray ? @more : $more[0];
58 8     8   64 };
59 8         29 *Nmaketext = $dummy;
60 8         260 *Nmaketext_p = $dummy;
61             }
62            
63             1;
64            
65             __END__