aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2021-06-17 23:56:42 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2021-06-17 23:56:42 -0700
commit8e9679101b638f65af8be2e034263efed09bf22e (patch)
tree32efacbe186552bb1594f228390628ea56cb5ce4 /countify
parentREADME.md: refresh docs (diff)
downloadelections-8e9679101b638f65af8be2e034263efed09bf22e.tar.gz
elections-8e9679101b638f65af8be2e034263efed09bf22e.tar.bz2
elections-8e9679101b638f65af8be2e034263efed09bf22e.zip
Votify: improvements from re-using the codebase for another project
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'countify')
-rwxr-xr-xcountify19
1 files changed, 13 insertions, 6 deletions
diff --git a/countify b/countify
index 13618a4..cf31d69 100755
--- a/countify
+++ b/countify
@@ -19,9 +19,13 @@ BEGIN {
push @INC, $dirname;
}
-use POSIX;
+use Cwd qw(abs_path);
+use File::Basename;
+use File::Spec::Functions;
use Getopt::Long;
use List::Util;
+use POSIX;
+
use Votify 'official';
use strict;
@@ -94,12 +98,15 @@ if ($opt{'collect'}) {
$master->collect($vl->voters);
for my $o ($ol->officials) {
my ($uid, $home) = (getpwnam $o)[2,7];
- mkdir "$home/results-$election";
- $master->write("$home/results-$election/master-$election");
- $vl->write("$home/results-$election/confs-$election");
+ $home = "/home/$o" unless defined $home;
+ mkdir catfile("$home", "results-$election");
+ $master->write_master("$home/results-$election/master-$election");
+ $master->write_casting_voters("$home/results-$election/casting-voters-$election");
+ $vl->write_confs("$home/results-$election/confs-$election");
chown $uid, -1, "$home/results-$election",
"$home/results-$election/master-$election",
- "$home/results-$election/confs-$election";
+ "$home/results-$election/confs-$election",
+ "$home/results-$election/casting-voters-$election";
}
exit 0;
}
@@ -107,7 +114,7 @@ if ($opt{'collect'}) {
if ($opt{'rank'}) {
my ($master) = MasterBallot->new($election, $vl);
my (@candidates, @winner, @ranked, @ranks);
- $master->read("$ENV{HOME}/results-$election/master-$election");
+ $master->read_master("$ENV{HOME}/results-$election/master-$election");
$master->generate_candidates();
@candidates = sort keys %{$master->{'candidates'}};