From 5c610e9b594e5a295a2dfad9b24ead59eda74990 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 31 Oct 2007 00:26:43 +0000 Subject: [PATCH] r1393@llin: dpavlin | 2007-10-31 00:52:52 +0100 added sorted to WebPAC::Normalize to define values which should go into sorted lists git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@923 07558da8-63fa-0310-ba24-9fe276d99e06 --- lib/WebPAC/Normalize.pm | 35 ++++++++++++++++++++--------------- t/3-normalize.t | 7 ++++++- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/WebPAC/Normalize.pm b/lib/WebPAC/Normalize.pm index 48768a2..548cd63 100644 --- a/lib/WebPAC/Normalize.pm +++ b/lib/WebPAC/Normalize.pm @@ -7,7 +7,7 @@ use Exporter 'import'; _debug _pack_subfields_hash - search_display search display + search_display search display sorted marc marc_indicators marc_repeatable_subfield marc_compose marc_leader marc_fixed @@ -41,13 +41,9 @@ my $debug = 0; WebPAC::Normalize - describe normalisaton rules using sets -=head1 VERSION - -Version 0.30 - =cut -our $VERSION = '0.30'; +our $VERSION = '0.31'; =head1 SYNOPSIS @@ -478,13 +474,16 @@ Define output just for I =cut -sub display { - my $name = shift or die "display needs name as first argument"; +sub _field { + my $type = shift or confess "need type -- BUG?"; + my $name = shift or confess "needs name as first argument"; my @o = grep { defined($_) && $_ ne '' } @_; return unless (@o); - $out->{$name}->{display} = \@o; + $out->{$name}->{$type} = \@o; } +sub display { _field( 'display', @_ ) } + =head2 search Prepare values just for I @@ -493,12 +492,18 @@ Prepare values just for I =cut -sub search { - my $name = shift or die "search needs name as first argument"; - my @o = grep { defined($_) && $_ ne '' } @_; - return unless (@o); - $out->{$name}->{search} = \@o; -} +sub search { _field( 'search', @_ ) } + +=head2 sorted + +Insert into lists which will be automatically sorted + + sorted('Title', rec('200','a') ); + +=cut + +sub sorted { _field( 'sorted', @_ ) } + =head2 marc_leader diff --git a/t/3-normalize.t b/t/3-normalize.t index b01e89f..363797f 100755 --- a/t/3-normalize.t +++ b/t/3-normalize.t @@ -2,7 +2,7 @@ use strict; -use Test::More tests => 341; +use Test::More tests => 347; use Test::Exception; use Cwd qw/abs_path/; use blib; @@ -436,6 +436,11 @@ sub test_s { test_check_ds('search'); test_check_ds('display'); + _clean_ds(); + test_s(qq{ sorted('something', '42'); }); + test_s(qq{ sorted('empty', ''); }); + test_check_ds('sorted'); + _clean_ds(); my $n = read_file( "$abs_path/data/normalize.pl" ); $n .= "\n1;\n"; -- 2.20.1