From 7efeeda29dddaa14447420b1649c1bfce36e5ed9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 5 Oct 2023 08:30:05 +0200 Subject: [PATCH] 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 Signed-off-by: Tomas Cohen Arazi --- .../Metadata/Extractor.pm} | 10 +++++----- .../Metadata/Extractor}/MARC/MARC21.pm | 8 ++++---- .../Metadata/Extractor}/MARC/UNIMARC.pm | 8 ++++---- t/Koha/MetadataExtractor.t | 16 ++++++++-------- t/Koha/MetadataExtractor/MARC/MARC21.t | 8 ++++---- t/Koha/MetadataExtractor/MARC/UNIMARC.t | 8 ++++---- 6 files changed, 29 insertions(+), 29 deletions(-) rename Koha/{MetadataExtractor.pm => Biblio/Metadata/Extractor.pm} (86%) rename Koha/{MetadataExtractor => Biblio/Metadata/Extractor}/MARC/MARC21.pm (86%) rename Koha/{MetadataExtractor => Biblio/Metadata/Extractor}/MARC/UNIMARC.pm (85%) diff --git a/Koha/MetadataExtractor.pm b/Koha/Biblio/Metadata/Extractor.pm similarity index 86% rename from Koha/MetadataExtractor.pm rename to Koha/Biblio/Metadata/Extractor.pm index c4b4f1e9be..766aa0b8b8 100644 --- a/Koha/MetadataExtractor.pm +++ b/Koha/Biblio/Metadata/Extractor.pm @@ -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 class. +Constructor for the I 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; } diff --git a/Koha/MetadataExtractor/MARC/MARC21.pm b/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm similarity index 86% rename from Koha/MetadataExtractor/MARC/MARC21.pm rename to Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm index 3917159a58..bfb5f414e2 100644 --- a/Koha/MetadataExtractor/MARC/MARC21.pm +++ b/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm @@ -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 class. +Constructor for the I class. =cut diff --git a/Koha/MetadataExtractor/MARC/UNIMARC.pm b/Koha/Biblio/Metadata/Extractor/MARC/UNIMARC.pm similarity index 85% rename from Koha/MetadataExtractor/MARC/UNIMARC.pm rename to Koha/Biblio/Metadata/Extractor/MARC/UNIMARC.pm index 53b8f3855e..23f9a04527 100644 --- a/Koha/MetadataExtractor/MARC/UNIMARC.pm +++ b/Koha/Biblio/Metadata/Extractor/MARC/UNIMARC.pm @@ -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 class. +Constructor for the I class. =cut diff --git a/t/Koha/MetadataExtractor.t b/t/Koha/MetadataExtractor.t index 9e55d96537..b98634ae34 100755 --- a/t/Koha/MetadataExtractor.t +++ b/t/Koha/MetadataExtractor.t @@ -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 }) { diff --git a/t/Koha/MetadataExtractor/MARC/MARC21.t b/t/Koha/MetadataExtractor/MARC/MARC21.t index 99c0a5a723..875d75dc65 100755 --- a/t/Koha/MetadataExtractor/MARC/MARC21.t +++ b/t/Koha/MetadataExtractor/MARC/MARC21.t @@ -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" ) ); diff --git a/t/Koha/MetadataExtractor/MARC/UNIMARC.t b/t/Koha/MetadataExtractor/MARC/UNIMARC.t index 85e17b1512..b23413a853 100755 --- a/t/Koha/MetadataExtractor/MARC/UNIMARC.t +++ b/t/Koha/MetadataExtractor/MARC/UNIMARC.t @@ -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" ) ); -- 2.39.5