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 'jasmine-core'
gem.add_dependency 'thor' gem.add_dependency 'thor'
gem.add_dependency 'selenium-webdriver' gem.add_dependency 'selenium-webdriver'
gem.add_dependency 'sinatra'
gem.add_dependency 'rainbow' gem.add_dependency 'rainbow'
gem.add_dependency 'sprockets' gem.add_dependency 'sprockets'
gem.add_dependency 'sprockets-vendor_gems' gem.add_dependency 'sprockets-vendor_gems'

View File

@ -1,34 +1,20 @@
require 'sinatra'
require 'cgi'
module Flowerbox module Flowerbox
class Rack < Sinatra::Base class Rack
class << self attr_accessor :runner, :sprockets
attr_accessor :runner, :sprockets
def initialize(runner, sprockets)
@runner, @sprockets = runner, sprockets
end end
def sprockets def call(env)
self.class.sprockets dup._call(env)
end end
def runner def _call(env)
self.class.runner if sprockets_file = env['PATH_INFO'][%r{/__F__(.*)$}, 1]
end sprockets.call(env.merge('PATH_INFO' => sprockets_file))
else
get %r{^/__F__/(.*)$} do |file| [ 200, { 'Content-type' => 'text/html' }, [ runner.template ] ]
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
end end
end end
end end

View File

@ -131,14 +131,15 @@ module Flowerbox
def server def server
require 'flowerbox/rack' require 'flowerbox/rack'
Flowerbox::Rack.runner = self if Flowerbox.server
Flowerbox::Rack.sprockets = @sprockets Flowerbox.server.app.runner = self
Flowerbox.server.app.sprockets = sprockets
return Flowerbox.server if Flowerbox.server return Flowerbox.server
end
require 'flowerbox/server' 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[:logging] = true if options[:verbose_server]
server_options[:port] = Flowerbox.port server_options[:port] = Flowerbox.port

View File

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