mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Added Rails.initialized? flag
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*Edge*
|
||||
|
||||
* Added Rails.initialized? flag [Josh Peek]
|
||||
|
||||
* Make rake test:uncommitted work with Git. [Tim Pope]
|
||||
|
||||
* Added Thin support to script/server. #488 [Bob Klosinski]
|
||||
|
||||
@@ -19,15 +19,23 @@ module Rails
|
||||
def configuration
|
||||
@@configuration
|
||||
end
|
||||
|
||||
|
||||
def configuration=(configuration)
|
||||
@@configuration = configuration
|
||||
end
|
||||
|
||||
|
||||
def initialized?
|
||||
@initialized || false
|
||||
end
|
||||
|
||||
def initialized=(initialized)
|
||||
@initialized ||= initialized
|
||||
end
|
||||
|
||||
def logger
|
||||
RAILS_DEFAULT_LOGGER
|
||||
end
|
||||
|
||||
|
||||
def root
|
||||
if defined?(RAILS_ROOT)
|
||||
RAILS_ROOT
|
||||
@@ -35,11 +43,11 @@ module Rails
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def env
|
||||
ActiveSupport::StringInquirer.new(RAILS_ENV)
|
||||
end
|
||||
|
||||
|
||||
def cache
|
||||
RAILS_CACHE
|
||||
end
|
||||
@@ -56,7 +64,7 @@ module Rails
|
||||
@@public_path = path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# The Initializer is responsible for processing the Rails configuration, such
|
||||
# as setting the $LOAD_PATH, requiring the right frameworks, initializing
|
||||
# logging, and more. It can be run either as a single command that'll just
|
||||
@@ -145,7 +153,7 @@ module Rails
|
||||
add_gem_load_paths
|
||||
load_gems
|
||||
check_gem_dependencies
|
||||
|
||||
|
||||
load_application_initializers
|
||||
|
||||
# the framework is now fully initialized
|
||||
@@ -158,8 +166,10 @@ module Rails
|
||||
initialize_routing
|
||||
|
||||
# Observers are loaded after plugins in case Observers or observed models are modified by plugins.
|
||||
|
||||
load_observers
|
||||
|
||||
# Flag initialized
|
||||
Rails.initialized = true
|
||||
end
|
||||
|
||||
# Check for valid Ruby version
|
||||
@@ -297,12 +307,12 @@ module Rails
|
||||
silence_warnings do
|
||||
return if @environment_loaded
|
||||
@environment_loaded = true
|
||||
|
||||
|
||||
config = configuration
|
||||
constants = self.class.constants
|
||||
|
||||
|
||||
eval(IO.read(configuration.environment_path), binding, configuration.environment_path)
|
||||
|
||||
|
||||
(self.class.constants - constants).each do |const|
|
||||
Object.const_set(const, self.class.const_get(const))
|
||||
end
|
||||
@@ -390,7 +400,7 @@ module Rails
|
||||
for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks)
|
||||
framework.to_s.camelize.constantize.const_get("Base").logger ||= RAILS_DEFAULT_LOGGER
|
||||
end
|
||||
|
||||
|
||||
RAILS_CACHE.logger ||= RAILS_DEFAULT_LOGGER
|
||||
end
|
||||
|
||||
@@ -486,7 +496,6 @@ module Rails
|
||||
Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
|
||||
Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# The Configuration class holds all the parameters for the Initializer and
|
||||
@@ -531,7 +540,7 @@ module Rails
|
||||
# The path to the database configuration file to use. (Defaults to
|
||||
# <tt>config/database.yml</tt>.)
|
||||
attr_accessor :database_configuration_file
|
||||
|
||||
|
||||
# The path to the routes configuration file to use. (Defaults to
|
||||
# <tt>config/routes.rb</tt>.)
|
||||
attr_accessor :routes_configuration_file
|
||||
@@ -597,7 +606,7 @@ module Rails
|
||||
# a sub class would have access to fine grained modification of the loading behavior. See
|
||||
# the implementation of Rails::Plugin::Loader for more details.
|
||||
attr_accessor :plugin_loader
|
||||
|
||||
|
||||
# Enables or disables plugin reloading. You can get around this setting per plugin.
|
||||
# If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
|
||||
# to make it reloadable:
|
||||
@@ -634,7 +643,7 @@ module Rails
|
||||
def gem(name, options = {})
|
||||
@gems << Rails::GemDependency.new(name, options)
|
||||
end
|
||||
|
||||
|
||||
# Deprecated options:
|
||||
def breakpoint_server(_ = nil)
|
||||
$stderr.puts %(
|
||||
@@ -693,7 +702,7 @@ module Rails
|
||||
else
|
||||
Pathname.new(::RAILS_ROOT).realpath.to_s
|
||||
end
|
||||
|
||||
|
||||
Object.const_set(:RELATIVE_RAILS_ROOT, ::RAILS_ROOT.dup) unless defined?(::RELATIVE_RAILS_ROOT)
|
||||
::RAILS_ROOT.replace @root_path
|
||||
end
|
||||
@@ -734,7 +743,7 @@ module Rails
|
||||
#
|
||||
# See Dispatcher#to_prepare.
|
||||
def to_prepare(&callback)
|
||||
after_initialize do
|
||||
after_initialize do
|
||||
require 'dispatcher' unless defined?(::Dispatcher)
|
||||
Dispatcher.to_prepare(&callback)
|
||||
end
|
||||
@@ -748,11 +757,11 @@ module Rails
|
||||
def framework_paths
|
||||
paths = %w(railties railties/lib activesupport/lib)
|
||||
paths << 'actionpack/lib' if frameworks.include? :action_controller or frameworks.include? :action_view
|
||||
|
||||
|
||||
[:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework|
|
||||
paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include? framework
|
||||
end
|
||||
|
||||
|
||||
paths.map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
|
||||
end
|
||||
|
||||
@@ -767,7 +776,7 @@ module Rails
|
||||
|
||||
def default_load_paths
|
||||
paths = []
|
||||
|
||||
|
||||
# Add the old mock paths only if the directories exists
|
||||
paths.concat(Dir["#{root_path}/test/mocks/#{environment}"]) if File.exists?("#{root_path}/test/mocks/#{environment}")
|
||||
|
||||
@@ -853,7 +862,7 @@ module Rails
|
||||
def default_plugin_loader
|
||||
Plugin::Loader
|
||||
end
|
||||
|
||||
|
||||
def default_cache_store
|
||||
if File.exist?("#{root_path}/tmp/cache/")
|
||||
[ :file_store, "#{root_path}/tmp/cache/" ]
|
||||
@@ -861,7 +870,7 @@ module Rails
|
||||
:memory_store
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def default_gems
|
||||
[]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user