Add the new generators environment and update commands.

This commit is contained in:
José Valim 2009-07-08 12:55:50 +02:00
parent c9ea21717e
commit 09c288f0c5
14 changed files with 40 additions and 21 deletions

View File

@ -1,5 +1,5 @@
RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
require 'generators'
if ARGV.size == 0
Rails::Generators.help

View File

@ -1,5 +1,5 @@
RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
require 'generators'
if ARGV.size == 0
Rails::Generators.help

View File

@ -1,5 +1,5 @@
RAILS_ENV.replace "generators"
require "#{RAILS_ROOT}/config/environment"
require 'generators'
if ARGV.size == 0
Rails::Generators.help

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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