diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-09-25 21:40:55 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-25 21:40:55 -0500 |
commit | dfbd3b94094d54483a47faa9d927370df476f572 (patch) | |
tree | a51a222e698722ecb4a4618dd73a0b691ca0098d /railties | |
parent | accd9b4634f1a2f220bc3e38cf5c4add04186fe6 (diff) | |
download | rails-dfbd3b94094d54483a47faa9d927370df476f572.tar.gz rails-dfbd3b94094d54483a47faa9d927370df476f572.tar.bz2 rails-dfbd3b94094d54483a47faa9d927370df476f572.zip |
Extract "parse_config" into AD
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application.rb | 16 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 14 | ||||
-rw-r--r-- | railties/test/application/load_test.rb | 12 |
3 files changed, 10 insertions, 32 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 7b50d2622e..d762689794 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -2,22 +2,6 @@ require 'action_controller' module Rails class Application - def self.load(path, options = {}) - config = options[:config] || 'config.ru' - config = File.join(path, config) - - if config =~ /\.ru$/ - cfgfile = File.read(config) - if cfgfile[/^#\\(.*)/] - opts.parse!($1.split(/\s+/)) - end - inner_app = eval("::Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config) - else - require config - inner_app = Object.const_get(File.basename(config, '.rb').capitalize) - end - end - def initialize @app = ActionController::Dispatcher.new end diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 743e5a0b07..25f5a8ada5 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -58,23 +58,11 @@ end ENV["RAILS_ENV"] = options[:environment] RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) -config = options[:config] -if config =~ /\.ru$/ - cfgfile = File.read(config) - if cfgfile[/^#\\(.*)/] - opts.parse!($1.split(/\s+/)) - end - inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config) -else - require config - inner_app = Object.const_get(File.basename(config, '.rb').capitalize) -end - app = Rack::Builder.new { use Rails::Rack::LogTailer unless options[:detach] use Rails::Rack::Debugger if options[:debugger] use Rails::Rack::Static - run inner_app + run ActionDispatch::Utils.parse_config(options[:config]) }.to_app puts "=> Call with -d to detach" diff --git a/railties/test/application/load_test.rb b/railties/test/application/load_test.rb index 6dda47bb8f..c5bc80197d 100644 --- a/railties/test/application/load_test.rb +++ b/railties/test/application/load_test.rb @@ -15,7 +15,13 @@ module ApplicationTests end test "running Rails::Application.load on the path returns a (vaguely) useful application" do - @app = Rails::Application.load app_path + app_file "config.ru", <<-CONFIG + require File.dirname(__FILE__) + '/config/environment' + use Rails::Rack::Static + run ActionController::Dispatcher.new + CONFIG + + @app = ActionDispatch::Utils.parse_config("#{app_path}/config.ru") assert_welcome get("/") end @@ -37,7 +43,7 @@ module ApplicationTests run proc {|env| [200, {"Content-Type" => "text/html"}, ["VICTORY"]] } CONFIG - @app = Rails::Application.load app_path, :config => "config.ru" + @app = ActionDispatch::Utils.parse_config("#{app_path}/config.ru") assert_body "VICTORY", get("/omg") assert_header "Config-Ru-Test", "TESTING", get("/omg") @@ -48,7 +54,7 @@ module ApplicationTests Myapp = proc {|env| [200, {"Content-Type" => "text/html"}, ["OMG ROBOTS"]] } CONFIG - @app = Rails::Application.load app_path, :config => "myapp.rb" + @app = ActionDispatch::Utils.parse_config("#{app_path}/myapp.rb") assert_body "OMG ROBOTS", get("/omg") end |