veto

Simple Sinatra voting website.
git clone git://git.knutsen.co/veto
Log | Files | Refs | README | LICENSE

commit 8e7325aa21d102575218864bd6e5033dc0087782
parent 176bb66a863a4e879a58d5088373a01f273b4379
Author: Fredrik <moi@knutsen.co>
Date:   Sun, 17 Mar 2019 00:54:51 +0000

Merge pull request #28 from Demonstrandum/devel

Devel
Diffstat:
MDockerfile | 2+-
MGemfile.lock | 4++--
Mserver.rb | 8++++++--
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5.0-alpine +FROM ruby:2.6.0-alpine RUN apk update && apk --update --no-cache add libstdc++ RUN apk --update --no-cache add --virtual .build_deps git g++ musl-dev make diff --git a/Gemfile.lock b/Gemfile.lock @@ -32,8 +32,8 @@ DEPENDENCIES mongo rack (~> 2.0, >= 2.0.6) rack-ssl (~> 1.4) - sinatra (~> 2.0, >= 2.0.1) + sinatra (~> 2.0, >= 2.0.4) thin BUNDLED WITH - 1.16.6 + 2.0.1 diff --git a/server.rb b/server.rb @@ -33,8 +33,12 @@ def make_poll code, name, alt end class String + def pseudo_dot + self.gsub '.', "\u2024" # Full-stop look-alike, since MongoDB uses dot notation. + end + def pseudo_dot! - self.gsub! '.', "\u2024" # Full-stop look-alike, since MongoDB uses dot notation. + replace pseudo_dot end end @@ -121,7 +125,7 @@ post '/new' do params[:primary].each do |option| POLLS.update_one({:code => params[:code]}, { :"$set" => { - :"votes.#{option.pseudo_dot!}" => { + :"votes.#{option.pseudo_dot}" => { :number => 0, :primary => true, :date => Time.now