From 91ad5de7d192690952f13bdddeea0bd3df53e10a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 29 Feb 2012 14:24:07 -0500 Subject: [PATCH] a few tweaks --- lib/flowerbox/delivery/server.rb | 12 +++++++++--- lib/flowerbox/delivery/sprockets_handler.rb | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/flowerbox/delivery/server.rb b/lib/flowerbox/delivery/server.rb index bda6b07..ab9bf12 100644 --- a/lib/flowerbox/delivery/server.rb +++ b/lib/flowerbox/delivery/server.rb @@ -13,14 +13,20 @@ module Flowerbox def start @server_thread = Thread.new do - Rack::Handler::WEBrick.run(lambda { |env| [ 200, {}, [] ] }, :Port => port, :Host => interface) { |server| + ::Rack::Handler::WEBrick.run(options[:app], :Port => port, :Host => interface) do |server| + trap('QUIT') { server.stop } + Thread.current[:server] = server - } + end end - while !@server_thread[:server] + while !@server_thread[:server] && @server_thread.alive? + $stderr.puts "waiting" + sleep 0.1 end + + raise StandardError.new("Server died") if !@server_thread.alive? end def stop diff --git a/lib/flowerbox/delivery/sprockets_handler.rb b/lib/flowerbox/delivery/sprockets_handler.rb index 29bb471..9701134 100644 --- a/lib/flowerbox/delivery/sprockets_handler.rb +++ b/lib/flowerbox/delivery/sprockets_handler.rb @@ -1,10 +1,15 @@ require 'sprockets' require 'sprockets/engines' +require 'forwardable' module Flowerbox::Delivery class SprocketsHandler + extend Forwardable + attr_reader :files, :options + def_delegators :environment, :append_path + def initialize(options) @options = options @@ -29,8 +34,8 @@ module Flowerbox::Delivery @environment.register_engine('.css', Flowerbox::Delivery::Tilt::CSSTemplate) @environment.register_engine('.jst', Flowerbox::Delivery::Tilt::JSTTemplate) + options[:asset_paths].each { |path| append_path(path) } - options[:asset_paths].each { |path| @environment.append_path(path) } @environment end @@ -43,3 +48,4 @@ module Flowerbox::Delivery end end end +