Current State of Dancer::Script
Now that more than half of the program of GSoC has passed, Franck asked for me to do a write-up of my work, so everybody can check it and evaluate to see if it can be merged with the current devel repo of Dancer.
You can check my whole work at my repo in github, and if you care to make changes, just PR at will :)
Introducing Dancer::Script
Dancer::Script module is a mash-up between the old script/dancer utility that we currently use to scaffold every new Dancer application and some other content that I added with management from Sawyer and Franck.
Dancer::Script makes use of Dancer::Object and Dancer::Logger, the last so we can get better log outputs from the whole scaffolding process
So what happened to script/dancer
executable?
Well, it became a 8 lines executables that only calls Dancer::Script
:D
In the same matter, I modified dispatch.cgi
and dispatch.fcgi
so it will call Dancer::Script
.
dispatch.fcgi
Dancer::Script::run_scaffold_cgi
and Dancer::Script::run_scaffold_fcgi
runs the code for the deployment of CGI
and FastCGI
. This way, every new change in Plack/PSGI that the team encounters and wish to add, can be directly added to Dancer::Script
without the need of scaffolding a new Dancer application in every update that is done to Dancer. Since there are common releases and quick-updates in between weeks, I believe that this is a justified method.
Verbose output
Now that Dancer::Script
makes use of Dancer::Logger
, the following methods replaced good ol’ print
, the methods error()
and debug()
.
So if we do dancer -a Hello::World
we get a pretty output like the following:
Carlos-Computer:test $ dancer -a Hello::World
debug> Writing directory: Hello-World
debug> Successfully wrote the directory: Hello-World
debug> Writing directory: Hello-World/bin
debug> Successfully wrote the directory: Hello-World/bin
debug> Writing file: Hello-World/bin/app.pl
debug> Successfully wrote: Hello-World/bin/app.pl
.............
The same goes for error()
Carlos-Computer:test $ dancer -a 1World
error> Error: Invalid application name.
error> Application names must not contain colons, dots, hyphens or start with a number.
Carlos-Computer:test $
Is that all?
Well, feature-wise speaking it is. But the other good part is that Dancer::Script
is fully an object module that can be run without script/dancer
. For example:
#!/usr/bin/perl
use strict;
use warnings;
use Dancer::Script;
Dancer::Script->init(appname => 'Hello::World', path => '/home/gnusosa/')->run;
So if you need to do something really specific with Dancer::Script
, you don’t need to call script/dancer
and run your automagically work.
But that’s not all!
Now that we have Dancer::Script
, it will allow for future subclassing for extra features that anybody could write themselves. We’ll also be able to easily add plugins so we could have flavors of Dancer::Script
. Just like the ones that create a Dist::Zilla
based dist or a Dancer plugin dist, etc… A lot of possibilities. :)
This is the current state of my work, I hope you like it, and expect feedback of all kind. Thanks for your time. :)