diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-04 10:32:10 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-04 20:17:31 +0200 |
commit | cd388e075c363d80f9bba050bbc77d7a1a1e0e07 (patch) | |
tree | b3f9cc7c5a5502d7b3f921e7b1d07bb2f58dd273 | |
parent | 37ba0047a98279ad818744c5ab3b4bb5f3f3eef8 (diff) | |
download | rails-cd388e075c363d80f9bba050bbc77d7a1a1e0e07.tar.gz rails-cd388e075c363d80f9bba050bbc77d7a1a1e0e07.tar.bz2 rails-cd388e075c363d80f9bba050bbc77d7a1a1e0e07.zip |
Search for generators on vendorized plugins and gems.
4 files changed, 17 insertions, 7 deletions
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb index d513a3f6c7..83f1847598 100644 --- a/railties/lib/generators.rb +++ b/railties/lib/generators.rb @@ -20,13 +20,19 @@ module Rails # Generators load paths. First search on generators in the RAILS_ROOT, then # look for them in rails generators. # - # TODO Add plugins, gems and frozen gems to load path. + # TODO Right now, only plugin and frozen gems generators are loaded. Gems + # loaded by rubygems are not available since Rails dependencies system is + # being reworked. # def self.load_path @@load_path ||= begin paths = [] paths << File.expand_path(File.join(File.dirname(__FILE__), "generators")) - paths << File.join(RAILS_ROOT, "lib", "generators") if defined?(RAILS_ROOT) + if defined?(RAILS_ROOT) + paths += Dir[File.join(RAILS_ROOT, "vendor", "gems", "*", "lib", "generators")] + paths += Dir[File.join(RAILS_ROOT, "vendor", "plugins", "*", "lib", "generators")] + paths << File.join(RAILS_ROOT, "lib", "generators") + end paths end end diff --git a/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb b/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb deleted file mode 100644 index 8fda8197d1..0000000000 --- a/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb +++ /dev/null @@ -1,4 +0,0 @@ -class StubbyGenerator < Rails::Generator::Base - def manifest - end -end diff --git a/railties/test/fixtures/vendor/gems/mspec/lib/generators/mspec_generator.rb b/railties/test/fixtures/vendor/gems/mspec/lib/generators/mspec_generator.rb new file mode 100644 index 0000000000..191bdbf2fc --- /dev/null +++ b/railties/test/fixtures/vendor/gems/mspec/lib/generators/mspec_generator.rb @@ -0,0 +1,2 @@ +class MspecGenerator < Rails::Generators::NamedBase +end diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index c49081e5cc..c7195f753d 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -63,6 +63,12 @@ class GeneratorsTest < GeneratorsTestCase assert_equal "rails:generators:javascripts", klass.namespace end + def test_find_by_namespace_lookup_to_vendor_folders + klass = Rails::Generators.find_by_namespace(:mspec) + assert klass + assert_equal "mspec", klass.namespace + end + def test_builtin_generators assert Rails::Generators.builtin.include? %w(rails model) end @@ -75,7 +81,7 @@ class GeneratorsTest < GeneratorsTestCase def test_rails_generators_with_others_information output = capture(:stdout){ Rails::Generators.help }.split("\n").last - assert_equal "Others: active_record:fixjour, fixjour, rails:javascripts.", output + assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts.", output end def test_no_color_sets_proper_shell |