Bug 34828: Move to Koha::Biblio::Metadata::Extractor
We are not directly linked with the other Koha::Metadata* packages. Better to isolate this under Koha::Biblio::Metadata (at least for now). Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
0161eeba13
commit
7efeeda29d
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::MetadataExtractor;
|
||||
package Koha::Biblio::Metadata::Extractor;
|
||||
|
||||
# Copyright ByWater Solutions 2023
|
||||
#
|
||||
|
|
@ -19,7 +19,7 @@ package Koha::MetadataExtractor;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::MetadataExtractor - Extract specific metadata from MARC::Record objects
|
||||
Koha::Biblio::Metadata::Extractor - Extract specific metadata from MARC::Record objects
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -33,9 +33,9 @@ use Koha::Exceptions;
|
|||
|
||||
=head3 new
|
||||
|
||||
my $extractor = Koha::MetadataExtractor->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor->new;
|
||||
|
||||
Constructor for the I<Koha::MetadataExtractor> class.
|
||||
Constructor for the I<Koha::Biblio::Metadata::Extractor> class.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ sub get_extractor {
|
|||
unless $valid_schemas->{$schema};
|
||||
|
||||
unless ( $self->{extractors}->{$schema} ) {
|
||||
my $extractor_class = "Koha::MetadataExtractor::MARC::$schema";
|
||||
my $extractor_class = "Koha::Biblio::Metadata::Extractor::MARC::$schema";
|
||||
eval "require $extractor_class";
|
||||
$self->{extractors}->{$schema} = $extractor_class->new;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::MetadataExtractor::MARC::MARC21;
|
||||
package Koha::Biblio::Metadata::Extractor::MARC::MARC21;
|
||||
|
||||
# Copyright ByWater Solutions 2023
|
||||
#
|
||||
|
|
@ -19,7 +19,7 @@ package Koha::MetadataExtractor::MARC::MARC21;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::MetadataExtractor - Extract specific metadata from MARC::Record objects
|
||||
Koha::Biblio::Metadata::Extractor - Extract specific metadata from MARC::Record objects
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -33,9 +33,9 @@ use Koha::Exceptions;
|
|||
|
||||
=head3 new
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::MARC21->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new;
|
||||
|
||||
Constructor for the I<Koha::MetadataExtractor> class.
|
||||
Constructor for the I<Koha::Biblio::Metadata::Extractor> class.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::MetadataExtractor::MARC::UNIMARC;
|
||||
package Koha::Biblio::Metadata::Extractor::MARC::UNIMARC;
|
||||
|
||||
# Copyright ByWater Solutions 2023
|
||||
#
|
||||
|
|
@ -19,7 +19,7 @@ package Koha::MetadataExtractor::MARC::UNIMARC;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::MetadataExtractor - Extract specific metadata from MARC::Record objects
|
||||
Koha::Biblio::Metadata::Extractor - Extract specific metadata from MARC::Record objects
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -33,9 +33,9 @@ use Koha::Exceptions;
|
|||
|
||||
=head3 new
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::UNIMARC->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::UNIMARC->new;
|
||||
|
||||
Constructor for the I<Koha::MetadataExtractor::MARC::UNIMARC> class.
|
||||
Constructor for the I<Koha::Biblio::Metadata::Extractor::MARC::UNIMARC> class.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -25,26 +25,26 @@ use Test::MockModule;
|
|||
|
||||
use MARC::Record;
|
||||
|
||||
use Koha::MetadataExtractor;
|
||||
use Koha::Biblio::Metadata::Extractor;
|
||||
|
||||
subtest 'new() tests' => sub {
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor->new;
|
||||
is( ref($extractor), 'Koha::MetadataExtractor' );
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor->new;
|
||||
is( ref($extractor), 'Koha::Biblio::Metadata::Extractor' );
|
||||
};
|
||||
|
||||
subtest 'get_extractor() tests' => sub {
|
||||
|
||||
plan tests => 8;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor->new;
|
||||
|
||||
foreach my $schema (qw{ MARC21 UNIMARC }) {
|
||||
my $specific_extractor = $extractor->get_extractor( { schema => $schema } );
|
||||
is(
|
||||
ref($specific_extractor), "Koha::MetadataExtractor::MARC::$schema",
|
||||
ref($specific_extractor), "Koha::Biblio::Metadata::Extractor::MARC::$schema",
|
||||
"Returns the right extractor library for schema ($schema)"
|
||||
);
|
||||
ok( exists $extractor->{extractors}->{$schema}, "Extractor for $schema cached" );
|
||||
|
|
@ -73,14 +73,14 @@ subtest 'get_normalized_upc() tests' => sub {
|
|||
|
||||
plan tests => 6;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor->new;
|
||||
|
||||
my $record = MARC::Record->new();
|
||||
|
||||
my $mock_marc21 = Test::MockModule->new('Koha::MetadataExtractor::MARC::MARC21');
|
||||
my $mock_marc21 = Test::MockModule->new('Koha::Biblio::Metadata::Extractor::MARC::MARC21');
|
||||
$mock_marc21->mock( 'get_normalized_upc', sub { return 'MARC21' } );
|
||||
|
||||
my $mock_unimarc = Test::MockModule->new('Koha::MetadataExtractor::MARC::UNIMARC');
|
||||
my $mock_unimarc = Test::MockModule->new('Koha::Biblio::Metadata::Extractor::MARC::UNIMARC');
|
||||
$mock_unimarc->mock( 'get_normalized_upc', sub { return 'UNIMARC' } );
|
||||
|
||||
foreach my $schema (qw{ MARC21 UNIMARC }) {
|
||||
|
|
|
|||
|
|
@ -24,21 +24,21 @@ use Test::Exception;
|
|||
|
||||
use MARC::Record;
|
||||
|
||||
use Koha::MetadataExtractor::MARC::MARC21;
|
||||
use Koha::Biblio::Metadata::Extractor::MARC::MARC21;
|
||||
|
||||
subtest 'new() tests' => sub {
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::MARC21->new;
|
||||
is( ref($extractor), 'Koha::MetadataExtractor::MARC::MARC21' );
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new;
|
||||
is( ref($extractor), 'Koha::Biblio::Metadata::Extractor::MARC::MARC21' );
|
||||
};
|
||||
|
||||
subtest 'get_normalized_upc() tests' => sub {
|
||||
|
||||
plan tests => 6;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::MARC21->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new;
|
||||
|
||||
my $record = MARC::Record->new();
|
||||
$record->append_fields( MARC::Field->new( '024', '1', ' ', a => "9-123345345X" ) );
|
||||
|
|
|
|||
|
|
@ -24,21 +24,21 @@ use Test::Exception;
|
|||
|
||||
use MARC::Record;
|
||||
|
||||
use Koha::MetadataExtractor::MARC::UNIMARC;
|
||||
use Koha::Biblio::Metadata::Extractor::MARC::UNIMARC;
|
||||
|
||||
subtest 'new() tests' => sub {
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::UNIMARC->new;
|
||||
is( ref($extractor), 'Koha::MetadataExtractor::MARC::UNIMARC' );
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::UNIMARC->new;
|
||||
is( ref($extractor), 'Koha::Biblio::Metadata::Extractor::MARC::UNIMARC' );
|
||||
};
|
||||
|
||||
subtest 'get_normalized_upc() tests' => sub {
|
||||
|
||||
plan tests => 6;
|
||||
|
||||
my $extractor = Koha::MetadataExtractor::MARC::UNIMARC->new;
|
||||
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::UNIMARC->new;
|
||||
|
||||
my $record = MARC::Record->new();
|
||||
$record->append_fields( MARC::Field->new( '072', '1', ' ', a => "9-123345345X" ) );
|
||||
|
|
|
|||
Loading…
Reference in New Issue