From 2699e9c2ddff13c5e19e1c95e838fa6d9a965c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 8 Jul 2009 10:57:56 +0200 Subject: Added config.generators with tests. --- railties/lib/rails/configuration.rb | 49 ++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 1a2f217d20..4a5fe4da7d 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -249,5 +249,52 @@ module Rails def reload_plugins? @reload_plugins end + + # Holds generators configuration: + # + # config.generators.orm :datamapper + # config.generators.test_framework :rspec + # config.generators.template_engine :haml + # + # A block can also be given for less verbose configuration: + # + # config.generators do |g| + # g.orm :datamapper + # g.test_framework :datamapper + # g.template_engine :haml + # end + # + # You can also configure/override aliases: + # + # config.generators.aliases :test_framework => "-w" + # + def generators + @generators ||= Generators.new + if block_given? + yield @generators + else + @generators + end + end + + class Generators #:nodoc: + def initialize + @aliases, @options = {}, {} + end + + def aliases(values=nil) + @aliases = values if values + @aliases + end + + def options(values=nil) + @options = values if values + @options + end + + def method_missing(method, *args, &block) + @options[method.to_sym] = args.first + end + end end -end \ No newline at end of file +end -- cgit v1.2.3