1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Deprecation: remove components from controller paths. Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn't have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. Closes #6755.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6445 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-03-18 13:35:16 +00:00
parent 27ba5edef1
commit 2632664f64
4 changed files with 46 additions and 30 deletions

View file

@ -1,5 +1,9 @@
*SVN*
* Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn't have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. #6755 [Jeremy Kemper, trevor]
* Deprecation: remove components from controller paths. [Jeremy Kemper]
* Add environment variable RAILS_DEFAULT_DATABASE, which allows the builtin default of 'mysql' to be overridden. [Nicholas Seckar]
* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess]

View file

@ -1,15 +1,6 @@
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS_ROOT = root_path
end
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
unless defined?(Rails::Initializer)
if File.directory?("#{RAILS_ROOT}/vendor/rails")

View file

@ -1,9 +1,12 @@
require 'logger'
require 'set'
require File.join(File.dirname(__FILE__), 'railties_path')
require File.join(File.dirname(__FILE__), 'rails/version')
require File.join(File.dirname(__FILE__), 'rails/plugin/locator')
require File.join(File.dirname(__FILE__), 'rails/plugin/loader')
require 'pathname'
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'railties_path'
require 'rails/version'
require 'rails/plugin/locator'
require 'rails/plugin/loader'
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
@ -307,10 +310,10 @@ module Rails
def initialize_temporary_directories
if configuration.frameworks.include?(:action_controller)
session_path = "#{RAILS_ROOT}/tmp/sessions/"
session_path = "#{configuration.root_path}/tmp/sessions/"
ActionController::Base.session_options[:tmpdir] = File.exist?(session_path) ? session_path : Dir::tmpdir
cache_path = "#{RAILS_ROOT}/tmp/cache/"
cache_path = "#{configuration.root_path}/tmp/cache/"
if File.exist?(cache_path)
ActionController::Base.fragment_cache_store = :file_store, cache_path
end
@ -336,7 +339,7 @@ module Rails
end
def load_application_initializers
Dir["#{RAILS_ROOT}/config/initializers/**/*.rb"].each do |initializer|
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].each do |initializer|
load(initializer)
end
end
@ -362,6 +365,9 @@ module Rails
# config = Rails::Configuration.new
# Rails::Initializer.run(:process, config)
class Configuration
# The application's base directory.
attr_reader :root_path
# A stub for setting options on ActionController::Base
attr_accessor :action_controller
@ -456,6 +462,8 @@ module Rails
# Create a new Configuration instance, initialized with the default
# values.
def initialize
set_root_path!
self.frameworks = default_frameworks
self.load_paths = default_load_paths
self.load_once_paths = default_load_once_paths
@ -477,6 +485,23 @@ module Rails
end
end
# Set the root_path to RAILS_ROOT and canonicalize it.
def set_root_path!
raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT)
raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT)
@root_path =
# Pathname is incompatible with Windows, but Windows doesn't have
# real symlinks so File.expand_path is safe.
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
Pathname.new(::RAILS_ROOT).realpath.to_s
end
end
# Loads and returns the contents of the #database_configuration_file. The
# contents of the file are processed via ERB before being sent through
# YAML::load.
@ -536,10 +561,6 @@ module Rails
end
private
def root_path
::RAILS_ROOT
end
def framework_root_path
defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root_path}/vendor/rails"
end
@ -596,7 +617,7 @@ module Rails
end
def default_controller_paths
paths = [ File.join(root_path, 'app', 'controllers'), File.join(root_path, 'components') ]
paths = [File.join(root_path, 'app', 'controllers')]
paths.concat builtin_directories
paths
end

View file

@ -1 +1 @@
RAILTIES_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
RAILTIES_PATH = File.join(File.dirname(__FILE__), '..')