| 1 | package Locale::File::PO::Header::MailItem; ## 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 namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | our $VERSION = '0.004'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | extends qw(Locale::File::PO::Header::Base); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | has name => ( | |||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||
| 13 | isa => 'Str', | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | has mail_name => ( | ||||||||||||||||||||||||||||
| 17 | is => 'rw', | ||||||||||||||||||||||||||||
| 18 | isa => 'Str|Undef', | ||||||||||||||||||||||||||||
| 19 | default => q{}, | ||||||||||||||||||||||||||||
| 20 | 19 | ▶ | trigger => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 19 | my ($self, $mail_name, $current_mail_name) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 19 | return $self->trigger_helper({ | |||||||||||||||||||||||||||
| 24 | new => $mail_name, | ||||||||||||||||||||||||||||
| 25 | current => $current_mail_name, | ||||||||||||||||||||||||||||
| 26 | default => q{}, | ||||||||||||||||||||||||||||
| 27 | writer => 'mail_name', | ||||||||||||||||||||||||||||
| 28 | }); | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | 5 | ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | has mail_address => ( | ||||||||||||||||||||||||||||
| 33 | is => 'rw', | ||||||||||||||||||||||||||||
| 34 | isa => 'Str|Undef', | ||||||||||||||||||||||||||||
| 35 | default => q{}, | ||||||||||||||||||||||||||||
| 36 | 21 | ▶ | trigger => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 21 | my ($self, $mail_address, $current_mail_address) = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 21 | return $self->trigger_helper({ | |||||||||||||||||||||||||||
| 40 | new => $mail_address, | ||||||||||||||||||||||||||||
| 41 | current => $current_mail_address, | ||||||||||||||||||||||||||||
| 42 | default => q{}, | ||||||||||||||||||||||||||||
| 43 | writer => 'mail_address', | ||||||||||||||||||||||||||||
| 44 | }); | ||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||
| 46 | 5 | ); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 9 | ▶ | sub header_keys { | ||||||||||||||||||||||||||
|
Subroutine
header_keys: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 9 | my $name = $self->name; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 9 | return "${name}_name", "${name}_address"; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 7 | ▶ | sub data { | ||||||||||||||||||||||||||
|
Subroutine
data: called CC=9 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 7 | my ($self, $key, @args) = @_; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 7 | ▶ | defined $key | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | or confess 'Undefined key'; | ||||||||||||||||||||||||||||
| 61 | 7 | ▶ | my $value = @args ? $args[0] : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 7 | ▶ | if ( $key =~ m{ _name \z }xms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | return | ||||||||||||||||||||||||||||
| 64 | @args | ||||||||||||||||||||||||||||
| 65 | ? $self->mail_name( # set | ||||||||||||||||||||||||||||
| 66 | ref $value eq 'HASH' | ||||||||||||||||||||||||||||
| 67 | ? $value->{name} | ||||||||||||||||||||||||||||
| 68 | 3 | ▶ | : $value | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 69 | ) | ||||||||||||||||||||||||||||
| 70 | : $self->mail_name; # get | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 4 | ▶ | if ( $key =~ m{ _address \z }xms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | return | ||||||||||||||||||||||||||||
| 74 | @args | ||||||||||||||||||||||||||||
| 75 | ? $self->mail_address( # set | ||||||||||||||||||||||||||||
| 76 | ref $value eq 'HASH' | ||||||||||||||||||||||||||||
| 77 | ? $value->{address} | ||||||||||||||||||||||||||||
| 78 | 4 | ▶ | : $value | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 79 | ) | ||||||||||||||||||||||||||||
| 80 | : $self->mail_address; #get | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | confess "Unknown key $key"; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 6 | ▶ | sub extract_msgstr { | ||||||||||||||||||||||||||
|
Subroutine
extract_msgstr: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 6 | my ($self, $msgstr_ref) = @_; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 6 | my $name = $self->name; | |||||||||||||||||||||||||||
| 90 | 6 | ${$msgstr_ref} =~ s{ | |||||||||||||||||||||||||||
| 91 | ^ | ||||||||||||||||||||||||||||
| 92 | \Q$name\E : | ||||||||||||||||||||||||||||
| 93 | \s* | ||||||||||||||||||||||||||||
| 94 | ( [^<\n]*? ) | ||||||||||||||||||||||||||||
| 95 | \s+ | ||||||||||||||||||||||||||||
| 96 | < ( [^>\n]*? ) > | ||||||||||||||||||||||||||||
| 97 | \s* | ||||||||||||||||||||||||||||
| 98 | $ | ||||||||||||||||||||||||||||
| 99 | }{}xmsi | ||||||||||||||||||||||||||||
| 100 | 6 | ▶ | || ${$msgstr_ref} =~ s{ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | ^ | ||||||||||||||||||||||||||||
| 102 | \Q$name\E : | ||||||||||||||||||||||||||||
| 103 | \s* | ||||||||||||||||||||||||||||
| 104 | ( [^\n]*? ) | ||||||||||||||||||||||||||||
| 105 | () | ||||||||||||||||||||||||||||
| 106 | \s* | ||||||||||||||||||||||||||||
| 107 | $ | ||||||||||||||||||||||||||||
| 108 | }{}xmsi; | ||||||||||||||||||||||||||||
| 109 | 6 | $self->mail_name($1); ## no critic (CaptureWithoutTest) | |||||||||||||||||||||||||||
| 110 | 6 | $self->mail_address($2); ## no critic (CaptureWithoutTest) | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 6 | return; | |||||||||||||||||||||||||||
| 113 | }; | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 9 | ▶ | sub lines { | ||||||||||||||||||||||||||
|
Subroutine
lines: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 116 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 9 | ▶ | if ( ! length $self->mail_name && ! length $self->mail_address ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $self->mail_name or length $self->mail_address
MC/DC50%1/2
length $self->mail_name or length $self->mail_address
length $self->mail_name
length $self->mail_address
Truth table66%2/3
A or B
A= length $self->mail_nameB= length $self->mail_address
| |||||||||||||||||||||||||||||
| 119 | 4 | return; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | 5 | my $line = $self->format_line( | |||||||||||||||||||||||||||
| 122 | '{name}: {mail_name} <{mail_address}>', | ||||||||||||||||||||||||||||
| 123 | name => $self->name, | ||||||||||||||||||||||||||||
| 124 | mail_name => $self->mail_name, | ||||||||||||||||||||||||||||
| 125 | mail_address => $self->mail_address, | ||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||
| 127 | 5 | $line =~ s{\s* <> \z}{}xms; # delete an empty mail address | |||||||||||||||||||||||||||
| 128 | 5 | $line =~ s{\s+}{ }xmsg; # delete space before a mail address | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 5 | return $line; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # $Id: Utils.pm 602 2011-11-13 13:49:23Z steffenw $ | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 5 | 1; | |||||||||||||||||||||||||||