Rabbit/Trait/XPathObjectMap.pm

filter: Statementstmt 100% 35 / 35 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.2% 49 / 52 CC 5 SCAR 7.8
CC
5
Cov
95%
__ANON__
4.0
__ANON__
2.0
_build_default
1.0
CRAP 2.2
« Rabbit/Trait/XPathValueMap.pm ↑ Summary Rabbit.pm »
1 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package XML::Rabbit::Trait::XPathObjectMap;
5 15 $XML::Rabbit::Trait::XPathObjectMap::VERSION = '0.4.1';
6 15 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 with 'XML::Rabbit::Trait::XPath';
9  
10 # ABSTRACT: Multiple XML DOM object xpath extractor trait
11  
12 8 ▶around '_process_options' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
13 8 my ($orig, $self, $name, $options, @rest) = @_;
14  
15 8 $self->$orig($name, $options, @rest);
16  
17 # This should really be:
18 # has '+isa' => ( required => 1 );
19 # but for some unknown reason Moose doesn't allow that
20 8 ▶ confess("isa attribute is required") unless defined( $options->{'isa'} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"isa"} 0 8 8
21  
22 15 };
23  
24  
25 has 'isa_map' => (
26 is => 'ro',
27 isa => 'HashRef[Str]',
28 lazy => 1,
29 4 ▶ default => sub { +{} },
Subroutine __ANON__: called CC=1 SCAR=0.0
30 15 );
31  
32  
33 15 has 'xpath_key' => (
34 is => 'ro',
35 isa => 'Str',
36 required => 1,
37 );
38  
39  
40 6 ▶sub _build_default {
Subroutine _build_default: called CC=1 SCAR=0.0
41 6 my ($self) = @_;
42 6 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
43 6 my ($parent) = @_;
44 6 my $xpath_query = $self->_resolve_xpath_query( $parent );
45 6 $self->_convert_isa_map( $parent );
46 6 my $class = $self->_resolve_class();
47 6 my %node_map;
48 6 foreach my $node ( $self->_find_nodes($parent, $xpath_query ) ) {
49 1460 my $key = $parent->xpc->findvalue( $self->xpath_key, $node );
50 1460 ▶ if ( defined($key) and length $key > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key and length $key > 0) 1459 1 1460
Condition66%2/3
defined $key and length $key > 0
!ll&&!rl&&r
011459
MC/DC50%1/2
defined $key and length $key > 0
defined $key length $key > 0
Truth table66%2/3
A and B
A= defined $keyB= length $key > 0
ABresult
0X0
100
111
51 1459 $node_map{ $key } = $self->_create_instance( $parent, $class, $node );
52 }
53 }
54 6 return \%node_map;
55 6 };
56 }
57  
58 15 Moose::Util::meta_attribute_alias('XPathObjectMap');
59  
60 15 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 15 1;
63  
64 __END__
« Rabbit/Trait/XPathValueMap.pm ↑ Summary Rabbit.pm »