On 19 Dec 2007, at 00:41, Daniel N wrote:

> - If I want my plugin to add some new generate functionality? Is this
> possible? If so, are there any examples? I dont seem to be able to
> find any :(
>
> You can look at the ORM plugins, although they are a bit different  
> since the subclass specific helpers in merb.  To see the generators  
> themselves that merb uses in
> http://merb.devjavu.com/browser/trunk/lib/merb/generators/merb_generator_helpers.rb
>
> Basically if you want a generator you would create a generator in the
>
> merb_generators directory.  If you want one specifically for  
> datamapper, activerecord, sequel, rspec or test_unit you would put  
> it in those directories with _generator added to the end.
>
> eg.
> activerecord_generators
> datamapper_generators
> rspec_generators
>   my_generator_name_generator.rb
>   templates
>     template1.erb
>     template2.erb
>   USAGE
>
> The usage file, if present will allow the generator to be listed in  
> a call to
> script/generate

Ok, so just to check I understand it, my folder structure of my plugin  
might look something like:

+ some_merb_plugin
   + lib
   + merb_generators
     - my_demo_generator.rb
     + templates
       - template1.erb
     - USAGE
   + spec

That will automatically then be included when script/generate is called?

Looking at the source of the merb controller (et al) generators, there  
all subclasses of RubiGen::Base, so id presumably be able to copy that  
structure to create the generator I want?


> - The plugin needs to go into the gem dir right? So anything within
> the gem dir is automatically included on the app load path?
>
> It doesn't have to go in there.  That's just a way to make sure your  
> app will see it on a shared host.  You include a line in  
> dependencies.rb
> dependency "my_plugin"

Cool - I guess that negates the need for putting them in the gem dir.

> - If there were some view helpers in the gem, is there way of forcing
> them to be included like in rails where you include them into the
> ActionView module so they are instantly available in views?
>
> Merb::ViewContext is the class that these should be put into.  If  
> you put them in there.  They will be avilable to your views.

Sweet, that makes sense.

Cheers

Tim



_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to