Header/ExtendedItem.pm

filter: Statementstmt 100% 42 / 42 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 93.7% 60 / 64 CC 6 SCAR 6.9
CC
6
Cov
98%
extract_msgstr
3.0
lines
3.0
data
2.0
CRAP 2.0
« Header/Base.pm ↑ Summary Header/Item.pm »
1 package Locale::File::PO::Header::ExtendedItem; ## no critic (TidyCode)
2
3 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 5 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 5 our $VERSION = '0.004';
11
12 5 extends qw(Locale::File::PO::Header::Base);
13
14 5 has name => (
15 is => 'rw',
16 isa => 'Str',
17 );
18
19 3 ▶subtype ExtendedArray => as 'ArrayRef[Str]' => where {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 3 @{$_} % 2 == 0;
21 5 };
22
23 5 has extended => (
24 is => 'rw',
25 isa => 'ExtendedArray|Undef',
26 );
27
28 2 ▶sub data {
Subroutine data: called CC=2 SCAR=6.9
Pod undocumented
29 2 my ($self, $key, @args) = @_;
30
31 2 ▶ return $self->extended( @args ? $args[0] : () );
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 1 1 2
32 }
33
34 2 ▶sub extract_msgstr {
Subroutine extract_msgstr: called CC=3 SCAR=11.0
Pod undocumented
35 2 my ($self, $msgstr_ref) = @_;
36
37 2 my @extended;
38 2 ▶ while (
Branch: 1 branch
BranchTrueFalseTotal
if (${$msgstr_ref;} =~ s/ ^ ( [^:\n]*? ) : \s* ( [^\n]*? ) \s* $ //msx) 5 2 7
39 7 ${$msgstr_ref} =~ s{
40 ^
41 ( [^:\n]*? ) :
42 \s*
43 ( [^\n]*? )
44 \s*
45 $
46 }{}xms
47 ) {
48 5 push @extended, $1, $2;
49 }
50 2 ▶ $self->extended( @extended ? \@extended : undef );
Branch: 1 branch
BranchTrueFalseTotal
@extended ? : 2 0 2
51
52 2 return;
53 }
54
55 3 ▶sub lines {
Subroutine lines: called CC=3 SCAR=11.0
Pod undocumented
56 3 my $self = shift;
57
58 3 my $extended = $self->extended;
59 3 ▶ defined $extended
Branch: 1 branch
BranchTrueFalseTotal
defined $extended or return 2 1 3
60 or return;
61
62 2 $extended = clone($extended);
63 2 my @lines;
64 2 ▶ while ( my ($name, $value) = splice @{$extended}, 0, 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@{$extended;}, 0, 2)) 5 2 7
65 5 push @lines, $self->format_line(
66 '{name}: {value}',
67 name => $name,
68 value => $value,
69 );
70 }
71
72 2 return @lines;
73 }
74
75 5 __PACKAGE__->meta->make_immutable;
76
77 # $Id:$
78
79 5 1;
« Header/Base.pm ↑ Summary Header/Item.pm »