mardi 24 février 2015

Register multiple Rails generators to be run on single invocation

On Rails3, I have multiple gems which by default rely on YAML config files placed in conf/gem1.yml, conf/gem2.yml, etc; these files should not be checked into source control as they have user-specific values such as secret tokens.


I'm looking for a way for each gem to define a generator that will create an initial version of that file for each dev to modify afterwards, and have those generators registered somehow so they can all be run by invoking a single command.


For example, I'd like gem1, gem2 and gem3 to define gem1:config, gem2:config and gem3:config generators, as well as a shared gems:all_config. So if I include gem1 and gem2 in my project, I automatically have the gems:all_config generator that will invoke gem1:config and gem2:config; if I add gem3 later, gem3:config is automatically appended to the call to gems:all_config.


Any ideas on how to implement this cleanly? I've been playing around with hook_for with no success so far, as it seems to be designed for a different use case.


Aucun commentaire:

Enregistrer un commentaire