Author: jim
Date: Wed May 29 19:35:26 2013
New Revision: 1487609

URL: http://svn.apache.org/r1487609
Log:
Lump all Steve subs into steve.pm

Removed:
    steve/trunk/cmdline/ballots.pm
    steve/trunk/cmdline/randomize.pm
Modified:
    steve/trunk/cmdline/make_issue.pl
    steve/trunk/cmdline/reminder.pl
    steve/trunk/cmdline/steve.pm

Modified: steve/trunk/cmdline/make_issue.pl
URL: 
http://svn.apache.org/viewvc/steve/trunk/cmdline/make_issue.pl?rev=1487609&r1=1487608&r2=1487609&view=diff
==============================================================================
--- steve/trunk/cmdline/make_issue.pl (original)
+++ steve/trunk/cmdline/make_issue.pl Wed May 29 19:35:26 2013
@@ -38,8 +38,6 @@ BEGIN {
     unshift @INC, "/home/voter/bin";
 }
 require "getopts.pl";
-use randomize;
-use ballots;
 use steve;
 
 umask(0077);

Modified: steve/trunk/cmdline/reminder.pl
URL: 
http://svn.apache.org/viewvc/steve/trunk/cmdline/reminder.pl?rev=1487609&r1=1487608&r2=1487609&view=diff
==============================================================================
--- steve/trunk/cmdline/reminder.pl (original)
+++ steve/trunk/cmdline/reminder.pl Wed May 29 19:35:26 2013
@@ -26,7 +26,6 @@
 BEGIN {
     unshift @INC, "/home/voter/bin";
 }
-use randomize;
 use steve;
 
 

Modified: steve/trunk/cmdline/steve.pm
URL: 
http://svn.apache.org/viewvc/steve/trunk/cmdline/steve.pm?rev=1487609&r1=1487608&r2=1487609&view=diff
==============================================================================
--- steve/trunk/cmdline/steve.pm (original)
+++ steve/trunk/cmdline/steve.pm Wed May 29 19:35:26 2013
@@ -19,6 +19,8 @@
 # shared functions for Apache Steve.
 #
 
+##use strict;
+
 $ECHO     = '/bin/echo';
 $CAT      = '/bin/cat';
 $MD5      = '/sbin/md5';
@@ -204,4 +206,42 @@ sub not_valid {
   return 0;
 }
 
+# randomize the order in which candidates are listed
+#
+# candidates are identified with a single alphanumeric character surrounded
+# by square brackets as the first non-blank on a line.
+#
+# candidates are to be listed consecutively, one per line.  If this is
+# found not to be the case, NO reordering is performed.
+sub randomize {
+  my (@prolog, @choices, @epilog);
+
+  push @prolog, shift  while @_ && not $_[0]  =~ /^\s*\[[a-z0-9]\]\s/;
+  unshift @epilog, pop while @_ && not $_[-1] =~ /^\s*\[[a-z0-9]\]\s/;
+  return @prolog, @_, @epilog if grep !/^\s*\[\S\]\s/, @_;
+  push @choices, splice(@_, rand @_, 1) while @_;
+  return @prolog, @choices, @epilog;
+}
+
+# return the ballot identifiers for each candidate in an issue.
+#
+# candidates are identified with a single alphanumeric character surrounded
+# by square brackets as the first non-blank on a line.
+#
+# candidates are to be listed consecutively, one per line.
+#
+sub ballots {
+  my (@ballots);
+
+  shift  while @_ && not $_[0]  =~ /^\s*\[[a-z0-9]\]\s/;
+  for (@_) {
+    if (/^\s*\[([a-z0-9])\]\s/) {
+      push @ballots, "$1\n";
+    } else {
+      last;
+    }
+  }
+  return @ballots;
+}
+
 1;


Reply via email to