Reporter/Summarizer/File.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 91.8% 34 / 37 SCAR 6.9
CC
2
Cov
96%
summarize
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Reporter/Sender.pm ↑ Summary Reporter/Summarizer/Fallback.pm »
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::File;
4 # ABSTRACT: a summarizer for a File object
5 1 $Exception::Reporter::Summarizer::File::VERSION = '0.014';
6 1 ▶use parent 'Exception::Reporter::Summarizer';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #pod =head1 OVERVIEW
9 #pod
10 #pod This summarizer expects L<Exception::Reporter::Dumpable::File> objects, and
11 #pod summarizes them just as you might expect.
12 #pod
13 #pod =cut
14  
15 1 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 sub can_summarize {
19 12 ▶ my ($self, $entry) = @_;
Subroutine can_summarize: called CC=1 SCAR=0.0
Pod undocumented
20 12 ▶ return try { $entry->[1]->isa('Exception::Reporter::Dumpable::File') };
Subroutine __ANON__: called CC=1 SCAR=0.0
21 }
22  
23 sub summarize {
24 2 ▶ my ($self, $entry) = @_;
Subroutine summarize: called CC=2 SCAR=7.0
Pod undocumented
25 2 my ($name, $value, $arg) = @$entry;
26  
27 2 my $fn_base = $self->sanitize_filename(
28 File::Basename::basename($value->path)
29 );
30  
31 return {
32 filename => $fn_base,
33 mimetype => $value->mimetype,
34 ident => "file at $name",
35 2 ▶ body => ${ $value->contents_ref },
Branch: 1 branch
BranchTrueFalseTotal
$value->charset ? : 2 0 2
36 body_is_bytes => 1,
37 ($value->charset ? (charset => $value->charset) : ()),
38 };
39 }
40  
41 1 1;
42  
43 __END__
« Reporter/Sender.pm ↑ Summary Reporter/Summarizer/Fallback.pm »