[Dancer-users] Packaging Dancer to CPAN

Pedro Melo melo at simplicidade.org
Thu May 26 23:35:56 CEST 2011


On Wed, May 25, 2011 at 6:02 PM, Pedro Melo <melo at simplicidade.org> wrote:
> Hi,
> I need to repack a Dancer-based site as a CPAN module. I remember
> seeing a bit of documentation about this somewhere but I can't find it
> at the moment.

Ok, got something to work with a couple problems to be solved: I can
package a Dancer app, deploy it via cpan/cpanm and start it up with
plackup or standalone. The problems are:

 * test suite fails. I need to tweak Dancer::Test a bit *I think*,
still looking into it;
 * the logger tries to create the log inside PERL5LIB: at first glance
I didn't see a way to disable
   logging. Ideally a ENV var would be best.

This is the process so far, from start to finish:

1. create a new dancer app and move into it:

  dancer -a w
  cd w

2. create a dist directory to hold the static files:

  mkdir -p lib/w/Dist

3. move the static files into it:

  mv config.yml environments public views lib/w/Dist

4. Generate a startup package like this one (adjust to the name of your app):

  cat > lib/w/Dist.pm <<'EOF'
package w::Dist;

  my $dist = $INC{'w/Dist.pm'};
  $dist =~ s/[.]pm$//g;

  $ENV{DANCER_APPDIR}  = $dist;

use Dancer;
use w;

sub run      { dance() }
sub psgi_app { local $ENV{PLACK_ENV} = 1; dance() }


4. regen MANIFEST:

  rm -rf lib/w/Dist/logs
  egrep -v '^(lib|config.yml|environments|public|views)' MANIFEST > MANIFEST.NEW
  find lib -type f >> MANIFEST.NEW
  rm -f MANIFEST

5. Build your dist:

  perl Makefile.PL
  make dist

6. test your new dist:

  cpanm --notest w-0.1.tar.gz
  plackup -Mw::Dist -e 'w::Dist->psgi_app'
  perl -Mw::Dist -e 'w::Dist->run'

This is of course work in progress, but most of it can be an automatic
process. I'm still new to the Dancer internals, but right now I don't
think I can solve the problem with the tests without changes to Dancer

Is there interest on a patch to make this easier, maybe as easy as a
'dancer pack-cpan' or something like this?

Thank you for your feedback.

Pedro Melo
xmpp:melo at simplicidade.org
mailto:melo at simplicidade.org

More information about the Dancer-users mailing list