Generators in plugins

Is it a bug or a feature that directories that happen to be named
'generators' deep inside a plugin (rather than at the top level) get
searched for generators? It's not mentioned by the documentation, but I'm
wondering if anyone's plugins might be broken by it, and if so, whether
that's their problem or Rails' problem.

Just trying to assess whether I should bother submitting a patch or not.

- Matt

Is it a bug or a feature that directories that happen to be named
'generators' deep inside a plugin (rather than at the top level) get
searched for generators?

It's a feature :

in lib/rails_generator/lookup.rb it says :

# Use component generators (model, controller, etc).
[...]
# 2. Look in plugins, either for generators/ or rails_generators/
# directories within each plugin

It's not mentioned by the documentation, but I'm
wondering if anyone's plugins might be broken by it,
and if so, whether that's their problem or Rails' problem.

Just trying to assess whether I should bother submitting a patch or not.

In my opinion, you shouldn't.

    -- Jean-François.

> Is it a bug or a feature that directories that happen to be named
> 'generators' deep inside a plugin (rather than at the top level) get
> searched for generators?

It's a feature :

in lib/rails_generator/lookup.rb it says :

# Use component generators (model, controller, etc).
[...]
# 2. Look in plugins, either for generators/ or rails_generators/
# directories within each plugin

That is still as ambiguous as the code, though -- does it mean just in the
top-level, or anywhere? While the plural "directories" would suggest
anywhere, but using a plural after an "or" is fairly common usage in
English.

Beyond that, there's still the issue of whether it's correct operation to
look for those directories anywhere in the tree. After all, we don't add
all 'lib' directories we happen to find in the tree to the load path (or do
we? I'd hope not).

> Just trying to assess whether I should bother submitting a patch or not.

In my opinion, you shouldn't.

One vote against, then. Anyone else?

- Matt

That is still as ambiguous as the code, though -- does it mean just in the
top-level, or anywhere? While the plural "directories" would suggest
anywhere, but using a plural after an "or" is fairly common usage in
English.

Beyond that, there's still the issue of whether it's correct operation to
look for those directories anywhere in the tree. After all, we don't add
all 'lib' directories we happen to find in the tree to the load path (or do
we? I'd hope not).

Yeah, it does seem kinda strange. generators or rails_generators
directories at the top level of plugins makes sense, but crawling
around inside the folders seems messy. If you investigate a patch,
have a look at what plugins break / might break. We can mention the
change in the release notes, but it'd be good to have a good idea
going into the change rather than be surprised when 2.1 ships.

Is there any sort of easily accessable list of plugins to test anywhere? The
Rails plugins landscape seems pretty fugly to me -- I tend to stumble over
plugins rather than having any single place to go and get all the code for
them, like a supermirror (multiple "plugin index" sites doesn't help
matters). And besides, I think generators are deeply overused and I avoid
plugins that abuse them, so I'm not heavily equipped with generator-using
plugins. <grin>

- Matt

One vote against, then. Anyone else?

A patch would be fine, it seems reasonable. Though, I don't really
see what it's hurting either.

Distributed revision control is the reason it bit me -- metadata trees that
happens to mirror the structure of the working copy give PathSource fits.
There's also the principle of least surprise.

- Matt