| 1 | package Mojo::Debugbar; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Mojo::Debugbar::Monitors; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Mojo::Loader qw(load_class); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Mojo::Server; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | our $VERSION = '0.1.4'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 0 | ▶ | has 'app' => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | has 'config' => sub {{ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | hide_empty => 0, | |||||||||||||||||||||||||||
| 13 | monitors => [ | ||||||||||||||||||||||||||||
| 14 | 'Mojo::Debugbar::Monitor::Request', | ||||||||||||||||||||||||||||
| 15 | 'Mojo::Debugbar::Monitor::DBIx', | ||||||||||||||||||||||||||||
| 16 | 'Mojo::Debugbar::Monitor::Template', | ||||||||||||||||||||||||||||
| 17 | 'Mojo::Debugbar::Monitor::ValidationTiny', | ||||||||||||||||||||||||||||
| 18 | 'Mojo::Debugbar::Monitor::Git', | ||||||||||||||||||||||||||||
| 19 | ], | ||||||||||||||||||||||||||||
| 20 | 2 | }}; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | has 'monitors' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 23 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my @monitors; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | foreach my $module (@{ $self->config->{ monitors } || [] }) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->config->{'monitors'} || []
MC/DC0%0/1
$self->config->{'monitors'} || []
$self->config->{'monitors'}
Truth table0%0/2
A
A= $self->config->{'monitors'}
| |||||||||||||||||||||||||||||
| 28 | 0 | my $monitor = _monitor($module, 1); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | push(@monitors, $monitor->new(app => $self->app)); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | return Mojo::Debugbar::Monitors->new( | ||||||||||||||||||||||||||||
| 34 | registered => \@monitors, | ||||||||||||||||||||||||||||
| 35 | hide_empty => $self->config->{ hide_empty }, | ||||||||||||||||||||||||||||
| 36 | 0 | ); | |||||||||||||||||||||||||||
| 37 | 2 | }; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head2 inject | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Inject monitors via javascript | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub inject { | ||||||||||||||||||||||||||
|
Subroutine
inject: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 0 | return shift->monitors->inject; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head2 render | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Proxy for monitors->render | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub render { | ||||||||||||||||||||||||||
|
Subroutine
render: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | return shift->monitors->render; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head2 stop | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Proxy for monitors->stop | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub stop { | ||||||||||||||||||||||||||
|
Subroutine
stop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $self->monitors->stop; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | return $self; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head2 start | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Proxy for monitors->start | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub start { | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | $self->monitors->start; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | return $self; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 _monitor | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Load monitor | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub _monitor { | ||||||||||||||||||||||||||
|
Subroutine
_monitor: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 95 | 0 | my ($module, $fatal) = @_; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return $module->isa('Mojo::Debugbar::Monitor') ? $module : undef | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 98 | unless my $e = load_class $module; | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $fatal && ref $e ? die $e : return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$fatal and ref $e
MC/DC0%0/2
$fatal and ref $e
$fatal
ref $e
Truth table0%0/3
A and B
A= $fatalB= ref $e
| |||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 2 | 1; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =encoding utf8 | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head1 NAME | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | Mojo::Debugbar - A nice Debugbar that helps developers using Mojolicious framework | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | use Mojo::Debugbar; | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | my $debugbar = Mojo::Debugbar->new(app => $app, config => { | ||||||||||||||||||||||||||||
| 115 | hide_empty => 0, | ||||||||||||||||||||||||||||
| 116 | monitors => [ | ||||||||||||||||||||||||||||
| 117 | 'Mojo::Debugbar::Monitor::Request', | ||||||||||||||||||||||||||||
| 118 | 'Mojo::Debugbar::Monitor::DBIx', | ||||||||||||||||||||||||||||
| 119 | 'Mojo::Debugbar::Monitor::Template', | ||||||||||||||||||||||||||||
| 120 | 'Mojo::Debugbar::Monitor::ValidationTiny', | ||||||||||||||||||||||||||||
| 121 | ] | ||||||||||||||||||||||||||||
| 122 | }); | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | $debugbar->start; | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | ... | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | $debugbar->stop; | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | L<Mojo::Debugbar> is a package that helps you collect some metrics for your Mojolicious app | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | L<Mojo::Debugbar> inherits all attributes from L<Mojo::Base>. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head1 METHODS | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | L<Mojo::Debugbar> inherits all methods from L<Mojo::Base> and implements | ||||||||||||||||||||||||||||
| 141 | the following new ones. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head2 inject | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | $debugbar->inject; | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Injects the monitors via javascript. | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =head2 render | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | $debugbar->start; | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | Renders the collected metrics as html. | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head2 start | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | $debugbar->start; | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | Starts all the monitors. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =head2 stop | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | $debugbar->stop; | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Stops all the monitors. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | L<Mojolicious>, L<Mojolicious::Plugin::Debugbar>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||