remove sinatra dependency, go pure rack

This commit is contained in:
John Bintz 2012-03-22 11:55:35 -04:00
parent 8e669b65c6
commit a4296650a1
4 changed files with 20 additions and 34 deletions

View File

@ -28,7 +28,6 @@ Gem::Specification.new do |gem|
gem.add_dependency 'jasmine-core'
gem.add_dependency 'thor'
gem.add_dependency 'selenium-webdriver'
gem.add_dependency 'sinatra'
gem.add_dependency 'rainbow'
gem.add_dependency 'sprockets'
gem.add_dependency 'sprockets-vendor_gems'

View File

@ -1,34 +1,20 @@
require 'sinatra'
require 'cgi'
module Flowerbox
class Rack < Sinatra::Base
class << self
attr_accessor :runner, :sprockets
class Rack
attr_accessor :runner, :sprockets
def initialize(runner, sprockets)
@runner, @sprockets = runner, sprockets
end
def sprockets
self.class.sprockets
def call(env)
dup._call(env)
end
def runner
self.class.runner
end
get %r{^/__F__/(.*)$} do |file|
asset = sprockets.asset_for(file, :bundle => false)
halt(404) if !asset
content_type asset.content_type
asset.body
end
get '/' do
begin
runner.template
rescue Flowerbox::Runner::Base::RunnerDiedError => e
e.message
def _call(env)
if sprockets_file = env['PATH_INFO'][%r{/__F__(.*)$}, 1]
sprockets.call(env.merge('PATH_INFO' => sprockets_file))
else
[ 200, { 'Content-type' => 'text/html' }, [ runner.template ] ]
end
end
end

View File

@ -131,14 +131,15 @@ module Flowerbox
def server
require 'flowerbox/rack'
Flowerbox::Rack.runner = self
Flowerbox::Rack.sprockets = @sprockets
return Flowerbox.server if Flowerbox.server
if Flowerbox.server
Flowerbox.server.app.runner = self
Flowerbox.server.app.sprockets = sprockets
return Flowerbox.server
end
require 'flowerbox/server'
server_options = { :app => Flowerbox::Rack }
server_options = { :app => Flowerbox::Rack.new(self, sprockets) }
server_options[:logging] = true if options[:verbose_server]
server_options[:port] = Flowerbox.port

View File

@ -10,7 +10,7 @@ module Flowerbox
attr_reader :files, :options
def_delegators :environment, :append_path, :register_engine, :[]
def_delegators :environment, :append_path, :register_engine, :[], :call
def self.gem_asset_paths
@gem_asset_paths ||= Sprockets.find_gem_vendor_paths
@ -29,7 +29,7 @@ module Flowerbox
end
def assets_for(asset)
environment.find_asset(asset, :bundle => false).to_a
environment.find_asset(asset, :bundle => true).to_a
end
def expire_index!