diff options
author | Carl Lerche <carllerche@mac.com> | 2009-09-30 12:05:34 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2009-09-30 12:05:34 -0700 |
commit | 2370e87ae0babf0fb4b21254c8120f7a93189d40 (patch) | |
tree | 163ba90026e407ff88ce2c2a71c723012e85bbda /railties/lib/rails/generators | |
parent | 34aae6d739918d972e5273b56c767dae76aa7c00 (diff) | |
download | rails-2370e87ae0babf0fb4b21254c8120f7a93189d40.tar.gz rails-2370e87ae0babf0fb4b21254c8120f7a93189d40.tar.bz2 rails-2370e87ae0babf0fb4b21254c8120f7a93189d40.zip |
Remove all calls to Rails::Initializer from boot.rb
This is starting a refactor of the rails initialization process. The boot.rb file will not remain the same.
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/boot.rb | 47 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/environment.rb | 4 |
2 files changed, 42 insertions, 9 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb index d2652af9b0..52086fbc7d 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -4,6 +4,11 @@ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails + # Mark the version of Rails that generated the boot.rb file. This is + # a temporary solution and will most likely be removed as Rails 3.0 + # comes closer. + BOOTSTRAP_VERSION = "3.0" + class << self def boot! unless booted? @@ -36,20 +41,50 @@ module Rails class Boot def run load_initializer - Rails::Initializer.run(:set_load_path) + set_load_paths + end + + def set_load_paths + %w( + railties + railties/lib + activesupport/lib + actionpack/lib + activerecord/lib + actionmailer/lib + activeresource/lib + actionwebservice/lib + ).reverse_each do |path| + path = "#{framework_root_path}/#{path}" + $LOAD_PATH.unshift(path) if File.directory?(path) + $LOAD_PATH.uniq! + end + end + + def framework_root_path + defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{RAILS_ROOT}/vendor/rails" end end class VendorBoot < Boot def load_initializer - # activesupport/lib - %w(railties/lib).each do |path| - $:.unshift("#{RAILS_ROOT}/vendor/rails/#{path}") - end + $:.unshift("#{framework_root_path}/railties/lib") require "rails" - Rails::Initializer.run(:install_gem_spec_stubs) + install_gem_spec_stubs Rails::GemDependency.add_frozen_gem_path end + + def install_gem_spec_stubs + begin; require "rubygems"; rescue LoadError; return; end + + %w(rails activesupport activerecord actionpack actionmailer activeresource).each do |stub| + Gem.loaded_specs[stub] ||= Gem::Specification.new do |s| + s.name = stub + s.version = Rails::VERSION::STRING + s.loaded_from = "" + end + end + end end class GemBoot < Boot 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 2f2d1162c0..adb3a3060a 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -6,9 +6,7 @@ # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') -module <%= app_name.camelize %>; end - -<%= app_name.camelize %>::Application = Rails::Initializer.run do |config| +Rails::Initializer.run do |config| # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. |