Skip to content
Browse files

Preliminary mocking interface for 2.3 testing

  • Loading branch information...
1 parent 55a1a46 commit 2655c11ec7d0b7926a033191e4af0ad8c13a64c2 @dhh dhh committed Nov 13, 2009
Showing with 34 additions and 1 deletion.
  1. +3 −1 init.rb
  2. +31 −0 lib/asset_router.rb
View
4 init.rb
@@ -1 +1,3 @@
-# Include hook code here
+require 'asset_router'
+
+config.middleware.use Assets::Router
View
31 lib/asset_router.rb
@@ -0,0 +1,31 @@
+require 'asset_server'
+
+module Assets
+ class Router
+ def initialize(app)
+ @app = app
+ end
+
+ Stylesheets = Assets::BundleServer.new("#{Rails.root}/public/stylesheets/**/*.css")
+ Javascripts = Assets::BundleServer.new("#{Rails.root}/public/javascripts/**/*.js")
+
+ def call(env)
+ if javascript_path?(env)
+ Javascripts.call(env)
+ elsif stylesheets_path?(env)
+ Stylesheets.call(env)
+ else
+ @app.call(env)
+ end
+ end
+
+ private
+ def javascript_path?(env)
+ env["PATH_INFO"] == "/javascripts/xall.js"
+ end
+
+ def stylesheets_path?(env)
+ env["PATH_INFO"] == "/stylesheets/xall.css"
+ end
+ end
+end

0 comments on commit 2655c11

Please sign in to comment.
Something went wrong with that request. Please try again.