XPathScript/Template/Tag.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 3 / 3 totaltotal 89.8% 53 / 59 CC 5 SCAR 6.8
CC
5
Cov
89%
set
4.0
get
2.3
__ANON__
2.0
CRAP 2.0
« XPathScript/Processor/XPath.pm ↑ Summary XPathScript/Processor/LibXML.pm »
1 package XML::XPathScript::Template::Tag;
2 35 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: XPathScript Template Element
4 35 $XML::XPathScript::Template::Tag::VERSION = '2.00';
5 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 35 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 35 ▶use Scalar::Util qw/ reftype /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 35 ▶use overload '&{}' => \&_overload_func,
Subroutine BEGIN: called CC=1 SCAR=0.0
12 35 q{""} => \&_overload_quote;
13  
14 35 our @ALLOWED_ATTRIBUTES = qw{
15 pre post
16 intro extro
17 prechildren postchildren
18 prechild testcode
19 showtag
20 postchild
21 action
22 rename
23 content contents
24 };
25  
26 3056 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
27 3056 return bless {}, shift;
28 }
29  
30 1 ▶sub get {
Subroutine get: called CC=2 SCAR=8.1
Pod documented
31 1 my $self = shift;
32 0 return wantarray ? map { $self->{$_} } @_
33 1 ▶ : $self->{$_[0]}
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
34 ;
35 }
36  
37 108 ▶sub set {
Subroutine set: called CC=4 SCAR=13.9
Pod documented
38 108 my( $self, $attribute_ref ) = @_;
39  
40 108 for my $key ( keys %{$attribute_ref} ) {
41 croak "attribute $key not allowed"
42 163 ▶ if ! grep { $key eq $_ } @ALLOWED_ATTRIBUTES;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$key eq $_;} @XML::XPathScript::Template::Tag::ALLOWED_ATTRIBUTES 0 163 163
43  
44 163 $self->{$key} = $attribute_ref->{$key};
45  
46 # renaming implies showing the tag
47 163 ▶ $self->{showtag} = 1 if $key eq 'rename';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "rename" 3 160 163
48 }
49  
50 108 return;
51 }
52  
53 1 ▶sub _overload_func {
Subroutine _overload_func: called CC=1 SCAR=0.0
54 1 my $self = shift;
55 1 ▶ return sub { $self->set( @_ ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
56 1 }
57  
58 71 ▶sub _overload_quote {
Subroutine _overload_quote: called CC=1 SCAR=1.2
59 71 my $self = shift;
60 71 return $self;
61 0 ▶ return sub { print $self };
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 }
63  
64 35 'end of XML::XPathScript::Template::Tag';
65  
66 __END__
« XPathScript/Processor/XPath.pm ↑ Summary XPathScript/Processor/LibXML.pm »