aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-05-05 06:19:42 +0200
committerwycats <wycats@gmail.com>2010-05-05 10:12:33 +0200
commit743d77f405a16cd1cf1d4bbccd6b512463e10a43 (patch)
tree9a52c5b55e9c968d47e18cd922b222112eb56e32 /railties/lib/rails/generators.rb
parentf2072a323cdaa531bdc7a5e488b4e5853c8d6b8d (diff)
downloadrails-743d77f405a16cd1cf1d4bbccd6b512463e10a43.tar.gz
rails-743d77f405a16cd1cf1d4bbccd6b512463e10a43.tar.bz2
rails-743d77f405a16cd1cf1d4bbccd6b512463e10a43.zip
Update hidden namespace mechanism to work better with alternate choices and to support full namespaces (not just entire groups)
Diffstat (limited to 'railties/lib/rails/generators.rb')
-rw-r--r--railties/lib/rails/generators.rb46
1 files changed, 42 insertions, 4 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 9bc019b152..fe8a6c0b94 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -166,6 +166,38 @@ module Rails
end
end
+ def self.hidden_namespaces
+ @hidden_namespaces ||= begin
+ orm = options[:rails][:orm]
+ test = options[:rails][:test_framework]
+ template = options[:rails][:template_engine]
+
+ [
+ "rails",
+ "#{orm}:migration",
+ "#{orm}:model",
+ "#{orm}:observer",
+ "#{test}:controller",
+ "#{test}:helper",
+ "#{test}:integration",
+ "#{test}:mailer",
+ "#{test}:model",
+ "#{test}:observer",
+ "#{test}:scaffold",
+ "#{test}:view",
+ "#{template}:controller",
+ "#{template}:scaffold"
+ ]
+ end
+ end
+
+ class << self
+ def hide_namespaces(*namespaces)
+ hidden_namespaces.concat(namespaces)
+ end
+ alias hide_namespace hide_namespaces
+ end
+
# Show help message with available generators.
def self.help(command = 'generate')
lookup!
@@ -197,9 +229,7 @@ module Rails
rails.delete("app")
print_list("rails", rails)
- groups.delete("active_record") if options[:rails][:orm] == :active_record
- groups.delete("test_unit") if options[:rails][:test_framework] == :test_unit
- groups.delete("erb") if options[:rails][:template_engine] == :erb
+ hidden_namespaces.each {|n| groups.delete(n.to_s) }
groups.sort.each { |b, n| print_list(b, n) }
end
@@ -208,9 +238,17 @@ module Rails
# Prints a list of generators.
def self.print_list(base, namespaces) #:nodoc:
+ namespaces = namespaces.reject do |n|
+ hidden_namespaces.include?(n)
+ end
+
return if namespaces.empty?
puts "#{base.camelize}:"
- namespaces.each { |namespace| puts(" #{namespace}") }
+
+ namespaces.each do |namespace|
+ puts(" #{namespace}")
+ end
+
puts
end