Reporter/Summarizer.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 5 totaltotal 85.1% 40 / 47 SCAR 11.0
CC
3
Cov
94%
new
2.0
register_reporter
2.0
BEGIN
1.0
CRAP 3.0
« Reporter/Dumper.pm ↑ Summary Reporter/Sender.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;
4 # ABSTRACT: a thing that summarizes dumpables for reporting
5 1 $Exception::Reporter::Summarizer::VERSION = '0.014';
6 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #pod =head1 OVERVIEW
10 #pod
11 #pod This class exists almost entirely to allow C<isa>-checking. It provides a
12 #pod C<new> method that returns a blessed, empty object. Passing it any parameters
13 #pod will cause an exception to be thrown.
14 #pod
15 #pod A C<sanitize_filename> method is also provided, which turns a vaguely
16 #pod filename-like string into a safer filename string.
17 #pod
18 #pod =cut
19  
20 sub new {
21 11 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
22  
23 11 ▶ Carp::confess("$class constructor does not take any parameters") if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 11 11
24  
25 11 return bless {}, $class;
26 }
27  
28 sub sanitize_filename {
29 15 ▶ my ($self, $filename) = @_;
Subroutine sanitize_filename: called CC=1 SCAR=0.0
Pod undocumented
30  
31 # These don't need to be actually secure, since we won't use this for
32 # opening any filehandles. -- rjbs, 2012-07-03
33 15 $filename =~ s/\.+/./g;
34 15 $filename =~ s/[^-a-zA-Z0-9]/-/g;
35 15 return $filename;
36 }
37  
38 sub register_reporter {
39 11 ▶ my ($self, $reporter) = @_;
Subroutine register_reporter: called CC=2 SCAR=7.0
Pod undocumented
40  
41 Carp::confess("register_reporter called, but a reporter was already registered")
42 11 ▶ if $self->{reporter};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"reporter"} 0 11 11
43  
44 11 $self->{reporter} = $reporter;
45 11 Scalar::Util::weaken($self->{reporter});
46 11 return;
47 }
48  
49 6 ▶sub reporter { $_[0]->{reporter} }
Subroutine reporter: called CC=1 SCAR=0.0
Pod undocumented
50  
51 sub dump {
52 6 ▶ my ($self, $value, $arg) = @_;
Subroutine dump: called CC=1 SCAR=0.0
Pod undocumented
53 6 $self->reporter->dumper->dump($value, $arg);
54 }
55  
56 1 1;
57  
58 __END__
« Reporter/Dumper.pm ↑ Summary Reporter/Sender.pm »