You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by ru...@apache.org on 2021/03/11 23:03:37 UTC

svn commit: r1887521 - /steve/trunk/whatif.rb

Author: rubys
Date: Thu Mar 11 23:03:37 2021
New Revision: 1887521

URL: http://svn.apache.org/viewvc?rev=1887521&view=rev
Log:
unicode stuffs

Modified:
    steve/trunk/whatif.rb

Modified: steve/trunk/whatif.rb
URL: http://svn.apache.org/viewvc/steve/trunk/whatif.rb?rev=1887521&r1=1887520&r2=1887521&view=diff
==============================================================================
--- steve/trunk/whatif.rb (original)
+++ steve/trunk/whatif.rb Thu Mar 11 23:03:37 2021
@@ -71,14 +71,14 @@ def filtered_election(votes, seats, cand
   output = `#{WHATIF} #{votes} #{seats} #{list}`
   output.scan(/.*elected$/).inject(Hash.new('none')) do |results, line|
     name, status = line.scan(/^(.*?)\s+(n?o?t?\s?elected)$/).flatten
-    results.merge({name.gsub(/\W/,'') => status.gsub(/\s/, '-')})
+    results.merge({name.gsub(/[^[[:alnum:]]]/,'') => status.gsub(/\s/, '-')})
   end
 end
 
 # XMLHttpRequest (AJAX)
 _json do
   nominees = File.read(ini(raw_votes(@date))).scan(/^\w:\s*(.*)/).flatten
-  candidates = params.keys & nominees.map {|name| name.gsub(/\W/,'')}
+  candidates = params.keys & nominees.map {|name| name.gsub(/[^[[:alnum:]]]/,'')}
   _! filtered_election(raw_votes(@date), @seats, candidates)
 end
 
@@ -107,7 +107,7 @@ _html do
     _h1_ 'STV Explorer'
 
     nominees = Hash[File.read(ini(raw_votes(@date))).scan(/^\w:\s*(.*)/).
-      flatten.map {|name| [name.gsub(/\W/,''), name]}]
+      flatten.map {|name| [name.gsub(/[^[[:alnum:]]]/,''), name]}]
     candidates = params.keys & nominees.keys
     candidates = nominees.keys if candidates.empty? or @reset