| 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::PlackRequest; | ||||||||||||
| 4 | 1 | $Exception::Reporter::Summarizer::PlackRequest::VERSION = '0.001'; | |||||||||||
| 5 | 1 | ▶ | use parent 'Exception::Reporter::Summarizer'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | # ABSTRACT: a summarizer for Plack::Request objects | ||||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use Plack::Request; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | #pod =head1 OVERVIEW | ||||||||||||
| 11 | #pod | ||||||||||||
| 12 | #pod If added as a summarizer to an L<Exception::Reporter>, this plugin will | ||||||||||||
| 13 | #pod summarize L<Plack::Request> objects, adding a summary for the request. | ||||||||||||
| 14 | #pod | ||||||||||||
| 15 | #pod =cut | ||||||||||||
| 16 | |||||||||||||
| 17 | 1 | ▶ | use Try::Tiny; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | |||||||||||||
| 19 | sub new { | ||||||||||||
| 20 | 1 | ▶ | my ($class, $arg) = @_; | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||
| 21 | 1 | ▶ | $arg ||= {}; | ||||||||||
|
Condition50%1/2
$arg ||= {}
MC/DC0%0/1
$arg ||= {}
$arg
Truth table50%1/2
A
A= $arg
| |||||||||||||
| 22 | |||||||||||||
| 23 | 1 | return bless { } => $class; | |||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | sub can_summarize { | ||||||||||||
| 27 | 0 | ▶ | my ($self, $entry) = @_; | ||||||||||
|
Subroutine
can_summarize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 28 | 0 | ▶ | return try { $entry->[1]->isa('Plack::Request') }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | sub summarize { | ||||||||||||
| 32 | 0 | ▶ | my ($self, $entry) = @_; | ||||||||||
|
Subroutine
summarize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 33 | 0 | my ($name, $req, $arg) = @$entry; | |||||||||||
| 34 | |||||||||||||
| 35 | 0 | my @summaries; | |||||||||||
| 36 | |||||||||||||
| 37 | 0 | push @summaries, $self->summarize_request($req); | |||||||||||
| 38 | |||||||||||||
| 39 | 0 | return @summaries; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | sub summarize_request { | ||||||||||||
| 43 | 0 | ▶ | my ($self, $req) = @_; | ||||||||||
|
Subroutine
summarize_request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 44 | |||||||||||||
| 45 | my %to_dump = map { | ||||||||||||
| 46 | 0 | ▶ | $_ => defined($req->$_) ? ($req->$_ . "") : undef, | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | } qw( | ||||||||||||
| 48 | address | ||||||||||||
| 49 | content_length | ||||||||||||
| 50 | content_type | ||||||||||||
| 51 | content_encoding | ||||||||||||
| 52 | remote_host | ||||||||||||
| 53 | protocol | ||||||||||||
| 54 | method | ||||||||||||
| 55 | port | ||||||||||||
| 56 | user | ||||||||||||
| 57 | request_uri | ||||||||||||
| 58 | path_info | ||||||||||||
| 59 | path | ||||||||||||
| 60 | query_string | ||||||||||||
| 61 | referer | ||||||||||||
| 62 | user_agent | ||||||||||||
| 63 | script_name | ||||||||||||
| 64 | scheme | ||||||||||||
| 65 | secure | ||||||||||||
| 66 | ); | ||||||||||||
| 67 | |||||||||||||
| 68 | 0 | $to_dump{upload} = [ $req->upload ]; | |||||||||||
| 69 | 0 | $to_dump{cookies} = $req->cookies; | |||||||||||
| 70 | |||||||||||||
| 71 | return { | ||||||||||||
| 72 | filename => 'request.txt', | ||||||||||||
| 73 | 0 | %{ $self->dump(\%to_dump, { basename => 'request' }) }, | |||||||||||
| 74 | ident => 'plack request', | ||||||||||||
| 75 | }; | ||||||||||||
| 76 | } | ||||||||||||
| 77 | |||||||||||||
| 78 | 1 | 1; | |||||||||||
| 79 | |||||||||||||
| 80 | __END__ | ||||||||||||