Changeset 70

Show
Ignore:
Timestamp:
01/07/08 17:39:33 (11 months ago)
Author:
jweiss
Message:

update config/ to Rails 2.0.2

Location:
trunk/config
Files:
3 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/config/boot.rb

    r1 r70  
    1 # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb 
     1# Don't change this file! 
     2# Configure your app in config/environment.rb and config/environments/*.rb 
    23 
    34RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 
    45 
    5 unless defined?(Rails::Initializer) 
    6   if File.directory?("#{RAILS_ROOT}/vendor/rails") 
    7     require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 
    8   else 
    9     require 'rubygems' 
     6module Rails 
     7  class << self 
     8    def boot! 
     9      unless booted? 
     10        preinitialize 
     11        pick_boot.run 
     12      end 
     13    end 
    1014 
    11     environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join 
    12     environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/ 
    13     rails_gem_version = $1 
     15    def booted? 
     16      defined? Rails::Initializer 
     17    end 
    1418 
    15     if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version 
    16       # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems 
    17       rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last 
     19    def pick_boot 
     20      (vendor_rails? ? VendorBoot : GemBoot).new 
     21    end 
    1822 
    19       if rails_gem 
    20         gem "rails", "=#{rails_gem.version.version}" 
    21         require rails_gem.full_gem_path + '/lib/initializer' 
    22       else 
    23         STDERR.puts %(Cannot find gem for Rails ~>#{version}.0: 
    24     Install the missing gem with 'gem install -v=#{version} rails', or 
    25     change environment.rb to define RAILS_GEM_VERSION with your desired version. 
    26   ) 
    27         exit 1 
    28       end 
    29     else 
    30       gem "rails" 
    31       require 'initializer' 
     23    def vendor_rails? 
     24      File.exist?("#{RAILS_ROOT}/vendor/rails") 
     25    end 
     26 
     27    def preinitialize 
     28      load(preinitializer_path) if File.exists?(preinitializer_path) 
     29    end 
     30 
     31    def preinitializer_path 
     32      "#{RAILS_ROOT}/config/preinitializer.rb" 
    3233    end 
    3334  end 
    3435 
    35   Rails::Initializer.run(:set_load_path) 
     36  class Boot 
     37    def run 
     38      load_initializer 
     39      Rails::Initializer.run(:set_load_path) 
     40    end 
     41  end 
     42 
     43  class VendorBoot < Boot 
     44    def load_initializer 
     45      require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 
     46    end 
     47  end 
     48 
     49  class GemBoot < Boot 
     50    def load_initializer 
     51      self.class.load_rubygems 
     52      load_rails_gem 
     53      require 'initializer' 
     54    end 
     55 
     56    def load_rails_gem 
     57      if version = self.class.gem_version 
     58        gem 'rails', version 
     59      else 
     60        gem 'rails' 
     61      end 
     62    rescue Gem::LoadError => load_error 
     63      $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) 
     64      exit 1 
     65    end 
     66 
     67    class << self 
     68      def rubygems_version 
     69        Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 
     70      end 
     71 
     72      def gem_version 
     73        if defined? RAILS_GEM_VERSION 
     74          RAILS_GEM_VERSION 
     75        elsif ENV.include?('RAILS_GEM_VERSION') 
     76          ENV['RAILS_GEM_VERSION'] 
     77        else 
     78          parse_gem_version(read_environment_rb) 
     79        end 
     80      end 
     81 
     82      def load_rubygems 
     83        require 'rubygems' 
     84 
     85        unless rubygems_version >= '0.9.4' 
     86          $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 
     87          exit 1 
     88        end 
     89 
     90      rescue LoadError 
     91        $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 
     92        exit 1 
     93      end 
     94 
     95      def parse_gem_version(text) 
     96        $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/ 
     97      end 
     98 
     99      private 
     100        def read_environment_rb 
     101          File.read("#{RAILS_ROOT}/config/environment.rb") 
     102        end 
     103    end 
     104  end 
    36105end 
     106 
     107# All that for this: 
     108Rails.boot! 
  • trunk/config/environment.rb

    r63 r70  
    1 # Be sure to restart your web server when you modify this file. 
     1# Be sure to restart your server when you modify this file 
    22 
    3 # Uncomment below to force Rails into production mode when  
     3# Uncomment below to force Rails into production mode when 
    44# you don't control web/app server and can't set it the proper way 
    55# ENV['RAILS_ENV'] ||= 'production' 
     
    1212 
    1313Rails::Initializer.run do |config| 
    14   # Settings in config/environments/* take precedence over those specified here 
     14  # Settings in config/environments/* take precedence over those specified here. 
     15  # Application configuration should go into files in config/initializers 
     16  # -- all .rb files in that directory are automatically loaded. 
     17  # See Rails::Configuration for more options. 
    1518 
    16   # Skip frameworks you're not going to use (only works if using vendor/rails) 
    17   # config.frameworks -= [ :active_resource, :action_mailer ] 
     19  # Skip frameworks you're not going to use (only works if using vendor/rails). 
     20  # To use Rails without a database, you must remove the Active Record framework 
     21  # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] 
    1822 
    19   # Only load the plugins named here, by default all plugins in vendor/plugins are loaded 
    20   # config.plugins = %W( exception_notification ssl_requirement ) 
     23  # Only load the plugins named here, in the order given. By default, all plugins  
     24  # in vendor/plugins are loaded in alphabetical order. 
     25  # :all can be used as a placeholder for all plugins not explicitly named 
     26  # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 
    2127 
    2228  # Add additional load paths for your own custom dirs 
     
    2935  # Your secret key for verifying cookie session data integrity. 
    3036  # If you change this key, all old sessions will become invalid! 
     37  # Make sure the secret is at least 30 characters and all random,  
     38  # no regular words or you'll be exposed to dictionary attacks. 
    3139  config.action_controller.session = { 
    32     :session_key => '_test_session', 
    33     :secret      => 'c856f89ddabee3fc3a14e358a3e9035c' 
     40    :session_key => '_webistrano_session', 
     41    :secret      => '4a850072e0e38kvi8#e3abcbf3e0702f0c0cfab35c7e29cbee5e6f267cd8b652ffa24jkasjdh78jk3-0a9:~&@90fb7759e073f0f6ba4b0607bc10324c' 
    3442  } 
    3543 
    36   # Use the database for sessions instead of the file system 
     44  # Use the database for sessions instead of the cookie-based default, 
     45  # which shouldn't be used to store highly confidential information 
    3746  # (create the session table with 'rake db:sessions:create') 
    3847  # config.action_controller.session_store = :active_record_store 
     
    4857  # Make Active Record use UTC-base instead of local time 
    4958  config.active_record.default_timezone = :utc 
    50  
    51   # See Rails::Configuration for more options 
    52  
    53   # Application configuration should go into files in config/initializers 
    54   # -- all .rb files in that directory is automatically loaded 
    5559end 
    5660