Merge from Justin
authorJohn Dong <jdong@mit.edu>
Wed, 15 Aug 2007 21:56:18 +0000 (17:56 -0400)
committerJohn Dong <jdong@mit.edu>
Wed, 15 Aug 2007 21:56:18 +0000 (17:56 -0400)
Fix runtime errors in RubyVote introduced.

1  2 
app/views/quickvote/results.rhtml
lib/rubyvote/election.rb
lib/rubyvote/positional.rb

index 9677d9ac0ae307e2ab7d102da2827b5e4a516220,5626636c7000b0a29aa9de1c07bb2c24d6529a8e..3b3a54d9ef68e11128b22891956d9bdb05cdf9fd
@@@ -145,7 -145,6 +145,6 @@@ by several other names.</p
  <div class="clearbox"></div>
  
  <h2>Voters</h2>
  <table class="voterbox">
  <tr>
  <th>IP Address</th>
        <%= `host #{IPAddr.new(voter.ipaddress).to_s}`.sub(/^.*pointer (.*)\.$/, '\1') %>
      
      <% rescue ArgumentError => err %>
 -      <%= " - " %>
 +      <%= voter.ipaddress %>
      <% end %>
      </td>
    <td><%= voter.vote.votestring %></td>
  <% end %>
  </table>
  
+ <%= render :partial => 'pref_table' %>
  <%= image_tag( graph_url( :action => 'votes_per_day', :id => @election ) ) %><br />
  <%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%><br />
  <%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
  <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>
diff --combined lib/rubyvote/election.rb
index 42f18bb6c9fa7470e34c46051787573b377fdce2,efb8dd8aae1ce56abc9896853a32eaf5c0f562da..ffd31c846e56400e9df945361d5a4c11ebb9df9d
@@@ -140,7 -140,8 +140,8 @@@ en
  
  class PluralityResult < ElectionResult
    attr_reader :ranked_candidates
+   attr_reader :points
+   
    def initialize(voteobj=nil)
      super(voteobj)
  
        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|
index 3de3fb29ae6f20b0371eedacb41471ff73be279f,dc0b63aca3811bdb07e2fdcfb4f4107d5d53b0d3..056194b519dc88f2a79adc3617bf95f250fa3310
@@@ -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

Benjamin Mako Hill || Want to submit a patch?