File Coverage

blib/lib/Data/ZPath/_Ctx.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 9 9 100.0
pod 0 5 0.0
total 37 42 88.1


line stmt bran cond sub pod time code
1 9     9   516349 use strict;
  9         33  
  9         432  
2 9     9   53 use warnings;
  9         17  
  9         638  
3              
4             package Data::ZPath::_Ctx;
5              
6 9     9   6176 use Data::ZPath::Node;
  9         31  
  9         425  
7 9     9   73 use Scalar::Util qw(blessed);
  9         15  
  9         2928  
8              
9             our $VERSION = '0.001000';
10              
11             sub new {
12 383     383 0 457035 my ( $class, $root ) = @_;
13              
14 383         687 my $root_node;
15 383 100 100     1678 if ( blessed($root) and $root->isa('Data::ZPath::Node') ) {
16 14         48 $root_node = $root;
17             }
18             else {
19 369         1424 $root_node = Data::ZPath::Node->from_root($root);
20             }
21              
22 383         2152 return bless {
23             root => $root_node,
24             nodeset => [$root_node],
25             parentset => undef,
26             }, $class;
27             }
28              
29             sub with_nodeset {
30 1353     1353 0 2289 my ( $self, $nodeset, $parentset ) = @_;
31 1353         6865 return bless {
32             %$self,
33             nodeset => $nodeset,
34             parentset => $parentset,
35             }, ref($self);
36             }
37              
38 141     141 0 445 sub root { $_[0]->{root} }
39 1304     1304 0 3139 sub nodeset { $_[0]->{nodeset} }
40 935     935 0 1887 sub parentset { $_[0]->{parentset} }
41              
42             1;