diff options
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/destroy.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/generate.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/plugin_new.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 12 |
6 files changed, 10 insertions, 22 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 4a79e68c76..21e6f69b92 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -106,13 +106,13 @@ module Rails def load_generators(app=self) initialize_generators railties.all { |r| r.load_generators(app) } - + Rails::Generators.configure!(app.config.generators) super self end def load_console(sandbox=false) - initialize_console(sandbox) + initialize_console railties.all { |r| r.load_console(sandbox) } super() self @@ -197,7 +197,7 @@ module Rails require "rails/generators" end - def initialize_console(sandbox=false) + def initialize_console require "pp" require "rails/console/app" require "rails/console/helpers" diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 4a082aedb8..39627a3094 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -15,6 +15,8 @@ command = aliases[command] || command case command when 'generate', 'destroy', 'plugin' + require 'rails/generators' + if command == 'plugin' && ARGV.first == 'new' require "rails/commands/plugin_new" else @@ -22,7 +24,9 @@ when 'generate', 'destroy', 'plugin' Rails.application.require_environment! if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH) - Rails.application = engine + Rails.application.load_generators(engine) + else + Rails.application.load_generators end require "rails/commands/#{command}" diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 2a84e2a6df..ae354eca97 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,8 +1,6 @@ require 'rails/generators' require 'active_support/core_ext/object/inclusion' -Rails::Generators.configure! - if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'destroy' exit diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 28c1c56352..b6f9a003d1 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,8 +1,6 @@ require 'rails/generators' require 'active_support/core_ext/object/inclusion' -Rails::Generators.configure! - if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'generate' exit diff --git a/railties/lib/rails/commands/plugin_new.rb b/railties/lib/rails/commands/plugin_new.rb index 8baa8ebfd4..20a0334945 100644 --- a/railties/lib/rails/commands/plugin_new.rb +++ b/railties/lib/rails/commands/plugin_new.rb @@ -4,7 +4,5 @@ else ARGV.shift end -require 'rails/generators' require 'rails/generators/rails/plugin_new/plugin_new_generator' - -Rails::Generators::PluginNewGenerator.start +Rails::Generators::PluginNewGenerator.start
\ No newline at end of file diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 02d92f751d..09e505a75b 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -68,7 +68,7 @@ module Rails } } - def self.configure!(config = Rails.application.config.generators) #:nodoc: + def self.configure!(config) #:nodoc: no_color! unless config.colorize_logging aliases.deep_merge! config.aliases options.deep_merge! config.options @@ -286,7 +286,6 @@ module Rails # Receives namespaces in an array and tries to find matching generators # in the load path. def self.lookup(namespaces) #:nodoc: - load_generators_from_railties! paths = namespaces_to_paths(namespaces) paths.each do |raw_path| @@ -310,8 +309,6 @@ module Rails # This will try to load any generator in the load path to show in help. def self.lookup! #:nodoc: - load_generators_from_railties! - $LOAD_PATH.each do |base| Dir[File.join(base, "{rails/generators,generators}", "**", "*_generator.rb")].each do |path| begin @@ -324,13 +321,6 @@ module Rails end end - # Allow generators to be loaded from custom paths. - def self.load_generators_from_railties! #:nodoc: - return if defined?(@generators_from_railties) || Rails.application.nil? - @generators_from_railties = true - Rails.application.load_generators - end - # Convert namespaces to paths by replacing ":" for "/" and adding # an extra lookup. For example, "rails:model" should be searched # in both: "rails/model/model_generator" and "rails/model_generator". |