Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6447

Show
Ignore:
Timestamp:
03/18/07 13:47:08 (3 years ago)
Author:
bitsweat
Message:

Merge [6445] from trunk. Consistently canonicalizes RAILS_ROOT on Windows and other platforms. References #6755.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/railties/CHANGELOG

    r6421 r6447  
     1*SVN* 
     2 
     3* 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] 
     4 
     5 
    16*1.2.3* (March 12th, 2007) 
    27 
  • branches/1-2-stable/railties/environments/boot.rb

    r6345 r6447  
    11# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb 
    22 
    3 unless defined?(RAILS_ROOT) 
    4   root_path = File.join(File.dirname(__FILE__), '..') 
    5  
    6   unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ 
    7     require 'pathname' 
    8     root_path = Pathname.new(root_path).cleanpath(true).to_s 
    9   end 
    10  
    11   RAILS_ROOT = root_path 
    12 end 
     3RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 
    134 
    145unless defined?(Rails::Initializer) 
  • branches/1-2-stable/railties/lib/initializer.rb

    r6041 r6447  
    11require 'logger' 
    22require 'set' 
    3 require File.join(File.dirname(__FILE__), 'railties_path') 
    4 require File.join(File.dirname(__FILE__), 'rails/version') 
     3require 'pathname' 
     4 
     5$LOAD_PATH.unshift File.dirname(__FILE__) 
     6require 'railties_path' 
     7require 'rails/version' 
     8 
    59 
    610RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) 
     
    192196          load_plugin path 
    193197        end 
    194       end  
     198      end 
    195199      $LOAD_PATH.uniq! 
    196200    end 
     
    308312    def initialize_temporary_directories 
    309313      if configuration.frameworks.include?(:action_controller) 
    310         session_path = "#{RAILS_ROOT}/tmp/sessions/" 
     314        session_path = "#{configuration.root_path}/tmp/sessions/" 
    311315        ActionController::Base.session_options[:tmpdir] = File.exist?(session_path) ? session_path : Dir::tmpdir 
    312316 
    313         cache_path = "#{RAILS_ROOT}/tmp/cache/" 
     317        cache_path = "#{configuration.root_path}/tmp/cache/" 
    314318        if File.exist?(cache_path) 
    315319          ActionController::Base.fragment_cache_store = :file_store, cache_path 
     
    415419  #   Rails::Initializer.run(:process, config) 
    416420  class Configuration 
     421    # The application's base directory. 
     422    attr_reader :root_path 
     423 
    417424    # A stub for setting options on ActionController::Base 
    418425    attr_accessor :action_controller 
     
    498505    # values. 
    499506    def initialize 
     507      set_root_path! 
     508 
    500509      self.frameworks                   = default_frameworks 
    501510      self.load_paths                   = default_load_paths 
     
    517526    end 
    518527 
     528    # Set the root_path to RAILS_ROOT and canonicalize it. 
     529    def set_root_path! 
     530      raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT) 
     531      raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT) 
     532 
     533      @root_path = 
     534        # Pathname is incompatible with Windows, but Windows doesn't have 
     535        # real symlinks so File.expand_path is safe. 
     536        if RUBY_PLATFORM =~ /(:?mswin|mingw)/ 
     537          File.expand_path(::RAILS_ROOT) 
     538 
     539        # Otherwise use Pathname#realpath which respects symlinks. 
     540        else 
     541          Pathname.new(::RAILS_ROOT).realpath.to_s 
     542        end 
     543    end 
     544 
    519545    # Loads and returns the contents of the #database_configuration_file. The 
    520546    # contents of the file are processed via ERB before being sent through 
     
    576602 
    577603    private 
    578       def root_path 
    579         ::RAILS_ROOT 
    580       end 
    581  
    582604      def framework_root_path 
    583605        defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root_path}/vendor/rails" 
  • branches/1-2-stable/railties/lib/railties_path.rb

    r2933 r6447  
    1 RAILTIES_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..')
     1RAILTIES_PATH = File.join(File.dirname(__FILE__), '..'