| 1 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | package Exception::Reporter::Summarizer::Catalyst; | ||||||||||||
| 4 | { | ||||||||||||
| 5 | 1 | $Exception::Reporter::Summarizer::Catalyst::VERSION = '0.004'; | |||||||||||
| 6 | } | ||||||||||||
| 7 | 1 | ▶ | use parent 'Exception::Reporter::Summarizer'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | # ABSTRACT: a summarizer for Catalyst applications | ||||||||||||
| 9 | |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | ▶ | use Try::Tiny; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | sub new { | ||||||||||||
| 14 | 0 | ▶ | my ($class, $arg) = @_; | ||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 15 | 0 | ▶ | $arg ||= {}; | ||||||||||
|
Condition0%0/2
$arg ||= {}
MC/DC0%0/1
$arg ||= {}
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||
| 16 | |||||||||||||
| 17 | 0 | return bless { resolve_hostname => !! $arg->{resolve_hostname} } => $class; | |||||||||||
| 18 | } | ||||||||||||
| 19 | |||||||||||||
| 20 | 0 | ▶ | sub resolve_hostname { $_[0]->{resolve_hostname} } | ||||||||||
|
Subroutine
resolve_hostname: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 21 | |||||||||||||
| 22 | sub can_summarize { | ||||||||||||
| 23 | 0 | ▶ | my ($self, $entry) = @_; | ||||||||||
|
Subroutine
can_summarize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 24 | 0 | ▶ | return try { $entry->[1]->isa('Catalyst') }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | sub summarize { | ||||||||||||
| 28 | 0 | ▶ | my ($self, $entry) = @_; | ||||||||||
|
Subroutine
summarize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 29 | 0 | my ($name, $c, $arg) = @$entry; | |||||||||||
| 30 | |||||||||||||
| 31 | my @summaries = ({ | ||||||||||||
| 32 | filename => 'catalyst.txt', | ||||||||||||
| 33 | %{ | ||||||||||||
| 34 | 0 | $self->dump( | |||||||||||
| 35 | { | ||||||||||||
| 36 | class => (ref $c), | ||||||||||||
| 37 | version => $c->VERSION, | ||||||||||||
| 38 | }, | ||||||||||||
| 39 | { basename => 'catalyst' }, | ||||||||||||
| 40 | ) | ||||||||||||
| 41 | }, | ||||||||||||
| 42 | |||||||||||||
| 43 | ident => 'Catalyst application ' . (ref $c), | ||||||||||||
| 44 | }); | ||||||||||||
| 45 | |||||||||||||
| 46 | 0 | push @summaries, $self->summarize_request($c); | |||||||||||
| 47 | # push @summaries, $self->summarize_response($c); | ||||||||||||
| 48 | 0 | push @summaries, $self->summarize_stash($c); | |||||||||||
| 49 | 0 | push @summaries, $self->summarize_errors($c); | |||||||||||
| 50 | |||||||||||||
| 51 | 0 | push @summaries, $self->summarize_user($c); | |||||||||||
| 52 | 0 | push @summaries, $self->summarize_session($c); | |||||||||||
| 53 | |||||||||||||
| 54 | 0 | return @summaries; | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | sub summarize_request { | ||||||||||||
| 58 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 59 | 0 | my $req = $c->req; | |||||||||||
| 60 | |||||||||||||
| 61 | 0 | my $cookie_hash = $req->cookies; | |||||||||||
| 62 | 0 | my %cookie_str = map {; $_ => $cookie_hash->{$_}->value } keys %$cookie_hash; | |||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | my $to_dump = { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | action => $req->action, | ||||||||||||
| 66 | address => $req->address, | ||||||||||||
| 67 | arguments => $req->arguments, | ||||||||||||
| 68 | body_parameters => $req->body_parameters, | ||||||||||||
| 69 | cookies => \%cookie_str, | ||||||||||||
| 70 | headers => $req->headers, | ||||||||||||
| 71 | method => $req->method, | ||||||||||||
| 72 | query_parameters => $req->query_parameters, | ||||||||||||
| 73 | uri => "" . $req->uri, | ||||||||||||
| 74 | uploads => $req->uploads, | ||||||||||||
| 75 | path => $req->path, | ||||||||||||
| 76 | |||||||||||||
| 77 | ($self->resolve_hostname ? (hostname => $req->hostname) : ()), | ||||||||||||
| 78 | }; | ||||||||||||
| 79 | |||||||||||||
| 80 | return { | ||||||||||||
| 81 | filename => 'request.txt', | ||||||||||||
| 82 | 0 | %{ $self->dump($to_dump, { basename => 'request' }) }, | |||||||||||
| 83 | ident => 'catalyst request', | ||||||||||||
| 84 | }; | ||||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | sub summarize_response { | ||||||||||||
| 88 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 89 | 0 | Carp::confess("...unimplemented..."); | |||||||||||
| 90 | 0 | my $res = $c->res; | |||||||||||
| 91 | return { | ||||||||||||
| 92 | filename => 'response.txt', | ||||||||||||
| 93 | 0 | %{ $self->dump($res, { basename => 'response' }) }, | |||||||||||
| 94 | ident => 'catalyst response', | ||||||||||||
| 95 | }; | ||||||||||||
| 96 | } | ||||||||||||
| 97 | |||||||||||||
| 98 | sub summarize_stash { | ||||||||||||
| 99 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_stash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 100 | 0 | my $stash = $c->stash; | |||||||||||
| 101 | return { | ||||||||||||
| 102 | filename => 'stash.txt', | ||||||||||||
| 103 | 0 | %{ $self->dump($stash, { basename => 'stash' }) }, | |||||||||||
| 104 | ident => 'catalyst stash', | ||||||||||||
| 105 | }; | ||||||||||||
| 106 | } | ||||||||||||
| 107 | |||||||||||||
| 108 | sub summarize_errors { | ||||||||||||
| 109 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_errors: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 110 | 0 | my $errors = $c->error; | |||||||||||
| 111 | 0 | ▶ | return unless @$errors; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 112 | return { | ||||||||||||
| 113 | filename => 'errors.txt', | ||||||||||||
| 114 | 0 | %{ $self->dump($errors, { basename => 'errors' }) }, | |||||||||||
| 115 | ident => 'catalyst errors', | ||||||||||||
| 116 | }; | ||||||||||||
| 117 | } | ||||||||||||
| 118 | |||||||||||||
| 119 | sub summarize_user { | ||||||||||||
| 120 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_user: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 121 | 0 | ▶ | return unless $c->can('user'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 122 | |||||||||||||
| 123 | 0 | my $user = $c->user; | |||||||||||
| 124 | return { | ||||||||||||
| 125 | filename => 'user.txt', | ||||||||||||
| 126 | 0 | %{ $self->dump($user, { basename => 'user' }) }, | |||||||||||
| 127 | ident => 'authenticated catalyst user', | ||||||||||||
| 128 | }; | ||||||||||||
| 129 | } | ||||||||||||
| 130 | |||||||||||||
| 131 | sub summarize_session { | ||||||||||||
| 132 | 0 | ▶ | my ($self, $c) = @_; | ||||||||||
|
Subroutine
summarize_session: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 133 | 0 | ▶ | return unless $c->can('session'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 134 | |||||||||||||
| 135 | 0 | my $session = $c->session; | |||||||||||
| 136 | return { | ||||||||||||
| 137 | filename => 'session.txt', | ||||||||||||
| 138 | 0 | %{ $self->dump($session, { basename => 'session' }) }, | |||||||||||
| 139 | ident => 'catalyst session', | ||||||||||||
| 140 | }; | ||||||||||||
| 141 | } | ||||||||||||
| 142 | |||||||||||||
| 143 | 1 | 1; | |||||||||||
| 144 | |||||||||||||
| 145 | __END__ | ||||||||||||