diff --git a/whatif.rb b/whatif.rb index cff11a5..a1e4244 100755 --- a/whatif.rb +++ b/whatif.rb @@ -45,6 +45,7 @@ MEETINGS = File.expand_path('../Meetings') unless defined? MEETINGS WHATIF = './whatif.py' unless defined? WHATIF +require 'open3' require 'wunderbar' require 'tempfile' @@ -63,9 +64,7 @@ def ini(vote) end def filtered_election(votes, seats, candidates) - list = candidates.join(' ') - - output = `#{WHATIF} #{votes} #{seats} #{list}` + output, _stderr, _rc = Open3.capture3(WHATIF, votes, seats, *candidates) 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(/[^[[:alnum:]]]/,'') => status.gsub(/\s/, '-')})