App-CatalystStarter-Bloated
view release on metacpan or search on metacpan
t/lib/.pgpass
t/lib/TestUtils.pm
t/mk_app.t
t/pgpass.t
share/initializr-verekia-4.0.zip
t/script/name.t
t/script/model.t
t/script/views.t
META.yml
META.json
t/verify_json.t
t/verify_root.t
t/verify_tt.t
bin/catalyst-fatstart.pl view on Meta::CPAN
B<Important>: Will set --model and --schema with default names unless
they are also specified. Default names currently are CatNameDB and
CatName::Schema.
=item -[-][no]dsnfix
Checks and corrects the dsn input
Fixes case of known drivers, adds missing leading dbi:, tries to
verify and correct sqlite file paths, checks that hostnames can be resolved
=for Euclid:
false: --nodsnfix
=item -[-][no]pgpass
If set, will look in ~/.pgpass to complete dbi information.
Will currently only suplement the dsn if it finds a matching database
name.
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
my $substitute_this = q[$c->response->body( $c->welcome_message );];
(my $root = $r->slurp) =~ s|\Q$substitute_this|# $&| and l->debug( "Commented response body message in sub index" );
$r->spew( $root );
l->info( sprintf "Created TT view as %s::View::%s",
@ARGV{qw/--name --TT/}
);
_verify_TT_view();
_verify_Root_index();
} ## create.tt
sub _create_JSON {
return unless my $json = $ARGV{"--JSON"};
_run_system( _creater() => "view", $json, "JSON" );
my $p = _catalyst_path( "JSON" );
my $json_code = $p->slurp;
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
if ( not $json_code =~ s/use base 'Catalyst::View::JSON';/$&\n$extra/ ) {
# l->error("failed configuring expose_stash in json");
}
$p->spew( $json_code );
l->info( sprintf "Created JSON view as %s::View::%s",
@ARGV{qw/--name --JSON/}
);
_verify_JSON_view();
} ## create_json.tt
sub _mk_views {
if ( $ARGV{'--TT'} ) {
_create_TT;
}
if ( $ARGV{'--JSON'} ) {
_create_JSON;
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
my $p = _catalyst_path( "C", "Root.pm" );
my $substitute_this = q[$c->response->body( $c->welcome_message );];
my $with_this = q[$c->stash->{jumbotron} = { header => "Splashy message", body => "This is a 'jumbotron' header, view source and check Root controller for details" };] . "\n";
(my $root = $p->slurp) =~ s|(?:# )?\Q$substitute_this|$&\n $with_this|
or l->error("Failed inserting jumbotron");
$p->spew( $root );
_verify_Root_jumbatron();
}
## test related
sub _test_new_cat {
return if $ARGV{'--notest'};
chdir $cat_dir;
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
elsif ( _run_system "make" => "test" ) {
l->error( "make test failed" );
return;
}
l->info( "Catalyst tests ok" );
chdir "..";
}
sub _verify_TT_view {
my $view_file = $_[0] || _catalyst_path( "TT" );
return if not defined $view_file;
eval { require $view_file };
if ( $@ ) {
l->error( "$view_file contains errors and must be edited by hand." );
l->error( "$@" );
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
my $cnf = $view_class->config;
if ( not defined $cnf->{WRAPPER} or $cnf->{WRAPPER} ne "wrapper.tt2" ) {
l->error( "$view_class didn't get WRAPPER properly configured, must be fixed manually." );
}
if ( not defined $cnf->{TEMPLATE_EXTENSION} or $cnf->{TEMPLATE_EXTENSION} ne ".tt2" ) {
l->error( "$view_class didn't get TEMPLATE_EXTENSION properly configured, must be fixed manually." );
}
l->debug( "Modifications to TT view ok" );
} ## verify_tt.t
sub _verify_Root_index {
my $root_controller_file = $_[0] || _catalyst_path( "C", "Root.pm" );
if ( not ref $root_controller_file ) {
$root_controller_file = path( $root_controller_file );
}
my $root_controller = $root_controller_file->slurp;
if ( $root_controller =~ /^\s+\$c->response->body.*welcome_message/m ) {
l->error( "Failed fixing Root controller. Comment out the response body line." );
l->error( "Root contents:" );
l->error( $root_controller );
}
l->debug( "Root controller set to run index.tt2" );
}
sub _verify_Root_jumbatron {
my $root_controller_file = $_[0] || _catalyst_path( "C", "Root.pm" );
if ( not ref $root_controller_file ) {
$root_controller_file = path( $root_controller_file );
}
my $root_controller = $root_controller_file->slurp;
if ( $root_controller !~ /stash.*jumbotron.*header.*body/ ) {
l->error( "Failed adding jumbotron example to Root controller" );
}
l->debug( "Sample jumbotron data added to Root controller" );
}
sub _verify_JSON_view {
my $view_file = $_[0] || _catalyst_path( "JSON" );
return if not defined $view_file;
eval { require $view_file };
if ( $@ ) {
l->error( "$view_file contains errors and must be edited by hand." );
l->error( "$@" );
lib/App/CatalystStarter/Bloated.pm view on Meta::CPAN
if ( not defined $cnf->{expose_stash} or
ref $cnf->{expose_stash} ne "ARRAY" or
$cnf->{expose_stash}[0] ne "json"
) {
l->error( "$view_class didn't get expose_stash properly configured, ".
"must be fixed manually, expected to be ['json']." );
}
l->debug( "Modifications to JSON view ok" );
} ## verify_json.t
## This does it all
sub run {
## complete with logic not covered in G::E
_finalize_argv;
## 1: Create a catalyst
_mk_app;
t/verify_json.t view on Meta::CPAN
## Need to import these or there will be trouble when the perl module
## code doesn't load
use Catalyst::View;
use Catalyst::View::JSON;
$ARGV{'--name'} = "Foo";
my $f1 = Path::Tiny->tempfile;
$f1->spew( $view_with_syntax_error );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_JSON_view($f1) },
qr/ contains errors and must be edited by hand\./,
"view with syntax error handled correctly"
);
$ARGV{'--name'} = "Bar";
my $f2 = Path::Tiny->tempfile;
$f2->spew( $view_with_missing_config );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_JSON_view($f2) },
qr/\Q didn't get expose_stash properly configured, must be fixed manually, expected to be ['json']./,
"view with missing export_stash handled"
);
done_testing;
BEGIN {
$view_with_syntax_error = <<'EOV';
package Foo::View::JSON;
t/verify_root.t view on Meta::CPAN
## code doesn't load
use Catalyst::View;
use Catalyst::View::TT;
note "index changed in Root";
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_plain );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_Root_index($f) },
qr/Failed fixing Root controller\. Comment out the response body line\./,
"Detects when Root controller does not have index commented out"
);
}
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_with_response_body_commented_out );
stderr_is(
sub { App::CatalystStarter::Bloated::_verify_Root_index($f) },
"",
"Root controller index ok"
);
}
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_with_both );
stderr_is(
sub { App::CatalystStarter::Bloated::_verify_Root_index($f) },
"",
"Root controller index ok when both are ok"
);
}
note "jumbotron added to Root";
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_plain );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_Root_jumbatron($f) },
qr/Failed adding jumbotron example to Root controller/,
"Detects when Root controller does not have jumbotron"
);
}
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_with_jumbotron );
stderr_is(
sub { App::CatalystStarter::Bloated::_verify_Root_jumbatron($f) },
"",
"Detects when Root controller does have jumbotron"
);
}
{
my $f = Path::Tiny->tempfile;
$f->spew( $root_controller_with_both );
stderr_is(
sub { App::CatalystStarter::Bloated::_verify_Root_jumbatron($f) },
"",
"Root controller jumbotron ok when both are ok"
);
}
done_testing;
BEGIN {
t/verify_tt.t view on Meta::CPAN
## Need to import these or there will be trouble when the perl module
## code doesn't load
use Catalyst::View;
use Catalyst::View::TT;
$ARGV{'--name'} = "Foo";
my $f1 = Path::Tiny->tempfile;
$f1->spew( $view_with_syntax_error );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_TT_view($f1) },
qr/ contains errors and must be edited by hand\./,
"view with syntax error handled correctly"
);
$ARGV{'--name'} = "Bar";
my $f2 = Path::Tiny->tempfile;
$f2->spew( $view_with_wrong_extension );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_TT_view($f2) },
qr/ didn't get TEMPLATE_EXTENSION properly configured, must be fixed manually\./,
"view with wrong extension handled correctly"
);
$ARGV{'--name'} = "Baz";
my $f3 = Path::Tiny->tempfile;
$f3->spew( $view_with_missing_wrapper );
stderr_like(
sub { App::CatalystStarter::Bloated::_verify_TT_view($f3) },
qr/ didn't get WRAPPER properly configured, must be fixed manually\./,
"view with wrapper not set handled correctly"
);
$ARGV{'--name'} = "Test";
my $f4 = Path::Tiny->tempfile;
$f4->spew( $view_where_all_is_ok );
stderr_is(
sub { App::CatalystStarter::Bloated::_verify_TT_view($f4) },
"", "view where all is ok gives no error"
);
done_testing;
BEGIN {
$view_with_syntax_error = <<'EOV';
package Foo::View::HTML;
( run in 2.685 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )