| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Mojo::Debugbar; | 
| 2 | 1 |  |  | 1 |  | 54220 | use Mojo::Base -base; | 
|  | 1 |  |  |  |  | 163944 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 1 |  |  | 1 |  | 515 | use Mojo::Debugbar::Monitors; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 5 | 1 |  |  | 1 |  | 388 | use Mojo::Loader qw(load_class); | 
|  | 1 |  |  |  |  | 28929 |  | 
|  | 1 |  |  |  |  | 53 |  | 
| 6 | 1 |  |  | 1 |  | 411 | use Mojo::Server; | 
|  | 1 |  |  |  |  | 7983 |  | 
|  | 1 |  |  |  |  | 13 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our $VERSION = '0.0.3'; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | has 'app' => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; | 
| 11 |  |  |  |  |  |  | has 'config' => sub {{ | 
| 12 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | }}; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | has 'monitors' => sub { | 
| 23 |  |  |  |  |  |  | my $self = shift; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | my @monitors; | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | foreach my $module (@{ $self->config->{ monitors } || [] }) { | 
| 28 |  |  |  |  |  |  | my $monitor = _monitor($module, 1); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | ); | 
| 37 |  |  |  |  |  |  | }; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head2 render | 
| 40 |  |  |  |  |  |  | Proxy for monitors->render | 
| 41 |  |  |  |  |  |  | =cut | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub render { | 
| 44 | 0 |  |  | 0 | 1 |  | return shift->monitors->render; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head2 stop | 
| 48 |  |  |  |  |  |  | Proxy for monitors->stop | 
| 49 |  |  |  |  |  |  | =cut | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub stop { | 
| 52 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 0 |  |  |  |  |  | $self->monitors->stop; | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 0 |  |  |  |  |  | return $self; | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head2 start | 
| 60 |  |  |  |  |  |  | Proxy for monitors->start | 
| 61 |  |  |  |  |  |  | =cut | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | sub start { | 
| 64 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 0 |  |  |  |  |  | $self->monitors->start; | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 0 |  |  |  |  |  | return $self; | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head2 _monitor | 
| 73 |  |  |  |  |  |  | Load monitor | 
| 74 |  |  |  |  |  |  | =cut | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | sub _monitor { | 
| 77 | 0 |  |  | 0 |  |  | my ($module, $fatal) = @_; | 
| 78 |  |  |  |  |  |  |  | 
| 79 | 0 | 0 |  |  |  |  | return $module->isa('Mojo::Debugbar::Monitor') ? $module : undef | 
|  |  | 0 |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | unless my $e = load_class $module; | 
| 81 | 0 | 0 | 0 |  |  |  | $fatal && ref $e ? die $e : return undef; | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | 1; | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =encoding utf8 | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =head1 NAME | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | Mojo::Debugbar - A nice Debugbar that helps developers using Mojolicious framework | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | use Mojo::Debugbar; | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | my $debugbar = Mojo::Debugbar->new(app => $app, config => { | 
| 97 |  |  |  |  |  |  | hide_empty  => 0, | 
| 98 |  |  |  |  |  |  | monitors    => [ | 
| 99 |  |  |  |  |  |  | 'Mojo::Debugbar::Monitor::Request', | 
| 100 |  |  |  |  |  |  | 'Mojo::Debugbar::Monitor::DBIx', | 
| 101 |  |  |  |  |  |  | 'Mojo::Debugbar::Monitor::Template', | 
| 102 |  |  |  |  |  |  | 'Mojo::Debugbar::Monitor::ValidationTiny', | 
| 103 |  |  |  |  |  |  | ] | 
| 104 |  |  |  |  |  |  | }); | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | $debugbar->start; | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | ... | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | $debugbar->stop; | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | L is a package that helps you collect some metrics for your Mojolicious app | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | L inherits all attributes from L. | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head1 METHODS | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | L inherits all methods from L and implements | 
| 123 |  |  |  |  |  |  | the following new ones. | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =head2 render | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | $debugbar->start; | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | Renders the collected metrics as html. | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | =head2 start | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | $debugbar->start; | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | Starts all the monitors. | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =head2 stop | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | $debugbar->stop; | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | Stops all the monitors. | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | L, L, L, L. | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =cut |