aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-11-03 18:58:40 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-11-03 18:58:40 -0800
commita3d5274e67c841a6fdc9f9acb9e1b6bbc351dd28 (patch)
tree78b1ab39446198e36b994215eacb1138438322ba /railties
parentd627c932bdc5c0e2911e39cfb38952c29dab7afc (diff)
downloadrails-a3d5274e67c841a6fdc9f9acb9e1b6bbc351dd28.tar.gz
rails-a3d5274e67c841a6fdc9f9acb9e1b6bbc351dd28.tar.bz2
rails-a3d5274e67c841a6fdc9f9acb9e1b6bbc351dd28.zip
Configure generator when needed rather than during initialization
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application.rb12
-rw-r--r--railties/lib/rails/generators.rb6
-rwxr-xr-xrailties/lib/rails/generators/rails/app/templates/script/destroy.tt3
-rwxr-xr-xrailties/lib/rails/generators/rails/app/templates/script/generate.tt3
-rw-r--r--railties/test/application/generators_test.rb3
5 files changed, 12 insertions, 15 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index ce3ab9147c..242aea1842 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -412,18 +412,6 @@ module Rails
end
end
- # Configure generators if they were already loaded
- # ===
- # TODO: Does this need to be an initializer here?
- initializer :initialize_generators do
- if defined?(RAILS_GENERATORS) && RAILS_GENERATORS
- require 'rails/generators'
- Rails::Generators.no_color! unless config.generators.colorize_logging
- Rails::Generators.aliases.deep_merge! config.generators.aliases
- Rails::Generators.options.deep_merge! config.generators.options
- end
- end
-
# For each framework, search for instrument file with Notifications hooks.
#
initializer :load_notifications_hooks do
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index a6a59f039f..fa2c11795b 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -72,6 +72,12 @@ module Rails
}
}
+ def self.configure!(config = Rails.application.config.generators) #:nodoc:
+ no_color! unless config.colorize_logging
+ aliases.deep_merge! config.aliases
+ options.deep_merge! config.options
+ end
+
def self.aliases #:nodoc:
@aliases ||= DEFAULT_ALIASES.dup
end
diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt
index 62a856d338..6adc90b2c3 100755
--- a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt
+++ b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt
@@ -1,4 +1,5 @@
<%= shebang %>
-RAILS_GENERATORS = true
require File.expand_path('../../config/environment', __FILE__)
+require 'rails/generators'
+Rails::Generators.configure!
require 'rails/commands/destroy'
diff --git a/railties/lib/rails/generators/rails/app/templates/script/generate.tt b/railties/lib/rails/generators/rails/app/templates/script/generate.tt
index a005e77104..71d47dec92 100755
--- a/railties/lib/rails/generators/rails/app/templates/script/generate.tt
+++ b/railties/lib/rails/generators/rails/app/templates/script/generate.tt
@@ -1,4 +1,5 @@
<%= shebang %>
-RAILS_GENERATORS = true
require File.expand_path('../../config/environment', __FILE__)
+require 'rails/generators'
+Rails::Generators.configure!
require 'rails/commands/generate'
diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb
index bfbf1ffd16..ccbcd84176 100644
--- a/railties/test/application/generators_test.rb
+++ b/railties/test/application/generators_test.rb
@@ -1,5 +1,4 @@
require "isolation/abstract_unit"
-RAILS_GENERATORS = true
module ApplicationTests
class GeneratorsTest < Test::Unit::TestCase
@@ -47,6 +46,7 @@ module ApplicationTests
end
# Initialize the application
Rails.initialize!
+ Rails::Generators.configure!
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework]
@@ -59,6 +59,7 @@ module ApplicationTests
end
# Initialize the application
Rails.initialize!
+ Rails::Generators.configure!
assert_equal Thor::Base.shell, Thor::Shell::Basic
end