line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
1885886
|
use strict; |
|
9
|
|
|
|
|
67
|
|
|
9
|
|
|
|
|
250
|
|
2
|
9
|
|
|
9
|
|
40
|
use warnings; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
247
|
|
3
|
9
|
|
|
9
|
|
177
|
use 5.022; |
|
9
|
|
|
|
|
28
|
|
4
|
9
|
|
|
9
|
|
43
|
use feature qw /postderef signatures/; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
1216
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: toolkit for implementing voting methods. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Vote::Count; |
9
|
9
|
|
|
9
|
|
3301
|
use namespace::autoclean; |
|
9
|
|
|
|
|
103919
|
|
|
9
|
|
|
|
|
41
|
|
10
|
9
|
|
|
9
|
|
5040
|
use Moose; |
|
9
|
|
|
|
|
3402801
|
|
|
9
|
|
|
|
|
76
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# use Data::Printer; |
13
|
9
|
|
|
9
|
|
65117
|
use Time::Piece; |
|
9
|
|
|
|
|
71568
|
|
|
9
|
|
|
|
|
47
|
|
14
|
|
|
|
|
|
|
|
15
|
9
|
|
|
9
|
|
913
|
no warnings 'experimental'; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
4724
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION=0.002; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'BallotSet' => ( is => 'ro', isa => 'HashRef' ); |
20
|
|
|
|
|
|
|
has 'BallotSetType' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
default => 'rcv', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub BUILD { |
28
|
23
|
|
|
23
|
0
|
24419
|
my $self = shift; |
29
|
|
|
|
|
|
|
# Verbose Log |
30
|
23
|
|
|
|
|
132
|
$self->{'LogV'} = localtime->cdate . "\n" ; |
31
|
|
|
|
|
|
|
# Debugging Log |
32
|
23
|
|
|
|
|
3324
|
$self->{'LogD'} = qq/Vote::Count Version $VERSION\n/; |
33
|
23
|
|
|
|
|
84
|
$self->{'LogD'} .= localtime->cdate . "\n" ; |
34
|
|
|
|
|
|
|
# Terse Log |
35
|
23
|
|
|
|
|
1839
|
$self->{'LogT'} = ''; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub logt { |
39
|
32
|
|
|
32
|
0
|
3207
|
my $self = shift @_; |
40
|
32
|
100
|
|
|
|
93
|
return $self->{'LogT'} unless ( @_) ; |
41
|
31
|
|
|
|
|
122
|
my $msg = join( "\n", @_ ) . "\n"; |
42
|
31
|
|
|
|
|
100
|
$self->{'LogT'} .= $msg; |
43
|
31
|
|
|
|
|
78
|
$self->{'LogV'} .= $msg; |
44
|
31
|
|
|
|
|
106
|
$self->logd( @_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub logv { |
48
|
147
|
|
|
147
|
0
|
2777
|
my $self = shift @_; |
49
|
147
|
100
|
|
|
|
250
|
return $self->{'LogV'} unless ( @_) ; |
50
|
146
|
|
|
|
|
304
|
my $msg = join( "\n", @_ ) . "\n"; |
51
|
146
|
|
|
|
|
357
|
$self->{'LogV'} .= $msg; |
52
|
146
|
|
|
|
|
286
|
$self->logd( @_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub logd { |
56
|
182
|
|
|
182
|
0
|
4898
|
my $self = shift @_; |
57
|
182
|
100
|
|
|
|
347
|
return $self->{'LogD'} unless ( @_) ; |
58
|
177
|
|
|
|
|
318
|
my @args = (@_); |
59
|
|
|
|
|
|
|
# since ops are seqential and fast logging event times |
60
|
|
|
|
|
|
|
# clutters the debug log. |
61
|
|
|
|
|
|
|
# unshift @args, localtime->date . ' ' . localtime->time; |
62
|
177
|
|
|
|
|
346
|
my $msg = join( "\n", @args ) . "\n"; |
63
|
177
|
|
|
|
|
534
|
$self->{'LogD'} .= $msg; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# load the roles providing the underlying ops. |
67
|
|
|
|
|
|
|
with 'Vote::Count::Approval', |
68
|
|
|
|
|
|
|
'Vote::Count::TopCount', |
69
|
|
|
|
|
|
|
'Vote::Count::Boorda', |
70
|
|
|
|
|
|
|
'Vote::Count::Floor' |
71
|
|
|
|
|
|
|
; |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
5
|
0
|
9
|
sub CountBallots ( $self ) { |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
5
|
|
74
|
5
|
|
|
|
|
141
|
my $ballots = $self->BallotSet()->{'ballots'}; |
75
|
5
|
|
|
|
|
9
|
my $numvotes = 0; |
76
|
5
|
|
|
|
|
22
|
for my $ballot ( keys $ballots->%* ) { |
77
|
50
|
|
|
|
|
68
|
$numvotes += $ballots->{$ballot}{'count'}; |
78
|
|
|
|
|
|
|
} |
79
|
5
|
|
|
|
|
35
|
return $numvotes; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|