Rails 2.1
Update to Rails 2.1 final.
This commit is contained in:
parent
fd554cce90
commit
516d6dfac0
257 changed files with 4058 additions and 1933 deletions
91
vendor/rails/railties/lib/initializer.rb
vendored
91
vendor/rails/railties/lib/initializer.rb
vendored
|
@ -43,6 +43,10 @@ module Rails
|
|||
RAILS_CACHE
|
||||
end
|
||||
|
||||
def version
|
||||
VERSION::STRING
|
||||
end
|
||||
|
||||
def public_path
|
||||
@@public_path ||= self.root ? File.join(self.root, "public") : "public"
|
||||
end
|
||||
|
@ -136,7 +140,8 @@ module Rails
|
|||
# pick up any gems that plugins depend on
|
||||
add_gem_load_paths
|
||||
load_gems
|
||||
|
||||
check_gem_dependencies
|
||||
|
||||
load_application_initializers
|
||||
|
||||
# the framework is now fully initialized
|
||||
|
@ -149,6 +154,7 @@ module Rails
|
|||
initialize_routing
|
||||
|
||||
# Observers are loaded after plugins in case Observers or observed models are modified by plugins.
|
||||
|
||||
load_observers
|
||||
end
|
||||
|
||||
|
@ -160,12 +166,12 @@ module Rails
|
|||
end
|
||||
|
||||
# If Rails is vendored and RubyGems is available, install stub GemSpecs
|
||||
# for Rails, ActiveSupport, ActiveRecord, ActionPack, ActionMailer, and
|
||||
# ActiveResource. This allows Gem plugins to depend on Rails even when
|
||||
# for Rails, Active Support, Active Record, Action Pack, Action Mailer, and
|
||||
# Active Resource. This allows Gem plugins to depend on Rails even when
|
||||
# the Gem version of Rails shouldn't be loaded.
|
||||
def install_gem_spec_stubs
|
||||
unless Rails.respond_to?(:vendor_rails?)
|
||||
abort "Your config/boot.rb is outdated: Run 'rake rails:update'."
|
||||
abort %{Your config/boot.rb is outdated: Run "rake rails:update".}
|
||||
end
|
||||
|
||||
if Rails.vendor_rails?
|
||||
|
@ -210,8 +216,8 @@ module Rails
|
|||
end
|
||||
|
||||
# Requires all frameworks specified by the Configuration#frameworks
|
||||
# list. By default, all frameworks (ActiveRecord, ActiveSupport,
|
||||
# ActionPack, ActionMailer, and ActiveResource) are loaded.
|
||||
# list. By default, all frameworks (Active Record, Active Support,
|
||||
# Action Pack, Action Mailer, and Active Resource) are loaded.
|
||||
def require_frameworks
|
||||
configuration.frameworks.each { |framework| require(framework.to_s) }
|
||||
rescue LoadError => e
|
||||
|
@ -237,7 +243,24 @@ module Rails
|
|||
end
|
||||
|
||||
def load_gems
|
||||
@configuration.gems.each &:load
|
||||
@configuration.gems.each(&:load)
|
||||
end
|
||||
|
||||
def check_gem_dependencies
|
||||
unloaded_gems = @configuration.gems.reject { |g| g.loaded? }
|
||||
if unloaded_gems.size > 0
|
||||
@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.}
|
||||
end
|
||||
else
|
||||
@gems_dependencies_loaded = true
|
||||
end
|
||||
end
|
||||
|
||||
# Loads all plugins in <tt>config.plugin_paths</tt>. <tt>plugin_paths</tt>
|
||||
|
@ -283,12 +306,8 @@ module Rails
|
|||
end
|
||||
|
||||
def load_observers
|
||||
if configuration.frameworks.include?(:active_record)
|
||||
if @configuration.gems.any? { |g| !g.loaded? }
|
||||
puts "Unable to instantiate observers, some gems that this application depends on are missing. Run 'rake gems:install'"
|
||||
else
|
||||
ActiveRecord::Base.instantiate_observers
|
||||
end
|
||||
if @gems_dependencies_loaded && configuration.frameworks.include?(:active_record)
|
||||
ActiveRecord::Base.instantiate_observers
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -326,7 +345,7 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
# If the +RAILS_DEFAULT_LOGGER+ constant is already set, this initialization
|
||||
# If the RAILS_DEFAULT_LOGGER constant is already set, this initialization
|
||||
# routine does nothing. If the constant is not set, and Configuration#logger
|
||||
# is not +nil+, this also does nothing. Otherwise, a new logger instance
|
||||
# is created at Configuration#log_path, with a default log level of
|
||||
|
@ -359,10 +378,10 @@ module Rails
|
|||
silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger }
|
||||
end
|
||||
|
||||
# Sets the logger for ActiveRecord, ActionController, and ActionMailer
|
||||
# Sets the logger for Active Record, Action Controller, and Action Mailer
|
||||
# (but only for those frameworks that are to be loaded). If the framework's
|
||||
# logger is already set, it is not changed, otherwise it is set to use
|
||||
# +RAILS_DEFAULT_LOGGER+.
|
||||
# RAILS_DEFAULT_LOGGER.
|
||||
def initialize_framework_logging
|
||||
for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks)
|
||||
framework.to_s.camelize.constantize.const_get("Base").logger ||= RAILS_DEFAULT_LOGGER
|
||||
|
@ -380,7 +399,7 @@ module Rails
|
|||
ActionController::Base.view_paths = [configuration.view_path] if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty?
|
||||
end
|
||||
|
||||
# If ActionController is not one of the loaded frameworks (Configuration#frameworks)
|
||||
# If Action Controller is not one of the loaded frameworks (Configuration#frameworks)
|
||||
# this does nothing. Otherwise, it loads the routing definitions and sets up
|
||||
# loading module used to lazily load controllers (Configuration#controller_paths).
|
||||
def initialize_routing
|
||||
|
@ -409,13 +428,13 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
# Sets the default value for Time.zone, and turns on ActiveRecord time_zone_aware_attributes.
|
||||
# Sets the default value for Time.zone, and turns on ActiveRecord::Base#time_zone_aware_attributes.
|
||||
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
|
||||
def initialize_time_zone
|
||||
if configuration.time_zone
|
||||
zone_default = Time.send!(:get_zone, configuration.time_zone)
|
||||
unless zone_default
|
||||
raise "Value assigned to config.time_zone not recognized. Run `rake -D time` for a list of tasks for finding appropriate time zone names."
|
||||
raise %{Value assigned to config.time_zone not recognized. Run "rake -D time" for a list of tasks for finding appropriate time zone names.}
|
||||
end
|
||||
Time.zone_default = zone_default
|
||||
if configuration.frameworks.include?(:active_record)
|
||||
|
@ -443,14 +462,18 @@ module Rails
|
|||
|
||||
# Fires the user-supplied after_initialize block (Configuration#after_initialize)
|
||||
def after_initialize
|
||||
configuration.after_initialize_blocks.each do |block|
|
||||
block.call
|
||||
if @gems_dependencies_loaded
|
||||
configuration.after_initialize_blocks.each do |block|
|
||||
block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_application_initializers
|
||||
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
|
||||
load(initializer)
|
||||
if @gems_dependencies_loaded
|
||||
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
|
||||
load(initializer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -475,22 +498,22 @@ module Rails
|
|||
# The application's base directory.
|
||||
attr_reader :root_path
|
||||
|
||||
# A stub for setting options on ActionController::Base
|
||||
# A stub for setting options on ActionController::Base.
|
||||
attr_accessor :action_controller
|
||||
|
||||
# A stub for setting options on ActionMailer::Base
|
||||
# A stub for setting options on ActionMailer::Base.
|
||||
attr_accessor :action_mailer
|
||||
|
||||
# A stub for setting options on ActionView::Base
|
||||
# A stub for setting options on ActionView::Base.
|
||||
attr_accessor :action_view
|
||||
|
||||
# A stub for setting options on ActiveRecord::Base
|
||||
# A stub for setting options on ActiveRecord::Base.
|
||||
attr_accessor :active_record
|
||||
|
||||
# A stub for setting options on ActiveRecord::Base
|
||||
# A stub for setting options on ActiveRecord::Base.
|
||||
attr_accessor :active_resource
|
||||
|
||||
# A stub for setting options on ActiveSupport
|
||||
# A stub for setting options on ActiveSupport.
|
||||
attr_accessor :active_support
|
||||
|
||||
# Whether or not classes should be cached (set to false if you want
|
||||
|
@ -618,9 +641,9 @@ module Rails
|
|||
end
|
||||
alias_method :breakpoint_server=, :breakpoint_server
|
||||
|
||||
# Sets the default time_zone. Setting this will enable time_zone
|
||||
# awareness for ActiveRecord models and set the ActiveRecord default
|
||||
# timezone to :utc.
|
||||
# Sets the default +time_zone+. Setting this will enable +time_zone+
|
||||
# awareness for Active Record models and set the Active Record default
|
||||
# timezone to <tt>:utc</tt>.
|
||||
attr_accessor :time_zone
|
||||
|
||||
# Create a new Configuration instance, initialized with the default
|
||||
|
@ -685,7 +708,7 @@ module Rails
|
|||
end
|
||||
|
||||
# Return the currently selected environment. By default, it returns the
|
||||
# value of the +RAILS_ENV+ constant.
|
||||
# value of the RAILS_ENV constant.
|
||||
def environment
|
||||
::RAILS_ENV
|
||||
end
|
||||
|
@ -843,7 +866,7 @@ end
|
|||
|
||||
# Needs to be duplicated from Active Support since its needed before Active
|
||||
# Support is available. Here both Options and Hash are namespaced to prevent
|
||||
# conflicts with other implementations AND with the classes residing in ActiveSupport.
|
||||
# conflicts with other implementations AND with the classes residing in Active Support.
|
||||
class Rails::OrderedOptions < Array #:nodoc:
|
||||
def []=(key, value)
|
||||
key = key.to_sym
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue