aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/commands/destroy.rb1
-rwxr-xr-xrailties/lib/rails/commands/generate.rb1
-rw-r--r--railties/lib/rails/configuration.rb20
-rw-r--r--railties/lib/rails/generators.rb3
-rw-r--r--railties/lib/rails/initializable.rb29
-rw-r--r--railties/lib/rails/plugin.rb2
-rw-r--r--railties/lib/rails/test_unit/railtie.rb4
-rw-r--r--railties/lib/rails/test_unit/testing.rake (renamed from railties/lib/rails/tasks/testing.rake)0
8 files changed, 28 insertions, 32 deletions
diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb
index a2eff377ce..92a06ebdd8 100644
--- a/railties/lib/rails/commands/destroy.rb
+++ b/railties/lib/rails/commands/destroy.rb
@@ -1,5 +1,4 @@
require 'rails/generators'
-Rails::Generators.configure!
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb
index c1120aad74..5e45d8ab46 100755
--- a/railties/lib/rails/commands/generate.rb
+++ b/railties/lib/rails/commands/generate.rb
@@ -1,5 +1,4 @@
require 'rails/generators'
-Rails::Generators.configure!
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index a95075562f..6a4ebe883b 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -128,61 +128,61 @@ module Rails
def view_path=(value)
ActiveSupport::Deprecation.warn "config.view_path= is deprecated, " <<
- "please do config.paths.app.views= instead", caller
+ "please do paths.app.views= instead", caller
paths.app.views = value
end
def view_path
ActiveSupport::Deprecation.warn "config.view_path is deprecated, " <<
- "please do config.paths.app.views instead", caller
+ "please do paths.app.views instead", caller
paths.app.views.to_a.first
end
def routes_configuration_file=(value)
ActiveSupport::Deprecation.warn "config.routes_configuration_file= is deprecated, " <<
- "please do config.paths.config.routes= instead", caller
+ "please do paths.config.routes= instead", caller
paths.config.routes = value
end
def routes_configuration_file
ActiveSupport::Deprecation.warn "config.routes_configuration_file is deprecated, " <<
- "please do config.paths.config.routes instead", caller
+ "please do paths.config.routes instead", caller
paths.config.routes.to_a.first
end
def database_configuration_file=(value)
ActiveSupport::Deprecation.warn "config.database_configuration_file= is deprecated, " <<
- "please do config.paths.config.database= instead", caller
+ "please do paths.config.database= instead", caller
paths.config.database = value
end
def database_configuration_file
ActiveSupport::Deprecation.warn "config.database_configuration_file is deprecated, " <<
- "please do config.paths.config.database instead", caller
+ "please do paths.config.database instead", caller
paths.config.database.to_a.first
end
def log_path=(value)
ActiveSupport::Deprecation.warn "config.log_path= is deprecated, " <<
- "please do config.paths.log= instead", caller
+ "please do paths.log= instead", caller
paths.config.log = value
end
def log_path
ActiveSupport::Deprecation.warn "config.log_path is deprecated, " <<
- "please do config.paths.log instead", caller
+ "please do paths.log instead", caller
paths.config.log.to_a.first
end
def controller_paths=(value)
ActiveSupport::Deprecation.warn "config.controller_paths= is deprecated, " <<
- "please do config.paths.app.controllers= instead", caller
+ "please do paths.app.controllers= instead", caller
paths.app.controllers = value
end
def controller_paths
ActiveSupport::Deprecation.warn "config.controller_paths is deprecated, " <<
- "please do config.paths.app.controllers instead", caller
+ "please do paths.app.controllers instead", caller
paths.app.controllers.to_a.uniq
end
end
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 1271de7af9..90b513fcb4 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -286,3 +286,6 @@ module Rails
end
end
+# If the application was already defined, configure generators,
+# otherwise you have to configure it by hand.
+Rails::Generators.configure! if Rails.respond_to?(:application) && Rails.application \ No newline at end of file
diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb
index d91f67823f..9a82e051e7 100644
--- a/railties/lib/rails/initializable.rb
+++ b/railties/lib/rails/initializable.rb
@@ -1,3 +1,5 @@
+require 'tsort'
+
module Rails
module Initializable
def self.included(base)
@@ -30,29 +32,21 @@ module Rails
end
class Collection < Array
+ include TSort
+
+ alias :tsort_each_node :each
+ def tsort_each_child(initializer, &block)
+ select { |i| i.before == initializer.name || i.name == initializer.after }.each(&block)
+ end
+
def initialize(initializers = [])
- super()
- initializers.each do |initializer|
- if initializer.before
- index = index_for(initializer.before)
- elsif initializer.after
- index = index_for(initializer.after)
- index += 1 if index
- else
- index = length
- end
- insert(index || -1, initializer)
- end
+ super(initializers)
+ replace(tsort)
end
def +(other)
Collection.new(to_a + other.to_a)
end
-
- def index_for(name)
- initializer = find { |i| i.name == name }
- initializer && index(initializer)
- end
end
def run_initializers(*args)
@@ -87,6 +81,7 @@ module Rails
def initializer(name, opts = {}, &blk)
raise ArgumentError, "A block must be passed when defining an initializer" unless blk
+ opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
initializers << Initializer.new(name, nil, opts, &blk)
end
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index 881c97f02d..64d03e7599 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -43,7 +43,7 @@ module Rails
@config ||= Engine::Configuration.new
end
- initializer :load_init_rb do |app|
+ initializer :load_init_rb, :before => :load_application_initializers do |app|
file = Dir["#{root}/{rails/init,init}.rb"].first
config = app.config
eval(File.read(file), binding, file) if file && File.file?(file)
diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb
index f93dace9bb..21b9dbc074 100644
--- a/railties/lib/rails/test_unit/railtie.rb
+++ b/railties/lib/rails/test_unit/railtie.rb
@@ -11,7 +11,7 @@ module Rails
end
rake_tasks do
- load "rails/tasks/testing.rake"
- end
+ load "rails/test_unit/testing.rake"
+ end
end
end \ No newline at end of file
diff --git a/railties/lib/rails/tasks/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 57857fb911..57857fb911 100644
--- a/railties/lib/rails/tasks/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake