[open-ils-commits] r12589 - in trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD: . test (djfiander)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Mar 18 20:51:11 EDT 2009


Author: djfiander
Date: 2009-03-18 20:51:10 -0400 (Wed, 18 Mar 2009)
New Revision: 12589

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t
Log:
Mostly mplement issues with combined dates (eg, May/June). Still don't do combined years (2000/2001)

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-03-19 00:06:02 UTC (rev 12588)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm	2009-03-19 00:51:10 UTC (rev 12589)
@@ -337,10 +337,20 @@
     my @date = @_;
 
     # XXX WRITE ME
+    return 0;
 }
 
+sub match_issue {
+    my $pat = shift;
+    my @date = @_;
+
+    # XXX WRITE ME
+    return 0;
+}
+
 my %dispatch = (
 		'd' => \&match_day,
+		'e' => \&match_issue, # not really a "chron" code
 		'w' => \&match_week,
 		'm' => \&match_month,
 		's' => \&match_season,
@@ -351,7 +361,9 @@
     my $pubcode = shift;
     my @date = @_;
 
-    foreach my $regularity ($self->{_mfhdc_PATTERN}->{y}) {
+    return 0 if !exists $self->{_mfhdc_PATTERN}->{y};
+
+    foreach my $regularity (@{$self->{_mfhdc_PATTERN}->{y}}) {
 	next unless $regularity =~ m/^$pubcode/;
 
 	my $chroncode= substr($regularity, 1, 1);
@@ -359,6 +371,7 @@
 
 	# XXX WRITE ME
 	foreach my $pat (@pats) {
+	    $pat =~ s|/.+||;	# If it's a combined date, match the start
 	    if ($dispatch{$chroncode}->($pat, @date)) {
 		return 1;
 	    }

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm	2009-03-19 00:06:02 UTC (rev 12588)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Holding.pm	2009-03-19 00:51:10 UTC (rev 12589)
@@ -206,12 +206,6 @@
 		  # x => completely irregular
 );
 
-sub is_combined {
-    my $str = shift;
-
-    return $str =~ m;.+/.+;
-}
-
 sub incr_date {
     my $incr = shift;
     my @new = @_;
@@ -286,8 +280,8 @@
 	$new[$i] = $cur[$i] = $next->{$keys[$i]} if exists $next->{$keys[$i]};
     }
 
-    if (is_combined($new[-1])) {
-	$new[-1] =~ s/^[^\/]+//;
+    if ($new[-1] =~ m;.+/.+;) {
+	$new[-1] =~ s|^[^/]+/||;
     }
 
     # If $frequency is not one of the standard codes defined in %increments
@@ -308,6 +302,14 @@
 	while ($caption->is_omitted(@new)) {
 	    @new = incr_date($increments{$freq}, @new);
 	}
+
+	if ($caption->is_combined(@new)) {
+	    my @second_date = incr_date($increments{$freq}, @new);
+
+	    # I am cheating: This code assumes that only the smallest
+	    # time increment is combined. So, no "Apr 15/May 1" allowed.
+	    @new[-1] = @new[-1] . '/' . @second_date[-1];
+	}
     }
 
     for my $i (0..$#new) {

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t	2009-03-19 00:06:02 UTC (rev 12588)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/test/mfhd.t	2009-03-19 00:51:10 UTC (rev 12589)
@@ -138,25 +138,25 @@
 
 245 00 $aMonthly, issue no. restarts, Calendar change: Jan, Combined issue: Jan/Feb
 853 20 $87$av.$bno.$u11$vr$i(year)$j(month)$wm$x01$ycm01/02
-863 41 $87.1$a1$b11$i1990$j12$x|a2|b1|i1991|j01/02$zTODO End of year, end of vol.
-863 41 $87.2$a2$b1$i1991$j01/02$x|a2|b2|i1991|j03$zTODO Beginning of year, beginning of vol.
+863 41 $87.1$a1$b11$i1990$j12$x|a2|b1|i1991|j01/02$z End of year, end of vol.
+863 41 $87.2$a2$b1$i1991$j01/02$x|a2|b2|i1991|j03$z Beginning of year, beginning of vol.
 
 245 00 $aMonthly, iss no. restarts, Calendar change: Jan, Combined iss: Nov/Dec
 853 20 $88$av.$bno.$u11$vr$i(year)$j(month)$wm$x01$ycm11/12
-863 41 $88.1$a1$b10$i1990$j10$x|a1|b11|i1990|j11/12$zTODO end of year, end of vol.
-863 41 $88.2$a1$b11$i1990$j11/12$x|a2|b1|i1991|j01$zTODO wrap vol at year end
+863 41 $88.1$a1$b10$i1990$j10$x|a1|b11|i1990|j11/12$z end of year, end of vol.
+863 41 $88.2$a1$b11$i1990$j11/12$x|a2|b1|i1991|j01$z wrap vol at year end
 
 245 00 $aMonthly, iss no. restarts, Cal. change: Jan, Combined iss: Jan/Feb, Nov/Dec
 853 20 $89$av.$bno.$u10$vr$i(year)$j(month)$wm$x01$ycm01/02,11/12
-863 41 $89.1$a1$b1$i1990$j01/02$x|a1|b2|i1990|j03$zTODO beg. of year, beg. of vol.
-863 41 $89.2$a1$b9$i1990$j10$x|a1|b10|i1990|j11/12$zTODO end of year, end of vol.
-863 41 $89.3$a1$b10$i1990$j11/12$x|a2|b1|i1991|j01/02$zTODO zwrap vol at year end
+863 41 $89.1$a1$b1$i1990$j01/02$x|a1|b2|i1990|j03$z beg. of year, beg. of vol.
+863 41 $89.2$a1$b9$i1990$j10$x|a1|b10|i1990|j11/12$z end of year, end of vol.
+863 41 $89.3$a1$b10$i1990$j11/12$x|a2|b1|i1991|j01/02$z zwrap vol at year end
 
 245 00 $aMonthly, iss no. restarts, Cal. change: Jan, Combined iss: May/Jun, Jul/Aug
 853 20 $810$av.$bno.$u10$vr$i(year)$j(month)$wm$x01$ycm05/06,07/08
-863 41 $810.1$a1$b4$i1990$j04$x|a1|b5|i1990|j05/06$zTODO next iss is combined.
-863 41 $810.2$a1$b5$i1990$j05/06$x|a1|b6|i1990|j07/08$zTODO combined to combined
-863 41 $810.3$a1$b6$i1990$j07/08$x|a1|b7|i1990|j09$zTODO combined to reg
+863 41 $810.1$a1$b4$i1990$j04$x|a1|b5|i1990|j05/06$z next iss is combined.
+863 41 $810.2$a1$b5$i1990$j05/06$x|a1|b6|i1990|j07/08$z combined to combined
+863 41 $810.3$a1$b6$i1990$j07/08$x|a1|b7|i1990|j09$z combined to reg
 
 245 00 $aMonthly, issue no. restarts, Calendar change: Jan, Combined issue: 1/2 Jan/Feb 
 853 20 $811$av.$bno.$u12$vr$i(year)$j(month)$wm$x01$ycm01/02$yce21/2



More information about the open-ils-commits mailing list