diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-03 15:13:06 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-03 15:13:06 +0000 |
commit | bc011df210e9cb56e1c4f2cc61dce002861201ef (patch) | |
tree | 085b6cf1de972663c84233e9296ccb1d780a97f1 /railties/environments | |
parent | 9bbb195c038e2c4967daaed5efb192ce51e58103 (diff) | |
download | rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.tar.gz rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.tar.bz2 rails-bc011df210e9cb56e1c4f2cc61dce002861201ef.zip |
Moved all the shared tasks from Rakefile into Rails, so that the Rakefile is empty and doesn't require updating. Added Rails::Initializer and Rails::Configuration to abstract all of the common setup out of config/environment.rb (uses config/boot.rb to bootstrap the initializer and paths)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2115 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/environments')
-rw-r--r-- | railties/environments/boot.rb | 8 | ||||
-rw-r--r-- | railties/environments/environment.rb | 96 |
2 files changed, 13 insertions, 91 deletions
diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb new file mode 100644 index 0000000000..7f30e829a9 --- /dev/null +++ b/railties/environments/boot.rb @@ -0,0 +1,8 @@ +RAILS_ROOT = File.join(File.dirname(__FILE__), '..') + +unless File.directory?("#{RAILS_ROOT}/vendor/rails") + require 'rubygems' + require 'initializer' +else + require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" +end
\ No newline at end of file diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb index 896a8faf49..6e2c616032 100644 --- a/railties/environments/environment.rb +++ b/railties/environments/environment.rb @@ -1,93 +1,7 @@ -# Load the Rails framework and configure your application. -# You can include your own configuration at the end of this file. -# # Be sure to restart your webserver when you modify this file. +# Bootstrap the Rails environment, frameworks, and default configuration +require File.join(File.dirname(__FILE__), 'boot') -# Uncomment to set UTF-8 as the encoding for strings. The Ruby default -# is US-ASCII (may differ on different platforms though). This setting is -# required if you need to return non-ASCII UTF-8 strings from ActionWebService. -# -# $KCODE = 'UTF8' - -# The path to the root directory of your application. -RAILS_ROOT = File.join(File.dirname(__FILE__), '..') - -# The environment your application is currently running. Don't set -# this here; put it in your webserver's configuration as the RAILS_ENV -# environment variable instead. -# -# See config/environments/*.rb for environment-specific configuration. -RAILS_ENV = ENV['RAILS_ENV'] || 'development' - - -# Load the Rails framework. Mock classes for testing come first. -ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"] - -# Then model subdirectories. -ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"]) -ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"]) - -# Followed by the standard includes. -ADDITIONAL_LOAD_PATHS.concat %w( - app - app/models - app/controllers - app/helpers - app/apis - components - config - lib - vendor - vendor/rails/railties - vendor/rails/railties/lib - vendor/rails/actionpack/lib - vendor/rails/activesupport/lib - vendor/rails/activerecord/lib - vendor/rails/actionmailer/lib - vendor/rails/actionwebservice/lib -).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) } - -# Prepend to $LOAD_PATH -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } - -# Require Rails libraries. -require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails") - -require 'active_support' -require 'active_record' -require 'action_controller' -require 'action_mailer' -require 'action_web_service' - -# Environment-specific configuration. -require_dependency "environments/#{RAILS_ENV}" -ActiveRecord::Base.configurations = YAML::load(ERB.new((IO.read("#{RAILS_ROOT}/config/database.yml"))).result) -ActiveRecord::Base.establish_connection - - -# Configure defaults if the included environment did not. -begin - RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log") - RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG) -rescue StandardError - RAILS_DEFAULT_LOGGER = Logger.new(STDERR) - RAILS_DEFAULT_LOGGER.level = Logger::WARN - RAILS_DEFAULT_LOGGER.warn( - "Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " + - "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." - ) -end - -[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER } -[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" } - -# Set up routes. -ActionController::Routing::Routes.reload - -Controllers = Dependencies::LoadingModule.root( - File.join(RAILS_ROOT, 'app', 'controllers'), - File.join(RAILS_ROOT, 'components') -) - -# Include your app's configuration here: - +Rails::Initializer.run do |config| + # See Rails::Configuration for options +end
\ No newline at end of file |