From d8594026962704b6b51e188a29406fbd22bb31ce Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 16 Oct 2009 18:58:35 -0500 Subject: Use Rails.initialize! where we just want to run the initializers and aren't concerned about the config --- railties/lib/rails/application.rb | 5 +++++ railties/lib/rails/commands/about.rb | 2 +- railties/lib/rails/commands/generate.rb | 2 +- railties/lib/rails/commands/performance/benchmarker.rb | 2 +- railties/lib/rails/commands/performance/profiler.rb | 2 +- railties/lib/rails/commands/runner.rb | 2 +- railties/lib/rails/core.rb | 4 ++++ .../lib/rails/generators/rails/app/templates/config/environment.rb | 2 +- 8 files changed, 15 insertions(+), 6 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index fe2dc3769e..621f1c3878 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -3,6 +3,11 @@ module Rails extend Initializable class << self + # Stub out App initialize + def initialize! + new + end + def config @config ||= Configuration.new end diff --git a/railties/lib/rails/commands/about.rb b/railties/lib/rails/commands/about.rb index 54c12a266f..6fdbc08027 100644 --- a/railties/lib/rails/commands/about.rb +++ b/railties/lib/rails/commands/about.rb @@ -1,3 +1,3 @@ -Rails.application.new +Rails.initialize! require 'rails/info' puts Rails::Info diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index cfa6a51d94..22aefa803a 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,5 +1,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) -Rails.application.new +Rails.initialize! if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/commands/performance/benchmarker.rb b/railties/lib/rails/commands/performance/benchmarker.rb index 5039c5408c..5420b57311 100644 --- a/railties/lib/rails/commands/performance/benchmarker.rb +++ b/railties/lib/rails/commands/performance/benchmarker.rb @@ -12,7 +12,7 @@ end require 'benchmark' include Benchmark -Rails.application.new +Rails.initialize! # Don't include compilation in the benchmark ARGV.each { |expression| eval(expression) } diff --git a/railties/lib/rails/commands/performance/profiler.rb b/railties/lib/rails/commands/performance/profiler.rb index 7274e2dfb7..30346dc0e7 100644 --- a/railties/lib/rails/commands/performance/profiler.rb +++ b/railties/lib/rails/commands/performance/profiler.rb @@ -5,7 +5,7 @@ end # Keep the expensive require out of the profile. $stderr.puts 'Loading Rails...' -Rails.application.new # Initialize the application +Rails.initialize! # Initialize the application # Define a method to profile. if ARGV[1] and ARGV[1].to_i > 1 diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index d24f36dd63..84d72f9fa9 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -36,7 +36,7 @@ ARGV.delete(code_or_file) ENV["RAILS_ENV"] = options[:environment] RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) -Rails.application.new +Rails.initialize! begin if code_or_file.nil? diff --git a/railties/lib/rails/core.rb b/railties/lib/rails/core.rb index e15661e2d7..6e7f912e6d 100644 --- a/railties/lib/rails/core.rb +++ b/railties/lib/rails/core.rb @@ -18,6 +18,10 @@ module Rails application.configuration end + def initialize! + application.initialize! + end + def initialized? @initialized || false end diff --git a/railties/lib/rails/generators/rails/app/templates/config/environment.rb b/railties/lib/rails/generators/rails/app/templates/config/environment.rb index fcf4eddb00..3bb0f2619e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -6,4 +6,4 @@ # Load the rails application require File.expand_path(File.join(File.dirname(__FILE__), 'application')) # Initialize the rails application -Rails.application.new +Rails.initialize! -- cgit v1.2.3