This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag upstream/1.19 in repository libcatmandu-marc-perl.
commit 9ec18c85e80b58f1e0eeb12474c0d1eaf86ab9a1 Author: Patrick Hochstenbach <[email protected]> Date: Tue Jun 14 14:03:13 2016 +0200 Fixing marc_map for inline fixes #31 --- Changes | 1 + lib/Catmandu/Fix/Inline/marc_map.pm | 7 ++++++- t/07-inline-fix.t | 10 +++++++--- t/old_new.json | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 96c8f3f..77ae9d1 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Catmandu-MARC {{$NEXT}} + - Fixing marc_map for inline fixes 0.217 2016-06-14 09:48:59 CEST - Fixed dependency on Catmandu 1.0201 for Inlineable diff --git a/lib/Catmandu/Fix/Inline/marc_map.pm b/lib/Catmandu/Fix/Inline/marc_map.pm index ed13bb5..5ff03b5 100644 --- a/lib/Catmandu/Fix/Inline/marc_map.pm +++ b/lib/Catmandu/Fix/Inline/marc_map.pm @@ -162,7 +162,12 @@ sub marc_map { } } } - push (@vals,$v) if ( (ref $v eq 'ARRAY' && @$v) || (ref $v eq '' && length $v )); + if (ref $v eq 'ARRAY' && @$v) { + push (@vals,@$v); + } + elsif (ref $v eq '' && length $v ) { + push (@vals,$v); + } } if (wantarray) { diff --git a/t/07-inline-fix.t b/t/07-inline-fix.t index 4b77e9e..5f7ee0e 100644 --- a/t/07-inline-fix.t +++ b/t/07-inline-fix.t @@ -1,14 +1,13 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 18; use Catmandu::Fix::Inline::marc_map qw(marc_map); use Catmandu::Fix::Inline::marc_add qw(marc_add); use Catmandu::Fix::Inline::marc_set qw(marc_set); use Catmandu::Fix::Inline::marc_remove qw(marc_remove); use Catmandu::Importer::JSON; -use Data::Dumper; my $importer = Catmandu::Importer::JSON->new( file => 't/old_new.json' ); @@ -25,7 +24,7 @@ ok(@$records == 2 , "Found 2 records"); { is scalar marc_map($records->[0],'245a'), q|ActivePerl with ASP and ADO /|, q|marc_map(245a)|; - is scalar marc_map($records->[0],'001') , q|fol05731351 | , q|marc_map(001)|; + is scalar marc_map($records->[0],'001') , q|fol05731351| , q|marc_map(001)|; ok ! defined(scalar marc_map($records->[0],'191')) , q|marc_map(191) not defined|; ok ! defined(scalar marc_map($records->[0],'245x')) , q|marc_map(245x) not defined|; } @@ -88,4 +87,9 @@ ok(@$records == 2 , "Found 2 records"); { my @arr = marc_map($records->[0],'630',-split=>1); ok @arr == 2; +} + +{ + my @arr = marc_map($records->[1],'020a',-split=>1); + ok @arr == 3; } \ No newline at end of file diff --git a/t/old_new.json b/t/old_new.json index 56ee7e0..0ed6ffa 100644 --- a/t/old_new.json +++ b/t/old_new.json @@ -1,2 +1,2 @@ -{"record":[["LDR",null,null,"_","00755cam 22002414a 4500"],["001",null,null,"_","fol05731351 "],["003",null,null,"_","IMchF"],["005",null,null,"_","20000613133448.0"],["008",null,null,"_","000107s2000 nyua 001 0 eng "],["010"," "," ","_","","a"," 00020737 "],["020"," "," ","_","","a","0471383147 (paper/cd-rom : alk. paper)"],["040"," "," ","_","","a","DLC","c","DLC","d","DLC"],["042"," "," ","_","","a","pcc"],["050","0","0","_","","a","QA76.73.P22","b","M33 2000"],["082", [...] -{"record":[["LDR",null,null,"_","00755cam 22002414a 4500"],["001",null,null,"_","fol05731351 "],["003",null,null,"_","IMchF"],["005",null,null,"_","20000613133448.0"],["008",null,null,"_","000107s2000 nyua 001 0 eng "],["010"," "," ","a"," 00020737 "],["020"," "," ","a","0471383147 (paper/cd-rom : alk. paper)"],["040"," "," ","a","DLC","c","DLC","d","DLC"],["042"," "," ","a","pcc"],["050","0","0","a","QA76.73.P22","b","M33 2000"],["082","0","0","a","005.13/3","2","21"],[" [...] +{"record":[["FMT"," "," ","_","BK"],["LDR"," "," ","_","00755cam 22002414a 4500"],["001"," "," ","_","fol05731351"],["003"," "," ","_","IMchF"],["005"," "," ","_","20000613133448.0"],["008"," "," ","_","000107s2000 nyua 001 0 eng"],["010"," "," ","a"," 00020737"],["020"," "," ","a","0471383147 (paper/cd-rom : alk. paper)"],["040"," "," ","a","DLC","c","DLC","d","DLC"],["042"," "," ","a","pcc"],["050","0","0","a","QA76.73.P22","b","M33 2000"],["082","0","0","a","005.13/3"," [...] +{"_id":"000000001","record":[["FMT"," "," ","_","BK"],["LDR"," "," ","_","00755cam 22002414a 4500"],["001"," "," ","_","fol05731351"],["003"," "," ","_","IMchF"],["005"," "," ","_","20000613133448.0"],["008"," "," ","_","000107s2000 nyua 001 0 eng"],["010"," "," ","a"," 00020737"],["020"," "," ","a","0471383147 (paper/cd-rom : alk. paper)"],["020"," "," ","a","1234567890","a","9876543210"],["040"," "," ","a","DLC","c","DLC","d","DLC"],["042"," "," ","a","pcc"],["050","0"," [...] -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
