X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fpocket-devotee;h=5e7b3ec59058a3f1c798661d3883c86f376a96fc;hb=e0199d4df4c6ed9aef465f8ecda16cf9eb7117cb;hp=9107a0b6d626761f29497f7bb9d42ee5c180eea2;hpb=931f6e0e582fe9438436c84f415246188c88c2f6;p=debian-ctte.git diff --git a/scripts/pocket-devotee b/scripts/pocket-devotee index 9107a0b..5e7b3ec 100755 --- a/scripts/pocket-devotee +++ b/scripts/pocket-devotee @@ -108,7 +108,7 @@ sub main { } my @options; for my $option (@{$options{option}}) { - my ($key,$name,$majority) = split /:/,$option; + my ($key,$name,$majority) = $option =~ /^\s*([^:]+)\s*:\s*(.+?)\s*(?::(\d+))?$/; $majority //= 1; push @options,{key => $key, name => $name, @@ -184,6 +184,8 @@ sub winner { if (not defined $params{tally_fh}) { $params{tally_fh} = \*STDIN; } + # header been output? + my $header_output = 0; # This is where we get our input data from while (defined ($_ = $params{tally_fh}->getline)) { @@ -216,7 +218,11 @@ sub winner { } $vote = ''; for my $opt (@options) { - $vote .= exists $option_rank{$opt->{key}} ? $option_rank{$opt->{key}} : '-'; + $vote .= exists $option_rank{$opt->{key}} ? $number_to_option{$option_rank{$opt->{key}}} : '-'; + } + if (not $header_output) { + print {$RESULTS} "/--".join("",map {$_->{key}} @options)."\n"; + $header_output = 1; } print {$RESULTS} "V: $vote $voter\n"; @@ -279,7 +285,7 @@ EOF printf {$RESULTS} "Option %s ", $order_to_options{$row + 1}{key}; for my $col (0..($max_choices - 1)) { if ($row == $col) { - printf {$RESULTS} " ", $Beat_Matrix[$row][$col]; + print {$RESULTS} " "; } else { printf {$RESULTS} " % 4d ", $Beat_Matrix[$row][$col]; } @@ -305,12 +311,12 @@ EOM foreach my $i (0..($max_choices - 2)) { if ($K > $Beat_Matrix[$i][$max_choices - 1]) { $Drop{$i}++; - print {$RESULTS} "Dropping Option", $order_to_options{$i + 1}{key}, + print {$RESULTS} "Dropping Option ", $order_to_options{$i + 1}{key}, " \"", $order_to_options{$i + 1}{name}, - "\" because of Quorum\n"; + "\" because of Quorum ($K > $Beat_Matrix[$i][$max_choices - 1])\n"; } else { print {$RESULTS} "Option ", $order_to_options{$i + 1}{key}, - " Reached quorum: $Beat_Matrix[$i][$max_choices - 1] > $K\n"; + " Reached quorum: $Beat_Matrix[$i][$max_choices - 1] >= $K\n"; } } print {$RESULTS} "\n\n";