Rabbit/Trait/XPathValueMap.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 93.8% 46 / 49 CC 5 SCAR 8.2
CC
5
Cov
95%
__ANON__
4.0
__ANON__
2.0
_build_default
1.0
CRAP 2.3
« Rabbit/Role/Document.pm ↑ Summary Rabbit/Trait/XPathObjectMap.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::XPathValueMap;
5 15 $XML::Rabbit::Trait::XPathValueMap::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 value xpath extractor trait
11  
12 6 ▶around '_process_options' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
13 6 my ($orig, $self, $name, $options, @rest) = @_;
14  
15 6 $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 6 ▶ confess("isa attribute is required") unless defined( $options->{'isa'} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"isa"} 0 6 6
21 15 };
22  
23  
24 15 has 'xpath_key' => (
25 is => 'ro',
26 isa => 'Str',
27 required => 1,
28 );
29  
30  
31 15 has 'xpath_value' => (
32 is => 'ro',
33 isa => 'Str',
34 required => 1,
35 );
36  
37  
38 4 ▶sub _build_default {
Subroutine _build_default: called CC=1 SCAR=0.0
39 4 my ($self) = @_;
40 4 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
41 4 my ($parent) = @_;
42 4 my $xpath_query = $self->_resolve_xpath_query( $parent );
43 4 my %node_map;
44 4 foreach my $node ( $self->_find_nodes( $parent, $xpath_query ) ) {
45 510 my $key = $parent->xpc->findvalue( $self->xpath_key, $node );
46 510 ▶ if ( defined($key) and length $key > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key and length $key > 0) 509 1 510
Condition66%2/3
defined $key and length $key > 0
!ll&&!rl&&r
01509
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
47 509 my $value = $parent->xpc->findvalue( $self->xpath_value, $node );
48 509 $node_map{$key} = $value;
49 }
50 }
51 4 return \%node_map;
52 4 };
53 }
54  
55 15 Moose::Util::meta_attribute_alias('XPathValueMap');
56  
57 15 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 15 1;
60  
61 __END__
« Rabbit/Role/Document.pm ↑ Summary Rabbit/Trait/XPathObjectMap.pm »