I wrote a generator that I'd like to use in my Rails3 projects using Thor (which I absolutely love).
How would I go about using my generator in all my rails3 projects? i.e. how do I install it?
If the answer is to make a gem out of it - could y开发者_开发技巧ou please describe the rails3 process of doing so?
Thanks!
Yep, make a gem!
In terms of loading your generator it's pretty much as simple as putting your generator files in lib/generators/#{generator_name}/
in the gem. See the generators guide for a little more explanation of how they're loaded.
Check out some gems which do this such as rails3-generators gem. rspec-rails, machinist for examples.
In terms of actually building your gem, check out jeweler
精彩评论