| 1 | package Dash::Backend::Mojolicious::Setup; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use File::ShareDir 1.116; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 6 | has 'dash_app'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 11 | ▶ | sub register_app { | ||||||||||||||||||||||||||
|
Subroutine
register_app: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 13 | 11 | my $renderer = shift; | |||||||||||||||||||||||||||
| 14 | 11 | my $routes = shift; | |||||||||||||||||||||||||||
| 15 | 11 | my $dash_app = shift; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | $dash_app //= sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 17 | 0 | return $self->dash_app; | |||||||||||||||||||||||||||
| 18 | 11 | ▶ | }; | ||||||||||||||||||||||||||
|
Condition33%1/3
$dash_app //= sub {
return $self->dash_app;
}
MC/DC0%0/2
$dash_app //= sub {
return $self->dash_app;
}
$dash_app
sub {
return $self->dash_app;
}
Truth table33%1/3
A //= B
A= $dash_appB= sub {
return $self->dash_app;
}
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 11 | push @{ $renderer->classes }, __PACKAGE__; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $routes->get( | ||||||||||||||||||||||||||||
| 23 | 1 | ▶ | '/' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | my $c = shift; | |||||||||||||||||||||||||||
| 25 | 1 | $c->stash( perl_dash_mojo_backend_stylesheets => $dash_app->()->_rendered_stylesheets, | |||||||||||||||||||||||||||
| 26 | perl_dash_mojo_backend_external_stylesheets => $dash_app->()->_rendered_external_stylesheets, | ||||||||||||||||||||||||||||
| 27 | perl_dash_mojo_backend_scripts => $dash_app->()->_rendered_scripts, | ||||||||||||||||||||||||||||
| 28 | perl_dash_mojo_backend_title => $dash_app->()->app_name | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | 1 | $c->render( template => 'index' ); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 11 | ); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 11 | my $dist_name = 'Dash'; | |||||||||||||||||||||||||||
| 35 | $routes->get( | ||||||||||||||||||||||||||||
| 36 | 1 | ▶ | '/_dash-component-suites/:perl_dash_mojo_backend_namespace/*perl_dash_mojo_backend_asset' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # TODO Component registry to find assets file in other dists | ||||||||||||||||||||||||||||
| 39 | 1 | my $c = shift; | |||||||||||||||||||||||||||
| 40 | 1 | my $file = $dash_app->()->_filename_from_file_with_fingerprint( $c->stash('perl_dash_mojo_backend_asset') ); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | $c->reply->file( | |||||||||||||||||||||||||||
| 43 | File::ShareDir::dist_file( $dist_name, | ||||||||||||||||||||||||||||
| 44 | Path::Tiny::path( 'assets', $c->stash('perl_dash_mojo_backend_namespace'), | ||||||||||||||||||||||||||||
| 45 | $file )->canonpath | ||||||||||||||||||||||||||||
| 46 | ) | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 11 | ); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | $routes->get( | ||||||||||||||||||||||||||||
| 52 | 1 | ▶ | '/_favicon.ico' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 1 | my $c = shift; | |||||||||||||||||||||||||||
| 54 | 1 | $c->reply->file( File::ShareDir::dist_file( $dist_name, 'favicon.ico' ) ); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 11 | ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | $routes->get( | ||||||||||||||||||||||||||||
| 59 | 1 | ▶ | '/_dash-layout' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 1 | my $c = shift; | |||||||||||||||||||||||||||
| 61 | 1 | $c->render( json => $dash_app->()->layout() ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 11 | ); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | $routes->get( | ||||||||||||||||||||||||||||
| 66 | 1 | ▶ | '/_dash-dependencies' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 1 | my $c = shift; | |||||||||||||||||||||||||||
| 68 | 1 | my $dependencies = $dash_app->()->_dependencies(); | |||||||||||||||||||||||||||
| 69 | 1 | $c->render( json => $dependencies ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 11 | ); | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | $routes->post( | ||||||||||||||||||||||||||||
| 74 | 2 | ▶ | '/_dash-update-component' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.3
| |||||||||||||||||||||||||||||
| 75 | 2 | my $c = shift; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | my $request = $c->req->json; | |||||||||||||||||||||||||||
| 78 | 2 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | 2 | my $content = $dash_app->()->_update_component($request); | |||||||||||||||||||||||||||
| 80 | 1 | $c->render( json => $content ); | |||||||||||||||||||||||||||
| 81 | 1 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | if ( Scalar::Util::blessed $_ && $_->isa('Dash::Exceptions::PreventUpdate') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($_) and $_->isa("Dash::Exceptions::PreventUpdate")
MC/DC0%0/2
builtin::blessed($_) and $_->isa("Dash::Exceptions::PreventUpdate")
builtin::blessed($_)
$_->isa("Dash::Exceptions::PreventUpdate")
Truth table33%1/3
A and B
A= builtin::blessed($_)B= $_->isa("Dash::Exceptions::PreventUpdate")
| |||||||||||||||||||||||||||||
| 83 | 1 | $c->render( status => 204, json => '' ); | |||||||||||||||||||||||||||
| 84 | } else { | ||||||||||||||||||||||||||||
| 85 | 0 | die $_; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 2 | }; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | 11 | ); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 11 | return; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 6 | 1; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =pod | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 NAME | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Dash::Backend::Mojolicious::Setup | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 VERSION | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | version 0.11 | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Pablo Rodríguez González <pablo.rodriguez.gonzalez@gmail.com> | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | This software is Copyright (c) 2022 by Pablo Rodríguez González. | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | The MIT (X11) License | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | __DATA__ | ||||||||||||||||||||||||||||