| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 304 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 21 |  | 
| 2 | 1 |  |  | 1 |  | 3 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 38 |  | 
| 3 |  |  |  |  |  |  | package Exception::Reporter::Summarizer::File; | 
| 4 |  |  |  |  |  |  | # ABSTRACT: a summarizer for a File object | 
| 5 |  |  |  |  |  |  | $Exception::Reporter::Summarizer::File::VERSION = '0.014'; | 
| 6 | 1 |  |  | 1 |  | 3 | use parent 'Exception::Reporter::Summarizer'; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | #pod =head1 OVERVIEW | 
| 9 |  |  |  |  |  |  | #pod | 
| 10 |  |  |  |  |  |  | #pod This summarizer expects L objects, and | 
| 11 |  |  |  |  |  |  | #pod summarizes them just as you might expect. | 
| 12 |  |  |  |  |  |  | #pod | 
| 13 |  |  |  |  |  |  | #pod =cut | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 |  |  | 1 |  | 37 | use File::Basename (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 13 |  | 
| 16 | 1 |  |  | 1 |  | 2 | use Try::Tiny; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 154 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub can_summarize { | 
| 19 | 12 |  |  | 12 | 0 | 13 | my ($self, $entry) = @_; | 
| 20 | 12 |  |  | 12 |  | 33 | return try { $entry->[1]->isa('Exception::Reporter::Dumpable::File') }; | 
|  | 12 |  |  |  |  | 159 |  | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub summarize { | 
| 24 | 2 |  |  | 2 | 0 | 2 | my ($self, $entry) = @_; | 
| 25 | 2 |  |  |  |  | 4 | my ($name, $value, $arg) = @$entry; | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 2 |  |  |  |  | 11 | 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 | 50 |  |  |  | 5 | body     => ${ $value->contents_ref }, | 
|  | 2 |  |  |  |  | 4 |  | 
| 36 |  |  |  |  |  |  | body_is_bytes => 1, | 
| 37 |  |  |  |  |  |  | ($value->charset ? (charset => $value->charset) : ()), | 
| 38 |  |  |  |  |  |  | }; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | 1; | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | __END__ |