[Dancer-users] a couple of questions re. Plugins

David Precious davidp at preshweb.co.uk
Fri Dec 2 18:38:23 CET 2011


On Friday 02 December 2011 16:48:26 Puneet Kishor wrote:
> Of course, continuing to refine DPM while under "lib" is a pain in the ass
> because I have `sudo` every time, and, besides, I don't want to break my
> existing apps while I further experiment with DPM. So, I made a copy of
> DPM in my own home directory. To share it with the rest of the world, I
> also made that home directory version into a git repo, and put it on
> github.
> 
> So, now I have
> 
> 	/opt/local/lib/perl5/site_perl/5.14.1/Dancer/Plugin/Meta.pm which is
> currently powering my apps ~/Projects/Dancer/Plugin/Meta.pm which is a git
> repo and where I continue to hack it

Firstly, I'd recommend adopting the usual layout of a CPAN module of a dir 
named Dancer-Plugin-Meta, containing lib/Dancer/Plugin/Meta.pm, along with a 
makefile, tests, etc.  It's much easier to use e.g. Module::Starter to rock 
that up for you.


Also, I'd recommend not manually editing/creating stuff under your site_perl 
directories - reserve that for modules actually installed via the CPAN 
toolchain.


> I am not knowledgable about the workflow whereby I can make experimental
> changes to ~/Projects/Dancer/Plugin/Meta.pm and test it in the development
> versions of my apps, and when I am satisfied with the changes, update my
> site_perl version with the new version (Of course, pushing the changes to
> github is easy).
> 
> Any guidance on this would be appreciated.


You probably want to look at using local::lib - or simply start your app when 
you're developing with a -I argument to add a dir to @INC, e.g.:

perl -I~/Projects/Dancer-Plugin-Meta/lib bin/app.pl

Doing that will mean that your dev version of the plugin will be found first 
in @INC and loaded instead of the system-wide one.

When you're happy with the changes in your dev version, you could install them 
as you would any other Perl module with e.g. "perl Makefile.PL; make install" 
if you have set up your module as a CPAN-ready package layout using e.g. 
Module::Starter as previously mentioned.

Of course, you could just add a "use lib ..." statement to your app while 
you're working on it, but that's a little bodgier :)

Hope that's of some help?


-- 
David Precious  ("bigpresh")
http://www.preshweb.co.uk/

   "Programming is like sex. One mistake and you have to support
   it for the rest of your life". (Michael Sinz)


More information about the Dancer-users mailing list