Created
March 17, 2009 07:19
-
-
Save deepthawtz/80384 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Merb::BootLoader::RackUpApplication < Merb::BootLoader | |
| # Setup the Merb Rack App or read a rackup file located at | |
| # Merb::Config[:rackup] with the same syntax as the | |
| # rackup tool that comes with rack. Automatically evals the file in | |
| # the context of a Rack::Builder.new { } block. Allows for mounting | |
| # additional apps or middleware. | |
| # | |
| # ==== Returns | |
| # nil | |
| # | |
| # :api: plugin | |
| def self.run | |
| require 'rack' | |
| if File.exists?(Merb.dir_for(:config) / "rack.rb") | |
| Merb::Config[:rackup] ||= Merb.dir_for(:config) / "rack.rb" | |
| end | |
| if Merb::Config[:rackup] | |
| rackup_code = File.read(Merb::Config[:rackup]) | |
| Merb::Config[:app] = eval("::Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, Merb::Config[:rackup]) | |
| else | |
| Merb::Config[:app] = ::Rack::Builder.new { | |
| if prefix = ::Merb::Config[:path_prefix] | |
| use Merb::Rack::PathPrefix, prefix | |
| end | |
| use Merb::Rack::Static, Merb.dir_for(:public) | |
| run Merb::Rack::Application.new | |
| }.to_app | |
| end | |
| nil | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment