Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8730 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

[patch] rails_generator finds generators within RubyGems

Reported by: nicwilliams Assigned to: core
Priority: normal Milestone: 1.x
Component: Railties Version: edge
Severity: normal Keywords: rails_generator, generators, rubygems, gem
Cc: topfunky

Description

You can store a <gen_name>_generator.rb file in many places (including plugins, ~/.rails/generator/, and within RubyGems whose name ends with _generator) but you cannot store one or more of them within normal RubyGems (that don't have the _generator name).

This patch allows any RubyGem to include a /rails_generators/ (for rails specific generators) or /generators/ (for non-Rails specific generators - for future use when rails_generators is extracted from rails for reuse by other frameworks) and for <generator_name>_generator.rb files to be loaded up by the script/generate command.

Suggested by topfunky, coded by drnic

Attachments

gem_generators.patch (5.3 kB) - added by nicwilliams on 06/22/07 19:03:46.
Patch for railties gem (apply within /railties/ folder)
gem_generators2.patch (5.2 kB) - added by nicwilliams on 06/27/07 09:11:36.
Replacement patch - lookup *generators changed to generators + rails_generators explicitly

Change History

06/22/07 19:03:46 changed by nicwilliams

  • attachment gem_generators.patch added.

Patch for railties gem (apply within /railties/ folder)

06/23/07 14:37:36 changed by nicwilliams

  • type changed from defect to enhancement.

06/25/07 07:33:30 changed by matt

  • keywords changed from rails_generator, generators, rubygems to rails_generator, generators, rubygems, gem.

+1 not a major new feature but it really makes gem developers' life easier and keeps things clean.

06/25/07 12:09:52 changed by nicwilliams

Discussion of this patch on Dr Nic's blog

06/27/07 08:54:28 changed by bitsweat

Good idea. What's

-            sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators")
+            sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/*generators")

for?

06/27/07 09:01:27 changed by nicwilliams

Jeremy, from the CHANGELOG:

	* Plugin generators can be placed in /rails_generators folder, in addition to /generators folder (in fact, any folder /*generators); to allow RubyGems with generators (see below) to be directly usable as plugins, and include generators. [Dr Nic, topfunky] 

That is, it allows the generators folder to be rails_generators or anything else ending with generators.

Hmm. Perhaps it should be restricted to generators OR rails_generators, and not so flexible; else merb_generators will get included etc. (I know there are no merb generators, but one day there will be, and plugins/gems might be bundled with generators for multiple frameworks.

I'll go change the patch so the *generators becomes (|rails_)generators.

06/27/07 09:02:09 changed by nicwilliams

Forget that, its a Dir...? not a regex. I'll come up with something for the patch.

06/27/07 09:11:36 changed by nicwilliams

  • attachment gem_generators2.patch added.

Replacement patch - lookup *generators changed to generators + rails_generators explicitly

06/27/07 09:25:29 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [7139]) Generators: look for generators in all gems, not just those suffixed with _generator, in the gem's generators or rails_generators directory. Allow use of the rails_generators directory instead of the standard generators directory in plugins also. Closes #8730.