From dd665ff9679514e354336bb183a9b40ad17145fb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 13 Mar 2008 02:47:26 +0000 Subject: Fixed that script/generate would not look for plugin generators in plugin_paths (closes #11000) [glv] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9017 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/initializer.rb | 11 +++++++++++ railties/lib/rails_generator/lookup.rb | 8 ++++++-- railties/lib/rails_generator/scripts.rb | 11 +++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 01acc50763..32e6c5251b 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -12,6 +12,15 @@ require 'rails/plugin/loader' RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) module Rails + # The Configuration instance used to configure the Rails environment + def self.configuration + @@configuration + end + + def self.configuration=(configuration) + @@configuration = configuration + end + # The Initializer is responsible for processing the Rails configuration, such # as setting the $LOAD_PATH, requiring the right frameworks, initializing # logging, and more. It can be run either as a single command that'll just @@ -60,6 +69,8 @@ module Rails # Sequentially step through all of the available initialization routines, # in order (view execution order in source). def process + Rails.configuration = configuration + check_ruby_version set_load_path diff --git a/railties/lib/rails_generator/lookup.rb b/railties/lib/rails_generator/lookup.rb index d88a1948a4..1f28c39d55 100644 --- a/railties/lib/rails_generator/lookup.rb +++ b/railties/lib/rails_generator/lookup.rb @@ -1,3 +1,5 @@ +require 'pathname' + require File.dirname(__FILE__) + '/spec' class Object @@ -104,8 +106,10 @@ module Rails if defined? ::RAILS_ROOT sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators") sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators") - sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators") - sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/rails_generators") + Rails.configuration.plugin_paths.each do |path| + relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT)) + sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/**/{,rails_}generators") + end end sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators") if Object.const_defined?(:Gem) diff --git a/railties/lib/rails_generator/scripts.rb b/railties/lib/rails_generator/scripts.rb index 75167da995..f857f68de4 100644 --- a/railties/lib/rails_generator/scripts.rb +++ b/railties/lib/rails_generator/scripts.rb @@ -43,12 +43,15 @@ module Rails def usage_message usage = "\nInstalled Generators\n" - Rails::Generator::Base.sources.inject({}) do |mem, source| + Rails::Generator::Base.sources.inject([]) do |mem, source| + # Using an association list instead of a hash to preserve order, + # for esthetic reasons more than anything else. label = source.label.to_s.capitalize - mem[label] ||= [] - mem[label] |= source.names + pair = mem.assoc(label) + mem << (pair = [label, []]) if pair.nil? + pair[1] |= source.names mem - end.each_pair do |label, names| + end.each do |label, names| usage << " #{label}: #{names.join(', ')}\n" unless names.empty? end -- cgit v1.2.3