ARK/Clear.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 43 CC 4 SCAR 26.4
CC
4
Cov
0%
action
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 package Koha::Contrib::ARK::Clear;
2 # ABSTRACT: Clear Koha ARK field
3 $Koha::Contrib::ARK::Clear::VERSION = '1.0.3';
4 use Moose;
5  
6 with 'Koha::Contrib::ARK::Action';
7  
8 use Modern::Perl;
9  
10  
11  
12 sub action {
13 my ($self, $biblionumber, $record) = @_;
14  
15 return unless $record;
16  
17 my $ark = $self->ark;
18 my $ka = $ark->c->{ark}->{koha}->{ark};
19 my ($tag, $letter) = ($ka->{tag}, $ka->{letter});
20  
21 $self->ark->what_append('clear');
22 if ( $letter ) {
23 for my $field ( $record->field($tag) ) {
24 my @subf = grep {
25 my $keep = $_->[0] ne $letter;
26 $keep;
27 } @{$field->subf};
28 $field->subf( \@subf );
29 }
30 $record->fields( [ grep {
31 $_->tag eq $tag && @{$_->subf} == 0 ? 0 : 1;
32 } @{ $record->fields } ] );
33 }
34 else {
35 $record->delete($tag);
36 }
37 }
38  
39  
40 __PACKAGE__->meta->make_immutable;
41 1;
42  
43 __END__
44  
45 =pod
46  
47 =encoding UTF-8
48  
49 =head1 NAME
50  
51 Koha::Contrib::ARK::Clear - Clear Koha ARK field
52  
53 =head1 VERSION
54  
55 version 1.0.3
56  
57 =head1 AUTHOR
58  
59 Frédéric Demians <f.demians@tamil.fr>
60  
61 =head1 COPYRIGHT AND LICENSE
62  
63 This software is Copyright (c) 2018 by Fréderic Demians.
64  
65 This is free software, licensed under:
66  
67 The GNU General Public License, Version 3, June 2007
68  
69 =cut