[libcatmandu-marc-perl] 07/26: Fixing undef 'indicators' for leaders

Jonas Smedegaard dr at jones.dk
Tue Dec 19 12:17:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag upstream/1.23.1
in repository libcatmandu-marc-perl.

commit 11a2931c3dd3a24ca232d9b4df131706424813c7
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri Nov 10 11:09:45 2017 +0100

    Fixing undef 'indicators' for leaders
---
 lib/Catmandu/Importer/MARC/Decoder.pm |  6 ++--
 t/Catmandu/Exporter/MARC/ISO.t        | 63 ++++++++++++++++++++++-------------
 2 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/lib/Catmandu/Importer/MARC/Decoder.pm b/lib/Catmandu/Importer/MARC/Decoder.pm
index f854f74..acc8615 100644
--- a/lib/Catmandu/Importer/MARC/Decoder.pm
+++ b/lib/Catmandu/Importer/MARC/Decoder.pm
@@ -23,12 +23,12 @@ sub decode {
     return unless eval { $record->isa('MARC::Record') };
     my @result = ();
 
-    push @result , [ 'LDR' , undef, undef, '_' , $record->leader ];
+    push @result , [ 'LDR' , ' ', ' ' , '_' , $record->leader ];
 
     for my $field ($record->fields()) {
         my $tag  = $field->tag;
-        my $ind1 = $field->indicator(1);
-        my $ind2 = $field->indicator(2);
+        my $ind1 = $field->indicator(1) // ' ';
+        my $ind2 = $field->indicator(2) // ' ';
 
         my @sf = ();
 
diff --git a/t/Catmandu/Exporter/MARC/ISO.t b/t/Catmandu/Exporter/MARC/ISO.t
index 550a36d..441f2e7 100644
--- a/t/Catmandu/Exporter/MARC/ISO.t
+++ b/t/Catmandu/Exporter/MARC/ISO.t
@@ -5,6 +5,8 @@ use warnings;
 use Test::More;
 use Test::Exception;
 use Catmandu::Exporter::MARC;
+use Catmandu::Importer::MARC;
+use utf8;
 
 my $pkg;
 
@@ -17,29 +19,42 @@ require_ok $pkg;
 
 my $marciso = undef;
 
-my $exporter = Catmandu::Exporter::MARC->new(file => \$marciso, type=> 'ISO');
-
-ok $exporter , 'got an MARC/ISO exporter';
-
-ok $exporter->add({
-  _id => '1' ,
-  record => [
-            ['FMT', undef, undef, '_', 'BK'],
-            ['001', undef, undef, '_', 'rec001'],
-            ['100', ' ', ' ', 'a', 'Davis, Miles' , 'c' , 'Test'],
-            ['245', ' ', ' ',
-                'a', 'Sketches in Blue' ,
-            ],
-            ['500', ' ', ' ', 'a', undef],
-            ['501', ' ', ' ' ],
-            ['502', ' ', ' ', 'a', undef, 'b' , 'ok'],
-            ['503', ' ', ' ', 'a', ''],
-            ['CAT', ' ', ' ', 'a', 'test'],
-        ]
-}) , 'add';
-
-ok $exporter->commit , 'commit';
-
-ok length($marciso) >= 127 , 'got iso';
+my $record = {
+    _id => '000000002',
+    record => [
+      [ 'LDR', ' ', ' ' , '_', '00156nam a2200085 i 4500' ] ,
+      [ '001', ' ', ' ' , '_', '000000002' ] ,
+      [ '245', '1', '0' , 'a', 'Catmandu Test' ] ,
+      [ '650', ' ', '0' , 'a', 'Perl' ] ,
+      [ '650', ' ', '0' , 'a', 'MARC' , 'a' , 'MARC2' ] ,
+      [ '650', ' ', '0' , 'a', '加德滿都' ] ,
+    ]
+};
+
+note("export marc");
+{
+    my $exporter = Catmandu::Exporter::MARC->new(file => \$marciso, type=> 'ISO');
+
+    ok $exporter , 'got a MARC/ISO exporter';
+
+    ok $exporter->add($record) , 'add';
+
+    ok $exporter->commit , 'commit';
+
+    ok length($marciso) >= 127 , 'got iso';
+}
+
+note("parse the results");
+{
+    my $importer = Catmandu::Importer::MARC->new(file => \$marciso , type => 'ISO');
+
+    ok $importer , 'got a MARC/ISO importer';
+
+    my $result = $importer->first;
+
+    ok $result , 'got a result';
+
+    is_deeply $result , $record , 'got the expected result';
+}
 
 done_testing;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git



More information about the Pkg-perl-cvs-commits mailing list