atm we have scopes for the generator of
[:merb, :rspec/:test_unit]
and this works well for selecting the test stub to generate by having
merb define the test_unit and rspec generators with the same name.
What currently happens with model generators though is that each ORM
defines their own. They all work the same, but they are called
different things. So you have
ar_model, sequel_model, dm_model and the same for migrations. These
are all in the merb scope so they must be renamed for the individual
ORM. I don't like the pollution when I run a bare script/generate and
it reports all these different generators, and I sometimes have to do
that to remember what the generator is called.
What I would like to do is to include another scope. The ORM scope.
I would then define the scopes as:
[:data_mapper, :merb, :rspec]
Then in the merb gem, in :merb scope I want a merb_model generator.
This would generate a basic class and test as a default. If I then
define a merb_model generator in the :data_mapper scope in the
data_mapper gem, I want it to use that for merb_model instead since
it's listed first in the scope list.
I hope I'm making sense. To be more consise, I'd like to define
multiple scopes, and, in order of the declared scope, have it look for
a generator of the given name. If it finds one use that and stop
looking.
This would allow me to use
ruby script/generate merb_model
and depending on the scope provided I would get the correct model with
it falling back to the merb defined merb_model if no other scope
defines the merb_model generator.
Am I making sense?
Cheers
-Daniel
http://drnicacademy.com - Ruby/Rails training around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
skype: nicwilliams
(p) +61 412 002 126
(mail) PO Box 583, Ashgrove 4060, Queensland, Australia
Perhaps it could print a list of scopes that match, and you pick from a list (sounds like more work to implement, but might be better - means you don't have to care what order you write your scopes in)
Nic
http://pastie.textmate.org/private/bdirim9zt78njslcpxokla
The only change required is that .reverse at the end. I've actually tried this out on a number of generators and it works no problem. No error is thrown for having multiple generators of the same name.
Let me know what you think.
Cheers
-Daniel