aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-07-08 12:55:50 +0200
committerJosé Valim <jose.valim@gmail.com>2009-07-08 12:55:50 +0200
commit09c288f0c5b5f9da4473bb321cccb766d9f59d7e (patch)
treed12cb86acdbe32ca2c6c9971ff9921360a02b1ef
parentc9ea21717eefb9e9b49891c519cc4d121ef7bb74 (diff)
downloadrails-09c288f0c5b5f9da4473bb321cccb766d9f59d7e.tar.gz
rails-09c288f0c5b5f9da4473bb321cccb766d9f59d7e.tar.bz2
rails-09c288f0c5b5f9da4473bb321cccb766d9f59d7e.zip
Add the new generators environment and update commands.
-rw-r--r--railties/lib/commands/destroy.rb2
-rwxr-xr-xrailties/lib/commands/generate.rb2
-rw-r--r--railties/lib/commands/update.rb2
-rw-r--r--railties/lib/generators.rb10
-rw-r--r--railties/lib/generators/base.rb2
-rw-r--r--railties/lib/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/generators/rails/app/templates/config/environments/generators.rb19
-rw-r--r--railties/lib/initializer.rb2
-rw-r--r--railties/test/generators/helper_generator_test.rb4
-rw-r--r--railties/test/generators/mailer_generator_test.rb4
-rw-r--r--railties/test/generators/model_generator_test.rb2
-rw-r--r--railties/test/generators/observer_generator_test.rb4
-rw-r--r--railties/test/generators/plugin_generator_test.rb4
-rw-r--r--railties/test/initializer_test.rb2
14 files changed, 40 insertions, 21 deletions
diff --git a/railties/lib/commands/destroy.rb b/railties/lib/commands/destroy.rb
index 075fe5bb12..6e740bb754 100644
--- a/railties/lib/commands/destroy.rb
+++ b/railties/lib/commands/destroy.rb
@@ -1,5 +1,5 @@
+RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
-require 'generators'
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/commands/generate.rb b/railties/lib/commands/generate.rb
index f6db965960..5408e78157 100755
--- a/railties/lib/commands/generate.rb
+++ b/railties/lib/commands/generate.rb
@@ -1,5 +1,5 @@
+RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
-require 'generators'
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/commands/update.rb b/railties/lib/commands/update.rb
index 50b7d73e0e..5ce1068e1a 100644
--- a/railties/lib/commands/update.rb
+++ b/railties/lib/commands/update.rb
@@ -1,5 +1,5 @@
+RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
-require 'generators'
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb
index a4ce92e04b..8fe5dabf86 100644
--- a/railties/lib/generators.rb
+++ b/railties/lib/generators.rb
@@ -38,13 +38,13 @@ module Rails
:helper => true,
:layout => true,
:migration => true,
- :orm => 'active_record',
- :resource_controller => 'controller',
- :scaffold_controller => 'scaffold_controller',
+ :orm => :active_record,
+ :resource_controller => :controller,
+ :scaffold_controller => :scaffold_controller,
:singleton => false,
:stylesheets => true,
- :test_framework => 'test_unit',
- :template_engine => 'erb',
+ :test_framework => :test_unit,
+ :template_engine => :erb,
:timestamps => true
}
diff --git a/railties/lib/generators/base.rb b/railties/lib/generators/base.rb
index dcc210240e..13916e081b 100644
--- a/railties/lib/generators/base.rb
+++ b/railties/lib/generators/base.rb
@@ -163,7 +163,7 @@ module Rails
end
shell.padding -= 1
else
- say "Could not find and invoke '\#{klass_name}'."
+ say_status :error, "\#{klass_name} [not found]", :red
end
end
METHOD
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb
index dc1d360e3f..20a06ed16a 100644
--- a/railties/lib/generators/rails/app/app_generator.rb
+++ b/railties/lib/generators/rails/app/app_generator.rb
@@ -1,6 +1,6 @@
require 'digest/md5'
require 'active_support/secure_random'
-require 'rails/version' unless defined?(RAILS::VERSION)
+require 'rails/version' unless defined?(Rails::VERSION)
module Rails::Generators
class AppGenerator < Base
diff --git a/railties/lib/generators/rails/app/templates/config/environments/generators.rb b/railties/lib/generators/rails/app/templates/config/environments/generators.rb
new file mode 100644
index 0000000000..503a281e20
--- /dev/null
+++ b/railties/lib/generators/rails/app/templates/config/environments/generators.rb
@@ -0,0 +1,19 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# Cache classes and log when you accidentally call methods on nil.
+config.cache_classes = false
+config.whiny_nils = true
+
+# We do not need any framework on generators. They are loaded on demand.
+config.frameworks.clear
+
+# Configure generators. Below you have the 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 fa7d2d5249..be65950a5b 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -572,7 +572,7 @@ Run `rake gems:install` to install the missing gems.
# Load generators if RAILS_ENV == "generators"
Initializer.default.add :initialize_generators do
if RAILS_ENV == "generators"
- require 'generators'
+ require "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/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb
index 3b240a96c5..02148ee1ce 100644
--- a/railties/test/generators/helper_generator_test.rb
+++ b/railties/test/generators/helper_generator_test.rb
@@ -18,8 +18,8 @@ class HelperGeneratorTest < GeneratorsTestCase
end
def test_logs_if_the_test_framework_cannot_be_found
- content = run_generator ["admin", "--test-framework=unknown"]
- assert_match /Could not find and invoke 'unknown'/, content
+ content = run_generator ["admin", "--test-framework=rspec"]
+ assert_match /rspec \[not found\]/, content
end
def test_check_class_collision
diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb
index 8532667d15..d3bb1cd13f 100644
--- a/railties/test/generators/mailer_generator_test.rb
+++ b/railties/test/generators/mailer_generator_test.rb
@@ -33,8 +33,8 @@ class MailerGeneratorTest < GeneratorsTestCase
end
def test_logs_if_the_template_engine_cannot_be_found
- content = run_generator ["notifier", "foo", "bar", "--template-engine=unknown"]
- assert_match /Could not find and invoke 'unknown'/, content
+ content = run_generator ["notifier", "foo", "bar", "--template-engine=haml"]
+ assert_match /haml \[not found\]/, content
end
def test_actions_are_turned_into_methods
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb
index 30fc837834..62e1c5ab9e 100644
--- a/railties/test/generators/model_generator_test.rb
+++ b/railties/test/generators/model_generator_test.rb
@@ -108,7 +108,7 @@ class ModelGeneratorTest < GeneratorsTestCase
def test_fixture_is_skipped_if_fixture_replacement_is_given
content = run_generator ["account", "-r", "factory_girl"]
- assert_match /Could not find and invoke 'factory_girl'/, content
+ assert_match /factory_girl \[not found\]/, content
assert_no_file "test/fixtures/accounts.yml"
end
diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb
index d97486d957..65e18eb942 100644
--- a/railties/test/generators/observer_generator_test.rb
+++ b/railties/test/generators/observer_generator_test.rb
@@ -20,8 +20,8 @@ class ObserverGeneratorTest < GeneratorsTestCase
end
def test_logs_if_the_test_framework_cannot_be_found
- content = run_generator ["account", "--test-framework=unknown"]
- assert_match /Could not find and invoke 'unknown'/, content
+ content = run_generator ["account", "--test-framework=rspec"]
+ assert_match /rspec \[not found\]/, content
end
protected
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index 2b41f85a2d..bfec671d31 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -26,8 +26,8 @@ class PluginGeneratorTest < GeneratorsTestCase
end
def test_logs_if_the_test_framework_cannot_be_found
- content = run_generator ["plugin_fu", "--test-framework=unknown"]
- assert_match /Could not find and invoke 'unknown'/, content
+ content = run_generator ["plugin_fu", "--test-framework=rspec"]
+ assert_match /rspec \[not found\]/, content
end
def test_creates_tasks_if_required
diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb
index 0a423b4da2..240bf31ab0 100644
--- a/railties/test/initializer_test.rb
+++ b/railties/test/initializer_test.rb
@@ -352,7 +352,7 @@ class InitializerGeneratorsTests < Test::Unit::TestCase
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]
+ assert_equal :test_unit, Rails::Generators.options[:test_framework]
end
protected