Fix/pica_tag.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 91.1% 31 / 34 CC 4 SCAR 6.5
CC
4
Cov
93%
fix
3.0
__ANON__
2.1
BEGIN
1.0
CRAP 1.9
« Validator/PICA.pm ↑ Summary Fix/pica_append.pm »
1 package Catmandu::Fix::pica_tag;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.18';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util 'reftype';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has tag => (
12 fix_arg => 1,
13 1 ▶ coerce => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
14 1 ▶ die "invalid tag: $_[0]\n" if $_[0] !~ qr/^[0-2]\d{2}[A-Z@]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ qr/^[0-2]\d{2}[A-Z\@]$/ 0 1 1
15 1 $_[0];
16 }
17 1 );
18  
19 1 ▶sub fix {
Subroutine fix: called CC=3 SCAR=11.0
Pod undocumented
20 1 my ( $self, $data ) = @_;
21  
22 1 ▶ if ( reftype $data->{record} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($data->{"record"}) eq "ARRAY") 1 0 1
23 1 for ( @{ $data->{record} } ) {
24 2 $_->[0] = $self->tag;
25 }
26 }
27  
28 1 return $data;
29 }
30  
31 =head1 NAME
32  
33 Catmandu::Fix::pica_tag - change tag of PICA+ field
34  
35 =head1 SYNOPSIS
36  
37 # change every 012X field into 012Y
38 do pica_each(012X)
39 pica_tag(012Y)
40 end
41  
42 =head1 FUNCTIONS
43  
44 =head2 pica_tag(TAG)
45  
46 Set the PICA+ tag of every field.
47  
48 =head2 SEE ALSO
49  
50 L<Catmandu::Fix::pica_occurrence>
51  
52 =cut
53  
54 1 1;
« Validator/PICA.pm ↑ Summary Fix/pica_append.pm »