Tags.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 92.3% 48 / 52 CC 3 SCAR 4.6
CC
3
Cov
90%
Tags
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« Tags/Registry.pm ↑ Summary
1 package Attribute::Method::Tags;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Attribute::Handlers;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Attribute::Method::Tags::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '0.11';
11  
12 2 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
13 # add this package to callers @ISA, as attributes only work via inheritance
14  
15 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 my $caller = caller;
18 2 push @{ "${ caller }::ISA" }, __PACKAGE__;
19 }
20  
21 4 ▶sub Tags : ATTR(CODE,RAWDATA) {
Subroutine Tags: called CC=3 SCAR=11.4
Pod documented
22 4 my ( $class, $symbol, undef, undef, $data, undef, $file, $line ) = @_;
23  
24 4 $data =~ s/^\s+//g;
25  
26 4 my @tags = split /\s+/, $data;
27  
28 4 ▶ if ( $symbol eq 'ANON' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "ANON") 0 4 4
29 0 die "Cannot tag anonymous subs at file $file, line $line\n";
30 }
31  
32 4 my $method = *{ $symbol }{ NAME };
33  
34 { # block for localising $@
35 4 local $@;
36  
37 4 Attribute::Method::Tags::Registry->add(
38 $class,
39 $method,
40 \@tags,
41 );
42 4 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
43 0 croak "Error in adding tags: $@";
44 }
45 }
46 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 1 1;
49  
50 __END__
« Tags/Registry.pm ↑ Summary