Agent/Tag_List.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 66.6% 2 / 3 totaltotal 80.0% 36 / 45 CC 3 SCAR 7.3
CC
3
Cov
82%
_typecheck
3.9
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« Agent/Stamping.pm ↑ Summary Agent/File_Pool.pm »
1 ###########################################################################
2 #
3 # Tag_List.pm
4 #
5 # Copyright (C) 1999 Raphael Manfredi.
6 # Copyright (C) 2002-2017 Mark Rogaski, mrogaski@cpan.org;
7 # all rights reserved.
8 #
9 # See the README file included with the
10 # distribution for license information.
11 #
12 ##########################################################################
13  
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 ########################################################################
17 package Log::Agent::Tag_List;
18  
19 2 require Tie::Array; # contains Tie::StdArray
20 2 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 @ISA = qw(Tie::StdArray);
22  
23 #
24 # A list of all log message tags recorded, with dedicated methods to
25 # manipulate them.
26 #
27  
28 #
29 # ->make
30 #
31 # Creation routine.
32 #
33 2 ▶sub make {
Subroutine make: called CC=1 SCAR=0.0
Pod undocumented
34 2 my $self = bless [], shift;
35 2 my (@tags) = @_;
36 2 @$self = @tags;
37 2 return $self;
38 }
39  
40 #
41 # _typecheck
42 #
43 # Make sure only objects of the proper type are given in the list.
44 # Croaks when type checking detects an error.
45 #
46 2 ▶sub _typecheck {
Subroutine _typecheck: called CC=3 SCAR=13.6
47 2 my $self = shift;
48 2 my ($type, $list) = @_;
49 2 ▶ my @bad = grep { !ref $_ || !$_->isa($type) } @$list;
Condition33%1/3
ref $_ && $_->isa($type)
!ll&&!rl&&r
002
MC/DC0%0/2
ref $_ && $_->isa($type)
ref $_ $_->isa($type)
Truth table33%1/3
A && B
A= ref $_B= $_->isa($type)
ABresult
0X0
100
111
50 2 ▶ return unless @bad;
Branch: 1 branch
BranchTrueFalseTotal
unless @bad 2 0 2
51  
52 0 my $first = $bad[0];
53 0 require Carp;
54 0 Carp::croak(sprintf
55 "Expected list of $type, got %d bad (first one is $first)",
56 scalar(@bad));
57 }
58  
59 #
60 # ->append
61 #
62 # Append list of Log::Agent::Tag objects to current list.
63 #
64 1 ▶sub append {
Subroutine append: called CC=1 SCAR=0.0
Pod documented
65 1 my $self = shift;
66 1 my (@tags) = @_;
67 1 $self->_typecheck("Log::Agent::Tag", \@tags);
68 1 push @$self, @tags;
69 }
70  
71 #
72 # ->prepend
73 #
74 # Prepend list of Log::Agent::Tag objects to current list.
75 #
76 1 ▶sub prepend {
Subroutine prepend: called CC=1 SCAR=0.0
Pod documented
77 1 my $self = shift;
78 1 my (@tags) = @_;
79 1 $self->_typecheck("Log::Agent::Tag", \@tags);
80 1 unshift @$self, @tags;
81 }
82  
83 2 1; # for require
84 __END__
« Agent/Stamping.pm ↑ Summary Agent/File_Pool.pm »