File Coverage

blib/lib/Locale/TextDomain/OO/Lexicon/File/PO.pm
Criterion Covered Total %
statement 32 32 100.0
branch 5 6 83.3
condition 1 2 50.0
subroutine 7 7 100.0
pod 1 1 100.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             package Locale::TextDomain::OO::Lexicon::File::PO; ## no critic (TidyCode)
2            
3 2     2   4622 use strict;
  2         4  
  2         58  
4 2     2   10 use warnings;
  2         4  
  2         54  
5 2     2   10 use Carp qw(confess);
  2         4  
  2         99  
6             require Locale::PO;
7 2     2   10 use Moo;
  2         4  
  2         10  
8 2     2   577 use MooX::StrictConstructor;
  2         4  
  2         12  
9 2     2   1581 use namespace::autoclean;
  2         5  
  2         13  
10            
11             our $VERSION = '1.031';
12            
13             with qw(
14             Locale::TextDomain::OO::Lexicon::Role::File
15             );
16            
17             sub read_messages {
18 2     2 1 9 my ($self, $filename) = @_;
19            
20 2   50     7 $filename ||= q{};
21 2 50       11 my $content_ref = Locale::PO->load_file_asarray($filename)
22             or confess "File not found $filename";
23            
24             return [
25             map { ## no critic (ComplexMappings)
26 17         103 my $po = $_;
27             +{
28             do {
29             map { ## no critic (ComplexMappings)
30 17         33 my $value = $po->$_;
  68         677  
31 68 100       395 defined $value
32             ? ( $_ => $po->dequote($value) )
33             : ();
34             } qw( msgctxt msgid msgid_plural msgstr )
35             },
36 17         23 do {
37 17         236 my $msgstr_n = $po->msgstr_n;
38             defined $msgstr_n
39             ? (
40             msgstr_plural => [
41             map {
42 14         155 $po->dequote( $msgstr_n->{$_} );
43 17 100       127 } sort keys %{$msgstr_n}
  6         27  
44             ]
45             )
46             : ();
47             },
48             };
49 2         5274 } @{$content_ref}
  2         7  
50             ];
51             }
52            
53             1;
54            
55             __END__