From 6c5f8b4f0f088e7c776dcf250c5aa132bb8d8a40 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
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).
---
 .../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 c4b4f1e9bef..766aa0b8b80 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<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;
     }
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 3917159a589..bfb5f414e26 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<Koha::MetadataExtractor> class.
+Constructor for the I<Koha::Biblio::Metadata::Extractor> 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 53b8f3855eb..23f9a045276 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<Koha::MetadataExtractor::MARC::UNIMARC> class.
+Constructor for the I<Koha::Biblio::Metadata::Extractor::MARC::UNIMARC> class.
 
 =cut
 
diff --git a/t/Koha/MetadataExtractor.t b/t/Koha/MetadataExtractor.t
index 9e55d965378..b98634ae347 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 99c0a5a7230..875d75dc653 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 85e17b15122..b23413a853c 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.34.1