From: John Dong
Date: Wed, 15 Aug 2007 21:56:18 +0000 (-0400)
Subject: Merge from Justin
X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/0bcced90721389c27eb815ca8dcab85533417697?ds=inline;hp=-c
Merge from Justin
Fix runtime errors in RubyVote introduced.
---
0bcced90721389c27eb815ca8dcab85533417697
diff --combined app/views/quickvote/results.rhtml
index 9677d9a,5626636..3b3a54d
--- a/app/views/quickvote/results.rhtml
+++ b/app/views/quickvote/results.rhtml
@@@ -145,7 -145,6 +145,6 @@@ by several other names.
Voters
-
IP Address |
@@@ -160,7 -159,7 +159,7 @@@
<%= `host #{IPAddr.new(voter.ipaddress).to_s}`.sub(/^.*pointer (.*)\.$/, '\1') %>
<% rescue ArgumentError => err %>
- <%= " - " %>
+ <%= voter.ipaddress %>
<% end %>
<%= voter.vote.votestring %> |
@@@ -168,8 -167,9 +167,9 @@@
<% end %>
+ <%= render :partial => 'pref_table' %>
+
<%= image_tag( graph_url( :action => 'votes_per_day', :id => @election ) ) %>
<%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %>
<%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>
-
diff --combined lib/rubyvote/election.rb
index 42f18bb,efb8dd8..ffd31c8
--- a/lib/rubyvote/election.rb
+++ b/lib/rubyvote/election.rb
@@@ -140,7 -140,8 +140,8 @@@ en
class PluralityResult < ElectionResult
attr_reader :ranked_candidates
-
+ attr_reader :points
+
def initialize(voteobj=nil)
super(voteobj)
@@@ -151,6 -152,8 +152,8 @@@
b[1] <=> a[1]
end.collect {|a| a[0]}
- @points = self.election.votes
++ @points = @election.votes
+
# winners are anyone who has the same number of votes as the
# first person
@winners = @ranked_candidates.find_all do |i|
diff --combined lib/rubyvote/positional.rb
index 3de3fb2,dc0b63a..056194b
--- a/lib/rubyvote/positional.rb
+++ b/lib/rubyvote/positional.rb
@@@ -38,7 -38,7 +38,7 @@@ class BordaVote < ElectionVot
end
super(votes)
end
-
+
def tally_vote(vote)
points = candidates.length - 1
vote.each do |candidate|
@@@ -51,7 -51,7 +51,7 @@@
points -= 1
end
end
-
+
def verify_vote(vote=nil)
vote.instance_of?( Array ) and
vote == vote.uniq
@@@ -64,11 -64,12 +64,12 @@@ en
class BordaResult < ElectionResult
attr_reader :ranked_candidates
+ attr_reader :points
def initialize(voteobj=nil)
super(voteobj)
votes = @election.votes
-
+
@ranked_candidates = votes.sort do |a, b|
b[1] <=> a[1]
end.collect {|i| i[0]}
@@@ -76,6 -77,8 +77,8 @@@
@winners = @ranked_candidates.find_all do |i|
votes[i] == votes[@ranked_candidates[0]]
end
+
- @points = self.election.votes
++ @points = @election.votes
end
end