Permalink
Browse files

Merge [6445] from trunk. Consistently canonicalizes RAILS_ROOT on Win…

…dows and other platforms. References #6755.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6447 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jeremy committed Mar 18, 2007
1 parent eefa0a2 commit 53c87f9818ac57beacd5b06bbe282a532c6d3663
Showing with 38 additions and 20 deletions.
  1. +5 −0 railties/CHANGELOG
  2. +1 −10 railties/environments/boot.rb
  3. +31 −9 railties/lib/initializer.rb
  4. +1 −1 railties/lib/railties_path.rb
View
@@ -1,3 +1,8 @@
*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]
*1.2.3* (March 12th, 2007)
* Ruby 1.8.6 compatibility fixes. Upgrade rake dependency to 0.7.2.
@@ -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")
@@ -1,7 +1,11 @@
require 'logger'
require 'set'
require File.join(File.dirname(__FILE__), 'railties_path')
require File.join(File.dirname(__FILE__), 'rails/version')
require 'pathname'
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'railties_path'
require 'rails/version'
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
@@ -191,7 +195,7 @@ def load_plugins
raise(LoadError, "Cannot find the plugin '#{name}'!") if path.nil?
load_plugin path
end
end
end
$LOAD_PATH.uniq!
end
@@ -307,10 +311,10 @@ def initialize_whiny_nils
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
@@ -414,6 +418,9 @@ def load_plugin(directory)
# 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
@@ -497,6 +504,8 @@ class Configuration
# 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
@@ -516,6 +525,23 @@ def initialize
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.
@@ -575,10 +601,6 @@ def framework_paths
end
private
def root_path
::RAILS_ROOT
end
def framework_root_path
defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root_path}/vendor/rails"
end
@@ -1 +1 @@
RAILTIES_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
RAILTIES_PATH = File.join(File.dirname(__FILE__), '..')

0 comments on commit 53c87f9

Please sign in to comment.