From 22bdec012427b49041bce3ae4f56d2ea87afb3ac Mon Sep 17 00:00:00 2001 From: Thomas Clavier Date: Thu, 13 Jun 2013 10:25:33 +0200 Subject: [PATCH 1/3] New Question : what is the previous day of ... --- lib/extreme_startup/question_factory.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/extreme_startup/question_factory.rb b/lib/extreme_startup/question_factory.rb index 3e935cd..59f90fb 100644 --- a/lib/extreme_startup/question_factory.rb +++ b/lib/extreme_startup/question_factory.rb @@ -306,6 +306,7 @@ class GeneralKnowledgeQuestion < Question class << self def question_bank [ + ["who created 'Il pulcino Pio'", "Lucio Scarpa"], ["who is the Prime Minister of Great Britain", "David Cameron"], ["which city is the Eiffel tower in", "Paris"], ["what currency did Spain use before the Euro", "peseta"], @@ -386,6 +387,29 @@ def scrabble_scores end end + require 'date' + class BeforeDateQuestion < Question + def initialize(player, date=nil) + if date + @date = Date.strptime(date, '%d-%m-%Y') + else + @date = Date.new(2013,rand(11) + 1,rand(27)+1) + end + end + + def points + 30 + end + + def correct_answer + @date.prev_day().strftime('%d-%m-%Y') + end + + def as_text + "what is the previous day of #{@date.strftime('%d-%m-%Y')}" + end + end + class QuestionFactory attr_reader :round @@ -397,6 +421,7 @@ def initialize MultiplicationQuestion, SquareCubeQuestion, GeneralKnowledgeQuestion, + BeforeDateQuestion, PrimesQuestion, SubtractionQuestion, FibonacciQuestion, From e14e620658f5f244c22b7ab585e5aa5788750f23 Mon Sep 17 00:00:00 2001 From: Thomas Clavier Date: Thu, 13 Jun 2013 10:27:08 +0200 Subject: [PATCH 2/3] migrate to last eventmachine --- Gemfile | 2 +- Gemfile.lock | 97 +++++++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/Gemfile b/Gemfile index 5422d67..f4c3c13 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source :rubygems -gem 'eventmachine', '1.0.0.beta.3' +gem "eventmachine" gem 'thin' gem 'sinatra' gem 'httparty' diff --git a/Gemfile.lock b/Gemfile.lock index 9f1dc1f..480aa7a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,66 +1,61 @@ GEM remote: http://rubygems.org/ specs: - builder (3.0.0) - capybara (1.0.0) + builder (3.2.1) + capybara (2.1.0) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) - selenium-webdriver (~> 0.2.0) - xpath (~> 0.1.4) - childprocess (0.1.9) - ffi (~> 1.0.6) - crack (0.1.8) - cucumber (0.10.6) + xpath (~> 2.0) + cucumber (1.3.2) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.4.0) - json (>= 1.4.6) - term-ansicolor (>= 1.0.5) - daemons (1.1.3) - diff-lcs (1.1.2) - eventmachine (1.0.0.beta.3) - ffi (1.0.9) - gherkin (2.4.0) - json (>= 1.4.6) - haml (3.1.2) - httparty (0.7.8) - crack (= 0.1.8) - json (1.5.2) - json_pure (1.5.2) - macaddr (1.0.0) - mime-types (1.16) - nokogiri (1.4.5) - rack (1.3.0) - rack-test (0.6.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.12.0) + multi_json (~> 1.3) + daemons (1.1.9) + diff-lcs (1.2.4) + eventmachine (1.0.3) + gherkin (2.12.0) + multi_json (~> 1.3) + haml (4.0.3) + tilt + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) + json (1.8.0) + macaddr (1.6.1) + systemu (~> 2.5.0) + mime-types (1.23) + multi_json (1.7.4) + multi_xml (0.5.3) + nokogiri (1.5.9) + rack (1.5.2) + rack-protection (1.5.0) + rack + rack-test (0.6.2) rack (>= 1.0) - rspec (2.6.0) - rspec-core (~> 2.6.0) - rspec-expectations (~> 2.6.0) - rspec-mocks (~> 2.6.0) - rspec-core (2.6.4) - rspec-expectations (2.6.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.6.0) - rubyzip (0.9.4) - selenium-webdriver (0.2.1) - childprocess (>= 0.1.7) - ffi (>= 1.0.7) - json_pure - rubyzip - sinatra (1.2.6) - rack (~> 1.1) - tilt (>= 1.2.2, < 2.0) - term-ansicolor (1.0.5) - thin (1.2.11) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + sinatra (1.4.2) + rack (~> 1.5, >= 1.5.2) + rack-protection (~> 1.4) + tilt (~> 1.3, >= 1.3.4) + systemu (2.5.2) + thin (1.5.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) - tilt (1.3.2) - uuid (2.3.2) + tilt (1.4.1) + uuid (2.3.7) macaddr (~> 1.0) - xpath (0.1.4) + xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS @@ -69,7 +64,7 @@ PLATFORMS DEPENDENCIES capybara cucumber - eventmachine (= 1.0.0.beta.3) + eventmachine haml httparty json From a9289281e6c17919fcf39030eb981ef902bd324e Mon Sep 17 00:00:00 2001 From: Thomas Clavier Date: Fri, 12 Dec 2014 11:51:46 +0100 Subject: [PATCH 3/3] If the route return code is an int, sinatra use it as http status code --- lib/extreme_startup/web_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extreme_startup/web_server.rb b/lib/extreme_startup/web_server.rb index e97981c..647ac8b 100644 --- a/lib/extreme_startup/web_server.rb +++ b/lib/extreme_startup/web_server.rb @@ -133,7 +133,7 @@ def to_json(*a) end post '/advance_round' do - question_factory.advance_round + question_factory.advance_round.to_s end post '/pause' do