Tamil/Authority/EditorsUpdater.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 58 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Koha::Contrib::Tamil::Authority::EditorsUpdater;
2 $Koha::Contrib::Tamil::Authority::EditorsUpdater::VERSION = '0.074';
3 use Moose;
4  
5 extends 'AnyEvent::Processor';
6  
7 use C4::AuthoritiesMarc qw(AddAuthority);
8  
9 has verbose => ( is => 'rw', isa => 'Bool' );
10  
11 has doit => ( is => 'rw', isa => 'Bool' );
12  
13 has koha => ( is => 'rw', isa => 'Koha::Contrib::Tamil::Koha' );
14  
15 has editor_from_isbn => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
16  
17 has isbns => ( is => 'rw', isa => 'ArrayRef' );
18  
19  
20 before 'run' => sub {
21 my ($self, $delete) = @_;
22  
23 if ( $delete && $self->doit ) {
24 print "Deleting EDITORS\n";
25 $self->koha->dbh->do("delete from auth_header where authtypecode='EDITORS'");
26 }
27 my @isbns = sort keys %{$self->editor_from_isbn};
28 $self->isbns( \@isbns );
29  
30 $self->SUPER::run();
31 };
32  
33  
34 override 'process' => sub {
35 my $self = shift;
36  
37 return 0 if $self->count == @{$self->isbns};
38  
39 my $isbn = $self->isbns->[$self->count];
40 $self->count( $self->count + 1 );
41 my ($name, $collections) = @{ $self->editor_from_isbn->{$isbn} };
42 my @sf = ();
43 push @sf, 'a', $isbn, 'b', $name;
44 foreach my $collection (sort keys %$collections) {
45 push @sf, 'c', $collection;
46 }
47 my $authority = MARC::Record->new();
48 $authority->append_fields( MARC::Field->new( 200, '', '', @sf ) );
49 AddAuthority( $authority, 0, 'EDITORS' ) if $self->doit;
50 #print $authority->as_formatted(), "\n" if $self->verbose;
51 return 1;
52 };
53  
54  
55 no Moose;
56 __PACKAGE__->meta->make_immutable;
57 1;
58  
59 __END__