Rails 2.1.1
Among other things, a security fix.
This commit is contained in:
parent
d2c4c8737c
commit
d4f97345db
354 changed files with 21027 additions and 3072 deletions
59
vendor/rails/railties/lib/initializer.rb
vendored
59
vendor/rails/railties/lib/initializer.rb
vendored
|
@ -36,7 +36,8 @@ module Rails
|
|||
end
|
||||
|
||||
def env
|
||||
RAILS_ENV
|
||||
require 'active_support/string_inquirer'
|
||||
ActiveSupport::StringInquirer.new(RAILS_ENV)
|
||||
end
|
||||
|
||||
def cache
|
||||
|
@ -78,7 +79,10 @@ module Rails
|
|||
|
||||
# The set of loaded plugins.
|
||||
attr_reader :loaded_plugins
|
||||
|
||||
|
||||
# Whether or not all the gem dependencies have been met
|
||||
attr_reader :gems_dependencies_loaded
|
||||
|
||||
# Runs the initializer. By default, this will invoke the #process method,
|
||||
# which simply executes all of the initialization routines. Alternately,
|
||||
# you can specify explicitly which initialization routine you want:
|
||||
|
@ -109,10 +113,10 @@ module Rails
|
|||
check_ruby_version
|
||||
install_gem_spec_stubs
|
||||
set_load_path
|
||||
|
||||
add_gem_load_paths
|
||||
|
||||
require_frameworks
|
||||
set_autoload_paths
|
||||
add_gem_load_paths
|
||||
add_plugin_load_paths
|
||||
load_environment
|
||||
|
||||
|
@ -200,10 +204,10 @@ module Rails
|
|||
# Set the paths from which Rails will automatically load source files, and
|
||||
# the load_once paths.
|
||||
def set_autoload_paths
|
||||
Dependencies.load_paths = configuration.load_paths.uniq
|
||||
Dependencies.load_once_paths = configuration.load_once_paths.uniq
|
||||
ActiveSupport::Dependencies.load_paths = configuration.load_paths.uniq
|
||||
ActiveSupport::Dependencies.load_once_paths = configuration.load_once_paths.uniq
|
||||
|
||||
extra = Dependencies.load_once_paths - Dependencies.load_paths
|
||||
extra = ActiveSupport::Dependencies.load_once_paths - ActiveSupport::Dependencies.load_paths
|
||||
unless extra.empty?
|
||||
abort <<-end_error
|
||||
load_once_paths must be a subset of the load_paths.
|
||||
|
@ -230,7 +234,7 @@ module Rails
|
|||
end
|
||||
|
||||
# Adds all load paths from plugins to the global set of load paths, so that
|
||||
# code from plugins can be required (explicitly or automatically via Dependencies).
|
||||
# code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies).
|
||||
def add_plugin_load_paths
|
||||
plugin_loader.add_plugin_load_paths
|
||||
end
|
||||
|
@ -238,12 +242,12 @@ module Rails
|
|||
def add_gem_load_paths
|
||||
unless @configuration.gems.empty?
|
||||
require "rubygems"
|
||||
@configuration.gems.each &:add_load_paths
|
||||
@configuration.gems.each { |gem| gem.add_load_paths }
|
||||
end
|
||||
end
|
||||
|
||||
def load_gems
|
||||
@configuration.gems.each(&:load)
|
||||
@configuration.gems.each { |gem| gem.load }
|
||||
end
|
||||
|
||||
def check_gem_dependencies
|
||||
|
@ -252,11 +256,16 @@ module Rails
|
|||
@gems_dependencies_loaded = false
|
||||
# don't print if the gems rake tasks are being run
|
||||
unless $rails_gem_installer
|
||||
puts %{These gems that this application depends on are missing:}
|
||||
unloaded_gems.each do |gem|
|
||||
puts " - #{gem.name}"
|
||||
end
|
||||
puts %{Run "rake gems:install" to install them.}
|
||||
abort <<-end_error
|
||||
Missing these required gems:
|
||||
#{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "}
|
||||
|
||||
You're running:
|
||||
ruby #{Gem.ruby_version} at #{Gem.ruby}
|
||||
rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '}
|
||||
|
||||
Run `rake gems:install` to install the missing gems.
|
||||
end_error
|
||||
end
|
||||
else
|
||||
@gems_dependencies_loaded = true
|
||||
|
@ -306,7 +315,7 @@ module Rails
|
|||
end
|
||||
|
||||
def load_observers
|
||||
if @gems_dependencies_loaded && configuration.frameworks.include?(:active_record)
|
||||
if gems_dependencies_loaded && configuration.frameworks.include?(:active_record)
|
||||
ActiveRecord::Base.instantiate_observers
|
||||
end
|
||||
end
|
||||
|
@ -412,7 +421,7 @@ module Rails
|
|||
# Sets the dependency loading mechanism based on the value of
|
||||
# Configuration#cache_classes.
|
||||
def initialize_dependency_mechanism
|
||||
Dependencies.mechanism = configuration.cache_classes ? :require : :load
|
||||
ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load
|
||||
end
|
||||
|
||||
# Loads support for "whiny nil" (noisy warnings when methods are invoked
|
||||
|
@ -462,7 +471,7 @@ module Rails
|
|||
|
||||
# Fires the user-supplied after_initialize block (Configuration#after_initialize)
|
||||
def after_initialize
|
||||
if @gems_dependencies_loaded
|
||||
if gems_dependencies_loaded
|
||||
configuration.after_initialize_blocks.each do |block|
|
||||
block.call
|
||||
end
|
||||
|
@ -470,7 +479,7 @@ module Rails
|
|||
end
|
||||
|
||||
def load_application_initializers
|
||||
if @gems_dependencies_loaded
|
||||
if gems_dependencies_loaded
|
||||
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
|
||||
load(initializer)
|
||||
end
|
||||
|
@ -478,6 +487,7 @@ module Rails
|
|||
end
|
||||
|
||||
def prepare_dispatcher
|
||||
return unless configuration.frameworks.include?(:action_controller)
|
||||
require 'dispatcher' unless defined?(::Dispatcher)
|
||||
Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
|
||||
Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch
|
||||
|
@ -598,12 +608,12 @@ module Rails
|
|||
# If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
|
||||
# to make it reloadable:
|
||||
#
|
||||
# Dependencies.load_once_paths.delete lib_path
|
||||
# ActiveSupport::Dependencies.load_once_paths.delete lib_path
|
||||
#
|
||||
# If <tt>reload_plugins?</tt> is true, add this to your plugin's <tt>init.rb</tt>
|
||||
# to only load it once:
|
||||
#
|
||||
# Dependencies.load_once_paths << lib_path
|
||||
# ActiveSupport::Dependencies.load_once_paths << lib_path
|
||||
#
|
||||
attr_accessor :reload_plugins
|
||||
|
||||
|
@ -620,13 +630,17 @@ module Rails
|
|||
# You can add gems with the #gem method.
|
||||
attr_accessor :gems
|
||||
|
||||
# Adds a single Gem dependency to the rails application.
|
||||
# Adds a single Gem dependency to the rails application. By default, it will require
|
||||
# the library with the same name as the gem. Use :lib to specify a different name.
|
||||
#
|
||||
# # gem 'aws-s3', '>= 0.4.0'
|
||||
# # require 'aws/s3'
|
||||
# config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
|
||||
# :source => "http://code.whytheluckystiff.net"
|
||||
#
|
||||
# To require a library be installed, but not attempt to load it, pass :lib => false
|
||||
#
|
||||
# config.gem 'qrp', :version => '0.4.1', :lib => false
|
||||
def gem(name, options = {})
|
||||
@gems << Rails::GemDependency.new(name, options)
|
||||
end
|
||||
|
@ -698,6 +712,7 @@ module Rails
|
|||
# contents of the file are processed via ERB before being sent through
|
||||
# YAML::load.
|
||||
def database_configuration
|
||||
require 'erb'
|
||||
YAML::load(ERB.new(IO.read(database_configuration_file)).result)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue