Acme-CPANModulesBundle-Import-PerlDancerAdvent-2018
view release on metacpan or search on metacpan
devdata/http_advent.perldancer.org_2018_18 view on Meta::CPAN
my $app_name = $opt->{'application'};
$app_name =~ /^My::Company::App::/
or $self->usage_error('App must be prefixed by "My::Company::App");
# Maybe check we are only scaffolding in a particular directory
cwd() eq '/opt/my_company/webapps/'
or $self->usage_error('Only create apps in our webapps directory');
# At this point, we can run the original scaffolding
$self->SUPER::execute( $opt, $args );
# Now we finished generating, but we can contineu customizing what we have
}
1;</pre>
<p>Writing your own generation on top of the existing generation allows
you to manage the input (including additional validation) and the
output, giving you full control over the scaffolding process.</p>
<p>Some examples on which customizations you might want to perform:</p>
devdata/http_advent.perldancer.org_2018_22 view on Meta::CPAN
# Subclass the main plugin
extends('Dancer2::Plugin::ParamTypes');
# Provide your own 'with_types' keyword
plugin_keywords('with_types');
# Make our keyword call the parent plugin
sub with_types {
my $self = shift;
return $self->SUPER::with_types(@_);
}
# Register all of our own type checks at build time
sub BUILD {
my $self = shift;
$self->register_type_check 'Str' => sub {...};
$self->register_type_check 'ShortStr' => sub {...};
$self->register_type_check 'PositiveInt' => sub {...};
$self->register_type_check 'SHA1' => sub {...};
( run in 1.247 second using v1.01-cache-2.11-cpan-49f99fa48dc )