From 04854f42e452e941fd3eb86140e3e13bc50f4bc8 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 21 Mar 2012 19:57:30 -0400 Subject: [PATCH] clean up a little more stuff --- lib/flowerbox/rack.rb | 48 ++---------------------------------- lib/flowerbox/runner/base.rb | 2 ++ lib/flowerbox/server.rb | 1 + 3 files changed, 5 insertions(+), 46 deletions(-) diff --git a/lib/flowerbox/rack.rb b/lib/flowerbox/rack.rb index 70dd28d..b54c13c 100644 --- a/lib/flowerbox/rack.rb +++ b/lib/flowerbox/rack.rb @@ -1,5 +1,4 @@ require 'sinatra' -require 'json' require 'cgi' module Flowerbox @@ -8,55 +7,12 @@ module Flowerbox attr_accessor :runner, :sprockets end - def runner - self.class.runner - end - def sprockets self.class.sprockets end - def data - JSON.parse(request.body.string) - end - - def self.command(*args, &block) - url, args = args - url = "/#{url}" - - post(url, *args) do - instance_eval(&block) - - "" - end - end - - command :results do - runner.finish!(data.flatten.first) - end - - command :start_test do - runner.add_tests(data.flatten) - end - - command :finish_test do - runner.add_results(data.flatten) - end - - command :log do - runner.log(data.first) - end - - command :ping do - end - - command :pause_timer do - end - - command :unpause_timer do - end - - command :starting do + def runner + self.class.runner end get %r{^/__F__/(.*)$} do |file| diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index dc22a33..d9421ad 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -59,6 +59,8 @@ module Flowerbox attempts = 3 + require 'flowerbox/server' + while true begin server.start diff --git a/lib/flowerbox/server.rb b/lib/flowerbox/server.rb index 24dd4bb..61ab632 100644 --- a/lib/flowerbox/server.rb +++ b/lib/flowerbox/server.rb @@ -4,6 +4,7 @@ require 'socket' require 'rack/builder' require 'thin' require 'em-websocket' +require 'json' module Flowerbox class Server