From f68e7a3987adf2cffe0e48263d117839c2028185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@gmail.com> Date: Mon, 13 Jul 2009 18:18:08 +0200 Subject: Remove generator environment until we have a gem manifest. --- railties/lib/commands/destroy.rb | 2 +- railties/lib/commands/generate.rb | 2 +- railties/lib/commands/update.rb | 2 +- .../rails/app/templates/config/environment.rb | 19 +++++++++++++++++++ .../app/templates/config/environments/generators.rb | 18 ------------------ railties/lib/initializer.rb | 5 ++--- railties/test/initializer_test.rb | 8 -------- 7 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 railties/lib/generators/rails/app/templates/config/environments/generators.rb (limited to 'railties') diff --git a/railties/lib/commands/destroy.rb b/railties/lib/commands/destroy.rb index 6e740bb754..5013d30b83 100644 --- a/railties/lib/commands/destroy.rb +++ b/railties/lib/commands/destroy.rb @@ -1,4 +1,4 @@ -RAILS_ENV.replace "generators" +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require "#{RAILS_ROOT}/config/environment" if ARGV.size == 0 diff --git a/railties/lib/commands/generate.rb b/railties/lib/commands/generate.rb index 5408e78157..32cabcab10 100755 --- a/railties/lib/commands/generate.rb +++ b/railties/lib/commands/generate.rb @@ -1,4 +1,4 @@ -RAILS_ENV.replace "generators" +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require "#{RAILS_ROOT}/config/environment" if ARGV.size == 0 diff --git a/railties/lib/commands/update.rb b/railties/lib/commands/update.rb index 5ce1068e1a..f3b3ad0775 100644 --- a/railties/lib/commands/update.rb +++ b/railties/lib/commands/update.rb @@ -1,4 +1,4 @@ -RAILS_ENV.replace "generators" +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require "#{RAILS_ROOT}/config/environment" if ARGV.size == 0 diff --git a/railties/lib/generators/rails/app/templates/config/environment.rb b/railties/lib/generators/rails/app/templates/config/environment.rb index 84c5abf1e9..02fbb57b87 100644 --- a/railties/lib/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/generators/rails/app/templates/config/environment.rb @@ -42,4 +42,23 @@ Rails::Initializer.run do |config| # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] # config.i18n.default_locale = :de + + # Configure generators default options. + config.generators do |g| + # Scaffold configuration + g.helper = true + g.layout = true + g.stylesheets = true + + # ORM configuration + g.orm = :active_record + g.timestamps = true + + # Template engine configuration + g.template_engine = :erb + + # Test framework configuration + g.test_framework = :test_unit + g.fixtures = true + end end diff --git a/railties/lib/generators/rails/app/templates/config/environments/generators.rb b/railties/lib/generators/rails/app/templates/config/environments/generators.rb deleted file mode 100644 index 1b426f5a05..0000000000 --- a/railties/lib/generators/rails/app/templates/config/environments/generators.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# No need to reload in generators environment, so do cache classes. -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Configure generators options (below are default values, delete them if you want). -config.generators do |g| - g.helper = true - g.layout = true - g.orm = :active_record - g.stylesheets = true - g.template_engine = :erb - g.test_framework = :test_unit - g.timestamps = true -end diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index be65950a5b..d0ef9d0c2f 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -569,10 +569,9 @@ Run `rake gems:install` to install the missing gems. end end - # Load generators if RAILS_ENV == "generators" + # Configure generators if they were already loaded Initializer.default.add :initialize_generators do - if RAILS_ENV == "generators" - require "generators" + if defined?(Rails::Generators) Rails::Generators.no_color! unless config.generators.colorize_logging Rails::Generators.aliases.merge! config.generators.aliases Rails::Generators.options.merge! config.generators.options diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index 240bf31ab0..163785fee3 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -293,7 +293,6 @@ end class InitializerGeneratorsTests < Test::Unit::TestCase def setup - @old_env_value = RAILS_ENV.dup @configuration = Rails::Configuration.new @initializer = Rails::Initializer.default @initializer.config = @configuration @@ -349,16 +348,9 @@ class InitializerGeneratorsTests < Test::Unit::TestCase end end - def test_generators_are_not_invoked_with_other_environments - @configuration.generators.test_framework = :rspec - @initializer.run(:initialize_generators) - assert_equal :test_unit, Rails::Generators.options[:test_framework] - end - protected def teardown - RAILS_ENV.replace @old_env_value Rails::Generators.clear_aliases! Rails::Generators.clear_options! end -- cgit v1.2.3